feat(transaction): Idempotent callbacks (immediate runs) (#2453)

This commit generalizes the machanism of running transaction callbacks during scheduling, removing the need for specialized ScheduleUniqueShard/RunQuickie. Instead, transactions can be run now during ScheduleInShard - called "immediate" runs - if the transaction is concluding and either only a single shard is active or the operation can be safely repeated if scheduling failed (idempotent commands, like MGET).

Updates transaction stats to mirror the new changes more closely.

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
This commit is contained in:
Vladislav 2024-04-03 23:06:57 +03:00 committed by GitHub
parent 84d451fbed
commit fbc55bb82d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 150 additions and 285 deletions

View file

@ -24,19 +24,18 @@ namespace dfly {
__thread ServerState* ServerState::state_ = nullptr;
ServerState::Stats::Stats(unsigned num_shards) : tx_width_freq_arr(num_shards) {
tx_type_cnt.fill(0);
}
ServerState::Stats& ServerState::Stats::Add(const ServerState::Stats& other) {
static_assert(sizeof(Stats) == 17 * 8, "Stats size mismatch");
for (int i = 0; i < NUM_TX_TYPES; ++i) {
this->tx_type_cnt[i] += other.tx_type_cnt[i];
}
static_assert(sizeof(Stats) == 16 * 8, "Stats size mismatch");
this->eval_io_coordination_cnt += other.eval_io_coordination_cnt;
this->eval_shardlocal_coordination_cnt += other.eval_shardlocal_coordination_cnt;
this->eval_squashed_flushes += other.eval_squashed_flushes;
this->tx_global_cnt += other.tx_global_cnt;
this->tx_normal_cnt += other.tx_normal_cnt;
this->tx_inline_runs += other.tx_inline_runs;
this->tx_schedule_cancel_cnt += other.tx_schedule_cancel_cnt;
this->multi_squash_executions += other.multi_squash_executions;