chore: Refactor string span management (#3165)

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
This commit is contained in:
Vladislav 2024-06-18 10:37:32 +03:00 committed by GitHub
parent 6291c04016
commit e45c1e92a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 198 additions and 273 deletions

View file

@ -257,10 +257,9 @@ void Transaction::PrepareMultiFps(CmdArgList keys) {
auto& tag_fps = multi_->tag_fps;
tag_fps.reserve(keys.size());
for (MutableSlice key : keys) {
string_view sv = facade::ToSV(key);
ShardId sid = Shard(sv, shard_set->size());
tag_fps.emplace(sid, LockTag(sv).Fingerprint());
for (string_view str : ArgS(keys)) {
ShardId sid = Shard(str, shard_set->size());
tag_fps.emplace(sid, LockTag(str).Fingerprint());
}
}
@ -1213,7 +1212,8 @@ OpStatus Transaction::WaitOnWatch(const time_point& tp, WaitKeysProvider wkeys_p
return result;
}
OpStatus Transaction::WatchInShard(const ShardArgs& keys, EngineShard* shard, KeyReadyChecker krc) {
OpStatus Transaction::WatchInShard(BlockingController::Keys keys, EngineShard* shard,
KeyReadyChecker krc) {
auto& sd = shard_data_[SidToId(shard->shard_id())];
CHECK_EQ(0, sd.local_mask & SUSPENDED_Q);
@ -1221,12 +1221,12 @@ OpStatus Transaction::WatchInShard(const ShardArgs& keys, EngineShard* shard, Ke
sd.local_mask &= ~OUT_OF_ORDER;
shard->EnsureBlockingController()->AddWatched(keys, std::move(krc), this);
DVLOG(2) << "WatchInShard " << DebugId() << ", first_key:" << keys.Front();
DVLOG(2) << "WatchInShard " << DebugId();
return OpStatus::OK;
}
void Transaction::ExpireShardCb(const ShardArgs& wkeys, EngineShard* shard) {
void Transaction::ExpireShardCb(BlockingController::Keys keys, EngineShard* shard) {
// Blocking transactions don't release keys when suspending, release them now.
auto lock_args = GetLockArgs(shard->shard_id());
shard->db_slice().Release(LockMode(), lock_args);
@ -1234,7 +1234,7 @@ void Transaction::ExpireShardCb(const ShardArgs& wkeys, EngineShard* shard) {
auto& sd = shard_data_[SidToId(shard->shard_id())];
sd.local_mask &= ~KEYLOCK_ACQUIRED;
shard->blocking_controller()->FinalizeWatched(wkeys, this);
shard->blocking_controller()->FinalizeWatched(keys, this);
DCHECK(!shard->blocking_controller()->awakened_transactions().contains(this));
// Resume processing of transaction queue