From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-1.sys.kth.se (smtp-1.sys.kth.se [130.237.32.175]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id q03CdY1h020570 for ; Tue, 3 Jan 2012 07:39:35 -0500 (EST) Received: from mailscan-1.sys.kth.se (mailscan-1.sys.kth.se [130.237.32.91]) by smtp-1.sys.kth.se (Postfix) with ESMTP id 95A62156B61 for ; Tue, 3 Jan 2012 13:39:29 +0100 (CET) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-1.sys.kth.se ([130.237.32.175]) by mailscan-1.sys.kth.se (mailscan-1.sys.kth.se [130.237.32.91]) (amavisd-new, port 10024) with LMTP id 6QDOZCZrsyFC for ; Tue, 3 Jan 2012 13:39:29 +0100 (CET) X-KTH-Auth: kristaps [193.10.49.5] X-KTH-mail-from: kristaps@bsd.lv X-KTH-rcpt-to: tech@mdocml.bsd.lv Received: from ctime.hhs.se (ctime.hhs.se [193.10.49.5]) by smtp-1.sys.kth.se (Postfix) with ESMTP id 08334156B5B for ; Tue, 3 Jan 2012 13:39:28 +0100 (CET) Message-ID: <4F02F700.1060506@bsd.lv> Date: Tue, 03 Jan 2012 13:39:28 +0100 From: Kristaps Dzonsons User-Agent: Mozilla/5.0 (X11; OpenBSD amd64; rv:5.0) Gecko/20110805 Thunderbird/5.0 X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 To: tech@mdocml.bsd.lv Subject: Re: half-atomically rebuild databases References: <20120101154538.GA5307@iris.usta.de> <20120101155508.GA4516@britannica.bec.de> <20120101162958.GB5307@iris.usta.de> In-Reply-To: <20120101162958.GB5307@iris.usta.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit > Joerg Sonnenberger wrote on Sun, Jan 01, 2012 at 04:55:08PM +0100: >> On Sun, Jan 01, 2012 at 04:45:38PM +0100, Ingo Schwarze wrote: > >>> This is not perfect because the mandocdb process might get -KILLed >>> between the two renames, but i don't see a syscall anywhere to >>> atomically rename *two* files. > >> Why do you have to? > > There are two files to rename(2): whatis.{db,index}. > >> You can create the new file under temporary name in >> the same directory and rename it to the normal file name. > > That's exactly what the patch i sent does: > Creating both files under temporary names in the same directory > and rename both to the normal file names when both are ready. Hi Ingo, I don't like this: no matter how we splice it, at some point the files will be inconsistent. I also don't think it's unreasonable to have a "bogus" database for a few seconds when they're being rebuilt so long as this is documented. However, if this is a problem scenario, we can just use flock(2) and be upfront that the database is inconsistent (apropos_db.c and mandocdb.c would need to sync open order) instead of crossing our fingers and hoping that they don't dbopen(3) between rename(2)s. Thoughts? Kristaps -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv