From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 1314B1F461; Tue, 25 Jun 2019 17:51:33 +0000 (UTC) Date: Tue, 25 Jun 2019 17:51:32 +0000 From: Eric Wong To: "Eric W. Biederman" Cc: meta@public-inbox.org Subject: Re: Q: Did you do something to message number recently? Message-ID: <20190625175132.ng7oasz6ft3zbhsm@dcvr> References: <878strvusz.fsf@xmission.com> <20190624163442.xhk6drl7ptnq7i5o@dcvr> <20190624173319.3bb4t3zrieb4k5w2@dcvr> <877e9avbh2.fsf@xmission.com> <20190624234212.j7ghrejyv7ts7y2u@dcvr> <878stpub4d.fsf@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <878stpub4d.fsf@xmission.com> List-Id: "Eric W. Biederman" wrote: > Eric Wong writes: > > > "Eric W. Biederman" wrote: > >> The add method computes the number using num_for, which uses > >> Msgmpa::mid_insert. > >> > >> Short of the sequence number for msgmap getting scrambled I don't > >> see how that can go wrong. Sigh. > > > > That seems to be what went wrong with "INSERT OR IGNORE" > > > > cf. https://public-inbox.org/meta/20190624233809.1721-1-e@80x24.org/ > > Is it INSERT OR IGNORE or is it the autoincrement? As I read > the sqlite docs autoincrement is allowed to skip message numbers. > Especially in cases where the insert fails. Changing it to plain INSERT made the autoincrement stop skipping. That's been my experience with other DBs in the past, too; but I haven't used "OR IGNORE" much (and it's been a long time since I've looked at SQL outside of SQLite). > This fix should come with a test case shouldn't it? Such a test > case should be pretty straight forward to write. Insert a message > multiple times and then insert a new one. Did you see my changes to t/msgmap.t and t/v2writable.t? I appended the test to existing dupe test in t/msgmap.t and added the num_highwater check to t/v2writable.t which hit duplicates. I don't think there needs to be a separate test, and the test suite is already slow enough to impact productivity on my laptop. > I don't recall the transaction constraints on sqlite but I am wondering > if instead of INSERT OR IGNORE we should read and the increment > num_highwater in the public-inbox code and then we would not need to > depend upon autoincrement only incrementing once. Even when the sqlite > docs don't promise it will. Yeah, that's probably the right step going forward. I don't think there's forward/backwards-compatibility things to worry about, since the indexing code for mirrors already ignores the autoincrement.