diff --git a/lib/cyrusdb_twom.c b/lib/cyrusdb_twom.c index 90f2346154..c239162577 100644 --- a/lib/cyrusdb_twom.c +++ b/lib/cyrusdb_twom.c @@ -2000,10 +2000,10 @@ static int mycheckpoint(struct dbengine *db) r = opendb(newfname, flags, &cr.db, &cr.tid); if (r) return r; - // has it already repacked? - if (cr.db->openfile->header.num_records || - cr.db->openfile->header.generation > 1 || - !memcmp(cr.db->openfile->header.uuid, db->openfile->header.uuid, 16)) { + // did we lose the race? (same uuid, higher generation, records exist) + if (!memcmp(cr.db->openfile->header.uuid, db->openfile->header.uuid, 16) + || cr.db->openfile->header.generation > 1 + || cr.db->openfile->header.num_records) { r = myabort(cr.db, cr.tid); if (r) goto err; myclose(cr.db);