during rename, we delete old key and create a new one in parallel, which affects transaction atomicity
we run next cb in parallel on 2 shards
void Renamer::FinalizeRename() {
auto cb = [this](Transaction* t, EngineShard* shard) {
const ShardId shard_id = shard->shard_id();
if (!do_copy_ && shard_id == src_sid_) {
return DelSrc(t, shard);
}
if (shard_id == dest_sid_) {
return DeserializeDest(t, shard);
}
return OpStatus::OK;
};
transaction_->Execute(std::move(cb), true);
}
Consider next flow
DelSrc() -> success DeserializeDest(t, shard); -> ERROR but the source is already deleted, so we lost the data
Under what conditions can DeserializeDest fail ?
I don't think we have an atomicity problem here. We should lock both of the keys when we initialize the transaction and no other transaction shall access them until we conclude.
Under what conditions can
DeserializeDestfail ?I don't think we have an atomicity problem here. We should lock both of the keys when we initialize the transaction and no other transaction shall access them until we conclude.
Under current, or because of OOM, or something that we can not predict
Other transactions don't matter if DeserializeDest() fails, we lose data
Hey can we break this transaction in 2 parts and execute DeserializeDest first in first hop and then DeleteSrc in second hop? with this we can check if DeserializeDest is successful before executing DeleteSrc function.