dragonfly icon indicating copy to clipboard operation
dragonfly copied to clipboard

during rename, we delete old key and create a new one in parallel, which affects transaction atomicity

Open BorysTheDev opened this issue 7 months ago • 2 comments

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

BorysTheDev avatar Jun 13 '25 13:06 BorysTheDev

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.

kostasrim avatar Jun 13 '25 13:06 kostasrim

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 current, or because of OOM, or something that we can not predict

Other transactions don't matter if DeserializeDest() fails, we lose data

BorysTheDev avatar Jun 13 '25 13:06 BorysTheDev

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.

H4R5H1T-007 avatar Jun 22 '25 13:06 H4R5H1T-007