Skip to content

Commit

Permalink
CLIENT-3199 Do not close/delete MRT monitor record on abort/commit wh…
Browse files Browse the repository at this point in the history
…en a write command in that MRT fails and is inDoubt.
  • Loading branch information
BrianNichols committed Dec 4, 2024
1 parent 9f35a15 commit b733f24
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 24 deletions.
8 changes: 4 additions & 4 deletions src/include/aerospike/as_txn.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ typedef struct as_txn {
uint32_t timeout;
uint32_t deadline;
as_txn_state state;
bool monitor_in_doubt;
bool write_in_doubt;
bool in_doubt;
bool free;
} as_txn;
Expand Down Expand Up @@ -250,12 +250,12 @@ AS_EXTERN as_status
as_txn_set_ns(as_txn* txn, const char* ns, as_error* err);

/**
* Does MRT monitor record exist or is in doubt.
* Return if the MRT monitor record should be closed/deleted. For internal use only.
*/
static inline bool
as_txn_monitor_might_exist(as_txn* txn)
as_txn_close_monitor(as_txn* txn)
{
return txn->deadline != 0 || txn->monitor_in_doubt;
return txn->deadline != 0 && !txn->write_in_doubt;
}

/**
Expand Down
3 changes: 0 additions & 3 deletions src/main/aerospike/aerospike_batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -4225,9 +4225,6 @@ as_batch_txn_callback(as_error* err, as_record* rec, void* udata, as_event_loop*
as_batch_txn* bt = udata;

if (err) {
if (err->in_doubt) {
bt->txn->monitor_in_doubt = true;
}
destroy_versions(bt->versions);
bt->listener(err, bt->records, bt->udata, event_loop);
cf_free(bt);
Expand Down
3 changes: 0 additions & 3 deletions src/main/aerospike/aerospike_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,6 @@ as_txn_monitor_callback(as_error* err, as_record* rec, void* udata, as_event_loo
as_event_command* cmd = udata;

if (err) {
if (err->in_doubt) {
cmd->txn->monitor_in_doubt = true;
}
as_write_command_notify(err, cmd, event_loop);
as_event_command_destroy(cmd);
return;
Expand Down
6 changes: 3 additions & 3 deletions src/main/aerospike/aerospike_txn.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ as_commit(aerospike* as, as_error* err, as_txn* txn, as_commit_status* commit_st
return AEROSPIKE_OK;
}

if (as_txn_monitor_might_exist(txn)) {
if (as_txn_close_monitor(txn)) {
status = as_txn_monitor_remove(as, err, &roll_policy->base, &key);

if (status != AEROSPIKE_OK) {
Expand Down Expand Up @@ -179,7 +179,7 @@ as_verify_and_commit(aerospike* as, as_error* err, as_txn* txn, as_commit_status
return verify_status;
}

if (as_txn_monitor_might_exist(txn)) {
if (as_txn_close_monitor(txn)) {
as_key key;
as_txn_monitor_init_key(txn, &key);

Expand Down Expand Up @@ -250,7 +250,7 @@ as_abort(aerospike* as, as_error* err, as_txn* txn, as_abort_status* abort_statu
return AEROSPIKE_OK;
}

if (as_txn_monitor_might_exist(txn)) {
if (as_txn_close_monitor(txn)) {
as_key key;
as_txn_monitor_init_key(txn, &key);

Expand Down
3 changes: 2 additions & 1 deletion src/main/aerospike/as_txn.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ as_txn_init_all(as_txn* txn, uint32_t read_buckets, uint32_t write_buckets)
txn->timeout = 0; // Zero means use server configuration mrt-duration.
txn->deadline = 0;
txn->state = AS_TXN_STATE_OPEN;
txn->monitor_in_doubt = false;
txn->write_in_doubt = false;
txn->in_doubt = false;
as_txn_hash_init(&txn->reads, read_buckets);
as_txn_hash_init(&txn->writes, write_buckets);
Expand Down Expand Up @@ -342,6 +342,7 @@ as_txn_on_write(as_txn* txn, const uint8_t* digest, const char* set, uint64_t ve
void
as_txn_on_write_in_doubt(as_txn* txn, const uint8_t* digest, const char* set)
{
txn->write_in_doubt = true;
as_txn_hash_remove(&txn->reads, digest);
as_txn_hash_put(&txn->writes, digest, set, 0);
}
Expand Down
11 changes: 1 addition & 10 deletions src/main/aerospike/as_txn_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,7 @@ as_txn_monitor_add_keys(
// the MRT timeout field on successive MRT monitor record updates.
ops->ttl = txn->timeout;

as_status status = as_txn_monitor_operate(as, err, txn, &txn_policy, &key, ops);

if (status != AEROSPIKE_OK) {
if (err->in_doubt) {
txn->monitor_in_doubt = true;
}
return status;
}

return status;
return as_txn_monitor_operate(as, err, txn, &txn_policy, &key, ops);
}

as_status
Expand Down

0 comments on commit b733f24

Please sign in to comment.