diff --git a/ctdb/common/ctdb_ltdb.c b/ctdb/common/ctdb_ltdb.c index 12fcf52d959..b2fd1899432 100644 --- a/ctdb/common/ctdb_ltdb.c +++ b/ctdb/common/ctdb_ltdb.c @@ -128,6 +128,7 @@ int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key, struct ctdb_context *ctdb = ctdb_db->ctdb; TDB_DATA rec; int ret; + bool seqnum_suppressed = false; if (ctdb->flags & CTDB_FLAG_TORTURE) { struct ctdb_ltdb_header *h2; @@ -147,10 +148,28 @@ int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key, memcpy(rec.dptr, header, sizeof(*header)); memcpy(rec.dptr + sizeof(*header), data.dptr, data.dsize); + /* Databases with seqnum updates enabled only get their seqnum + changes when/if we modify the data */ + if (ctdb_db->seqnum_update != NULL) { + TDB_DATA old; + old = tdb_fetch(ctdb_db->ltdb->tdb, key); + + if ( (old.dsize == rec.dsize) + && !memcmp(old.dptr+sizeof(struct ctdb_ltdb_header), + rec.dptr+sizeof(struct ctdb_ltdb_header), + rec.dsize-sizeof(struct ctdb_ltdb_header)) ) { + tdb_remove_flags(ctdb_db->ltdb->tdb, TDB_SEQNUM); + seqnum_suppressed = true; + } + if (old.dptr) free(old.dptr); + } ret = tdb_store(ctdb_db->ltdb->tdb, key, rec, TDB_REPLACE); if (ret != 0) { DEBUG(DEBUG_ERR, (__location__ " Failed to store dynamic data\n")); } + if (seqnum_suppressed) { + tdb_add_flags(ctdb_db->ltdb->tdb, TDB_SEQNUM); + } talloc_free(rec.dptr);