From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:4ea1::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iHsAC5izx2GQywAAgWs5BA (envelope-from ) for ; Sun, 26 Dec 2021 01:13:12 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 4EoHBZizx2FWwwAAG6o9tA (envelope-from ) for ; Sun, 26 Dec 2021 01:13:12 +0100 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D079729D68 for ; Sun, 26 Dec 2021 01:13:11 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 4FB715F71E; Sun, 26 Dec 2021 00:13:08 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 464555F71B for ; Sun, 26 Dec 2021 00:13:06 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id B4C425FC42; Sat, 25 Dec 2021 19:13:05 -0500 (EST) Received: (nullmailer pid 3381348 invoked by uid 1000); Sun, 26 Dec 2021 00:13:04 -0000 From: David Bremner To: Steven Allen , notmuch@notmuchmail.org Subject: Re: [bug] notmuch doesn't commit changes before an open transaction on close In-Reply-To: <20151025210215.GA3754@stebalien.com> References: <20151025210215.GA3754@stebalien.com> Date: Sat, 25 Dec 2021 20:13:04 -0400 Message-ID: <87sfugmdf3.fsf@tethera.net> MIME-Version: 1.0 Message-ID-Hash: JZORSFFUGFUA3JNWM46AX52CXPGSK7C6 X-Message-ID-Hash: JZORSFFUGFUA3JNWM46AX52CXPGSK7C6 X-MailFrom: david@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640477591; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=HCABEOBUV/Ryzzv/noM87Um63tsa9uWET6dCe6jp7uc=; b=OUSoKl69r4VP3NVF5xk4LiAhX4J0E9Fi6pcFirjYqtOBX3cLSCiPV+kcM6iTjKu9cIC/p8 jPonqnmXQB9Bg3utQ91L1ue9TmJ3mQ9BNJnQLzQHum9yDmS62o5b3rMlHNNwDiFmDi1L69 U72Ewe5gPSKyYofdZLH5+Ufb81f4m0TcWP2Vk9+SQLYT6TVJl5X3Zr0ST3qUlizqcJ5SbL au5jCJaAcEbLeUhltdff3rrImT9aAebq+s9Uqu9IuwPHDA7GLmllP2KL1iua0NPnUn6Lvn BEjRIds/VuXXyocYDB1i4siVQQDRmExvxOTt+7z27Kqsn+pDvq0eCM1l8huYxg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640477591; a=rsa-sha256; cv=none; b=CGG7sgOQYQVKh5HQ762YMSXRvHRddg2ekHG/GUipJ7Oo9U1Cs+MTelQGGK3GF8omgG2tLy DpNGE5z0YhjG1VBFNlScSaCDcA8mV560Bk5ri9WTDkxbR5yfquK0BcjVht+SSrGykUHY8G eX++QSM5xeJLJpyKZP2RWvDzUXoeFMQNIMHTmDHjWdM5B1EGpubklCgOjRc0ZwAWeeaP00 NduOFIZw9U+rXKQRxJOZGz7njaqctRESIU88cNxLIDdbbPP+wfgxCZRua8vZsvCwK0OglC onssfxXCKbVU4ENoqfLPEUCPxCMwVr9RJfXDYhiUGMdoh5u+1pEq1HW7vJNMgw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -2.17 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: D079729D68 X-Spam-Score: -2.17 X-Migadu-Scanner: scn1.migadu.com X-TUID: phesYmDS5fDq Steven Allen writes: > Notmuch claims to commit changes made before an open transaction on > close but actually throws them away (according to the documentation). > > According to the notmuch documentation, > >> For writable databases, notmuch_database_close commits all changes >> to disk before closing the database. If the caller is currently in >> an atomic section (there was a notmuch_database_begin_atomic >> without a matching notmuch_database_end_atomic), this will discard >> changes made in that atomic section (but still commit changes made >> prior to entering the atomic section). > > However, this isn't true. Notmuch atomic transactions don't flush on > entry so, this comment from the xapian documentation applies: > >> If you're applying atomic groups of changes and only wish to ensure >> that each group is either applied or not applied, then you can prevent >> the automatic commit() before and after the transaction by starting >> the transaction with begin_transaction(false). However, if >> cancel_transaction is called (or if commit_transaction isn't called >> before the WritableDatabase object is destroyed) then any changes >> which were pending before the transaction began will also be >> discarded. > > source: http://xapian.org/docs/apidoc/html/classXapian_1_1WritableDatabase.html > > This means that, in theory at least, xapian could throw away *all* > changes to the database if a transaction is open. The docs are corrected, and notmuch now does periodic automatic commits to reduce the amount of lost work when interrupted. At the moment I think that is the best we can do, so I'm marking this as fixed.