Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ezxWv-0007f8-Sa for pgsql-hackers@arkaria.postgresql.org; Sun, 25 Mar 2018 04:45:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ezxWu-0000d9-J2 for pgsql-hackers@arkaria.postgresql.org; Sun, 25 Mar 2018 04:45:16 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ezxWu-0000cl-8f for pgsql-hackers@lists.postgresql.org; Sun, 25 Mar 2018 04:45:16 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ezxWq-0006A7-Pi for pgsql-hackers@postgresql.org; Sun, 25 Mar 2018 04:45:14 +0000 Received: by mail-wm0-x243.google.com with SMTP id v21so9826765wmc.1 for ; Sat, 24 Mar 2018 21:45:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=5UHmXC1SGMevEkKkLG3T+aPxLFGUDdG3U8jSH64U8MQ=; b=P5/KwkvQQSoHj+wtfts4yoVVXoryxRL4+UABlSmyinKWkAkfcQiObxvf7g1x6re91v zcug9fopPz0yKiCkBJk/UXKFBbnLJKFMU0POlV6HuOQYv2N4Rm6VaIJCvwxmRIx3qtOY Hkp+BoUWZDOvdY1XqAybT0tqvt32T54awO0L5aYgxKkVGmwWlfT7tUO3GtJB7J/TxLTy qEaV8XHQyoJDEC/drDyVO7eCJZfnx30tRPIpigtRz/Gn2kPWGIU8bNu0iLSjZDGyqHJe Jy+TYN8endas99eUo67l6oKgESZPr5dYtc6gZykaG0RUA+eCOVHcImHMkuCcZKdLnVTS oG8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=5UHmXC1SGMevEkKkLG3T+aPxLFGUDdG3U8jSH64U8MQ=; b=HjRyN4+Z3i4NRqgzdHQJKwP87p0YN9wmqsjpHhufc9m1vvSIK5wU0x1tojhaPfqS9N nmk31DVPyyRCaeuEDgRjtf9fXhJ0tTlXdw4p66/YZHD+nEPmB94E7cVEKq1bSlFiWdT1 94ZSXZvwskxQtzZr+H8Uxep8Ho+eLeefAi0veVMgYYZKUL/LKuKuxIbBe3x6FbXLXXFN uIta3A6psTx+3hPh6LdbWVigVXVDDlOoSPr2XoxMgxd35rpq+A6IPic4mbuBcFeMms9p nusNoxeyxG3pjnxFSmPIFWTv02N1O9trkD11uOXTDcBaxmLntrGoRRKil5ySEFuOHjBy 8wGQ== X-Gm-Message-State: AElRT7HyqlkaMTVIFYRrS8aiOX5W5+zVAZuAkFYsfaA7O5DMf5jwiGn6 sDI1SlrKyCUx4+5TLluYLDbcy2Ny61k/HmmKjhFiXvei+l55yfhKPsgnqYonkyEeKFVxrXViuAq olUsSYDee8Sidd+PMe8qhbYmxG4KjpMrq1mG09ZN8YvcYivI++fwxN8ds2Q7bNvv/0V7NRch15U jxFiZN79CjLiw= X-Google-Smtp-Source: AG47ELuje2er/FH/CNt7HoK1VNYLmR/ccRL8jmOwYQSqm+gotw0biHxDm5sqfuIeXUCKOwd5eKcSvw== X-Received: by 10.28.48.149 with SMTP id w143mr13062083wmw.88.1521953109944; Sat, 24 Mar 2018 21:45:09 -0700 (PDT) Received: from [10.137.2.17] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id o70sm12479982wmg.3.2018.03.24.21.45.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Mar 2018 21:45:08 -0700 (PDT) Subject: Re: [PROPOSAL] Shared Ispell dictionaries To: Tom Lane Cc: Arthur Zakirov , Pavel Stehule , Andres Freund , Ildus Kurbangaliev , pgsql-hackers References: <20180307131819.GA13301@zakirov.localdomain> <3c7910ba-2a1b-5b73-71c6-d037ba1e89bd@2ndquadrant.com> <20180319110648.GA32319@zakirov.localdomain> <2ae9588a-f3cb-777d-1958-c76c22225823@2ndquadrant.com> <20180320131149.GA12884@zakirov.localdomain> <20180321090050.GA21751@zakirov.localdomain> <20180322105603.GA23544@zakirov.localdomain> <28250.1521924996@sss.pgh.pa.us> <25186.1521951490@sss.pgh.pa.us> From: Tomas Vondra Message-ID: Date: Sun, 25 Mar 2018 06:45:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <25186.1521951490@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 03/25/2018 06:18 AM, Tom Lane wrote: > Tomas Vondra writes: >> On 3/24/18 9:56 PM, Tom Lane wrote: >>> Also, the scheme for releasing the dictionary DSM during >>> RemoveTSDictionaryById is uncertain and full of race conditions: >>> the DROP might roll back later, or someone might come along and >>> start using the dictionary (causing a fresh DSM load) before the >>> DROP commits and makes the dictionary invisible to other sessions. >>> I don't think that either of those are necessarily fatal objections, >>> but there needs to be some commentary there explaining what happens. > >> Actually, I think that's an issue - such race condition might easily >> leak the shared memory forever (because the new dictionary will get a >> different OID etc.). It probably is not happening very often, because >> dictionaries are not dropped very often. But it needs fixing I think. > > My thought was (a) the ROLLBACK case is ok, because the next use of > the dictionary will reload it, and (b) the reload-concurrently-with- > DROP case is annoying, because indeed it leaks, but the window is small > and it probably won't be an issue in practice. We would need to be > sure that the DSM segment goes away at postmaster restart, but given > that I think it'd be tolerable. Of course it'd be better not to have > the race, but I see no easy way to prevent it -- do you? > Unfortunately no :( For a moment I thought that perhaps we could make it a responsibility of the last user of the dictionary - set a flag in the shared memory, and the last user would remove it. But the trouble is how to decide who's the last one? Even with some simple reference counting, we probably don't know if that's the really last one. FWIW this is where the view listing dictionaries loaded into shared memory would be helpful - you'd at least know there's a dictionary, wasting memory. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services