Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 7BF88431FD0 for ; Thu, 15 Dec 2011 20:06:03 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id W+w15xDJn+3b for ; Thu, 15 Dec 2011 20:06:01 -0800 (PST) Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU [18.9.25.13]) by olra.theworths.org (Postfix) with ESMTP id 8CF20429E26 for ; Thu, 15 Dec 2011 20:06:01 -0800 (PST) X-AuditID: 1209190d-b7f576d0000008c4-83-4eeac3a8bf45 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP id B5.1E.02244.8A3CAEE4; Thu, 15 Dec 2011 23:06:00 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id pBG45xYl018116; Thu, 15 Dec 2011 23:06:00 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id pBG45vTh003354 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Thu, 15 Dec 2011 23:05:58 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1RbP4s-0003jJ-AX; Thu, 15 Dec 2011 23:07:22 -0500 Date: Thu, 15 Dec 2011 23:07:22 -0500 From: Austin Clements To: David Bremner Subject: Re: More ideas about logging. Message-ID: <20111216040722.GC12245@mit.edu> References: <87obv9i7y3.fsf@zancas.localnet> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87obv9i7y3.fsf@zancas.localnet> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphleLIzCtJLcpLzFFi42IR4hTV1l1x+JWfQfNMS4uNy34yW1y/OZPZ 4v7y96wOzB6/2uYyezxbdYvZY93OP+wBzFFcNimpOZllqUX6dglcGT3TZzAVLOCsOHXvLWMD 4wL2LkZODgkBE4lP64+yQNhiEhfurWfrYuTiEBLYxygx8WA/WJGQwAZGiTtreSESJ5kk3q6d zAzhLGGUuPp+J1ALBweLgKrEv8OWIA1sAhoS2/YvZwSxRQTUJO4uawezmQU8JKYdOccEYgsD xVdd6WEFsXkFdCS6zv9ihVimI3FsZgcjRFxQ4uTMJywQvVoSN/69ZAJZxSwgLbH8HwdImFNA V2Ld271gd4oKqEhMObmNbQKj0Cwk3bOQdM9C6F7AyLyKUTYlt0o3NzEzpzg1Wbc4OTEvL7VI 10gvN7NELzWldBMjONAleXcwvjuodIhRgINRiYc3wOqVnxBrYllxZe4hRkkOJiVR3pp9QCG+ pPyUyozE4oz4otKc1OJDjBIczEoivOL2QDnelMTKqtSifJiUNAeLkjhvza6HfkIC6Yklqdmp qQWpRTBZGQ4OJQne94eAGgWLUtNTK9Iyc0oQ0kwcnCDDeYCGsx4GGV5ckJhbnJkOkT/FqCgl zvsHpFkAJJFRmgfXC0tErxjFgV4R5mUHaecBJjG47ldAg5mABm8PewEyuCQRISXVwMhzLe3S 0/3STecSd02a8qqj/NqWIwd9VLRXFv/h8d2/ca5lu4BY8G623UJHt5/cYVe7qeb/ir9cJ5n1 1y/Nsjx6+9vE+HPc6QU96o9d74WeOnz02Tr56PxHNp3C+t77t92wVDguteMCzy+tWF7Jk4c4 k9jMuEudvJgmLf543F5n4qkfd46dPOalxFKckWioxVxUnAgAagFDfB8DAAA= Cc: Olly Betts , Notmuch Mail X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2011 04:06:03 -0000 Quoth David Bremner on Dec 15 at 10:09 pm: > Assume we have routines read_metadata and write_metadata that read and > write to the xapian database metadata (in real life, I think we might > need to decide in advance exactly what will be written there). > > when we create a database > > write_metadata('log_write',0) > write_metadata('log_read',0) // more about this later > > To carry out database operation X with logging, we do the following > > begin_atomic > > txn=read_metadata('last_written') > > X > > // begin dangerzone > fprintf(logfile,"%d %s",num+1,stuff) // or whatever. > > write_metadata('last_written', num+1) > > end_atomic > //end dangerzone The trouble with this approach is that the OS doesn't have to flush logfile to the disk platters in any particular order relative to the updates to Xapian. So, after someone trips over your plug, you could come back with Xapian saying you have 500 log entries when your logfile comes back with only 20. The only way I know of to fix this is to fsync after the logfile write, which would obviously have performance issues. But maybe there are cleverer ways?