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 1f02La-0004r8-8N for pgsql-hackers@arkaria.postgresql.org; Sun, 25 Mar 2018 09:53:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f02LY-0004e4-GU for pgsql-hackers@arkaria.postgresql.org; Sun, 25 Mar 2018 09:53:52 +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 1f02LY-0004du-32 for pgsql-hackers@lists.postgresql.org; Sun, 25 Mar 2018 09:53:52 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f02LT-0004SE-NR for pgsql-hackers@postgresql.org; Sun, 25 Mar 2018 09:53:50 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 4BB2E21C1E66; Sun, 25 Mar 2018 12:53:44 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from arthur.localdomain (unknown [94.29.3.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id CA48121C1E5D; Sun, 25 Mar 2018 12:53:43 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1521971624; bh=QvXbFMFmB02sR+Qx7dsy83X6/nkkaM8GZixGKWkqAWg=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=FvPmW+uHB6CkPbQUg6KxfZ2we2vj1yzuGdXSY1hErpHaK+1OfbzEmO6VbNZgiesm+ jy/diiAMbi2ceawcsJ9GmFMKiWbtGg8mIltmEduT5TJYp+NRguWGKFglq6rumFp8bJ qXU5IcgO5vuKbSN33xw4KS/SzUVofWX+qObGOl/s= Date: Sun, 25 Mar 2018 12:53:41 +0300 From: Arthur Zakirov To: Tom Lane Cc: Tomas Vondra , Pavel Stehule , Andres Freund , Ildus Kurbangaliev , pgsql-hackers Subject: Re: [PROPOSAL] Shared Ispell dictionaries Message-ID: <20180325095340.GA1370@arthur.localdomain> References: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <28250.1521924996@sss.pgh.pa.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, Mar 24, 2018 at 04:56:36PM -0400, Tom Lane wrote: > Arthur Zakirov writes: > > [ v10 patch versions ] Thank you for the review, Tom! Tomas Vondra wrote: > Tom Lane wrote: >> * I cannot imagine a use-case for setting max_shared_dictionaries_size >> to anything except "unlimited". If it's not that, and you exceed it, >> then subsequent backends load private copies of the dictionary, making >> your memory situation rapidly worse not better. I think we should lose >> that GUC altogether and just load dictionaries automatically. > > Introduction of that limit is likely my fault. It came from from an > extension I wrote a long time ago, but back then it was a necessity > because we did not have DSM. So in retrospect I agree with you - it's > not particularly useful and we should ditch it. > > Arthur, let this be a lesson for you! You have to start fight against > bogus feature requests from other people ;-) Yeah, in this sense max_shared_dictionaries_size is pointless. I'll remove it then :). > * Similarly, I see no point in a "sharable" option on individual > dictionaries, especially when there's only one allowed setting for > most dictionary types. Let's lose that too. I think "Shareable" option could be useful if a shared dictionary building time was much longer than a non-shared dictionary building time. It is slightly longer because of additional memcpy(), but isn't noticable I think. So it is worth to remove it. > * And that leads us to not particularly need a view telling which > dictionaries are loaded, either. It's just an implementation detail > that users don't need to worry about. If all dictionaries will be shareable then this view could be removed. Unfortunately I think it can't help with leaked segments, I didn't find a way to iterate dshash entries. That's why pg_ts_shared_dictionaries() scans pg_ts_dict table instead of scanning dshash table. > I do think it's required that changing the dictionary's options with > ALTER TEXT SEARCH DICTIONARY automatically cause a reload; but if that's > happening with this patch, I don't see where. (It might work to use > the combination of dictionary OID and TID of the dictionary's pg_ts_dict > tuple as the lookup key for shared dictionaries. Oh, and have you > thought about the possibility of conflicting OIDs in different DBs? > Probably the database OID has to be part of the key, as well.) Yes unfortunately ALTER TEXT SEARCH DICTIONARY doesn't reload a dictionary. TID can help here. I thought about using XID too when I started to work on RELOAD command. But I'm not sure that it is a good idea, anyway XID isn't needed in current version. > 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. I missed this case. As you wrote below ROLLBACK case is ok. But I haven't a soluton for the second case for now. If I won't solve it I'll add additional comments in RemoveTSConfigurationById() and maybe in the documentation if it's appropriate. > BTW, I was going to complain that this patch alters the API for > dictionary template init functions without any documentation updates; > but then I realized that there isn't any documentation to update. > That pretty well sucks, but I suppose it's not the job of this patch > to improve that situation. Still, you could spend a bit more effort on > the commentary in ts_public.h in 0002, because that commentary is as > close to an API spec as we've got. I'll fix the comments. -- Arthur Zakirov Postgres Professional: http://www.postgrespro.com Russian Postgres Company