int ret;
header->flags &= ~(CTDB_REC_RO_REVOKING_READONLY|CTDB_REC_RO_HAVE_DELEGATIONS|CTDB_REC_RO_HAVE_READONLY);
+ header->flags |= CTDB_REC_FLAG_MIGRATED_WITH_DATA;
header->rsn -= 1;
if ((rc = talloc_zero(ctdb_db, struct revokechild_handle)) == NULL) {
struct ctdb_db_context *ctdb_db;
struct ctdb_marshall_buffer *m;
struct ctdb_req_control *c;
+ uint32_t flags;
};
+/* dont create/update records that does not exist locally */
+#define UPDATE_FLAGS_REPLACE_ONLY 1
/*
called from a child process to write the data
goto failed;
}
+ /* we must check if the record exists or not because
+ ctdb_ltdb_fetch will unconditionally create a record
+ */
+ if (state->flags & UPDATE_FLAGS_REPLACE_ONLY) {
+ TDB_DATA rec;
+ rec = tdb_fetch(state->ctdb_db->ltdb->tdb, key);
+ if (rec.dsize == 0) {
+ talloc_free(tmp_ctx);
+ continue;
+ }
+ free(rec.dptr);
+ }
+
/* fetch the old header and ensure the rsn is less than the new rsn */
ret = ctdb_ltdb_fetch(state->ctdb_db, key, &oldheader, tmp_ctx, &olddata);
if (ret != 0) {
state->ctdb_db = ctdb_db;
state->c = c;
state->m = m;
+ state->flags = UPDATE_FLAGS_REPLACE_ONLY;
/* create a child process to take out a transaction and
write the data.