fix: disable inline transactions when db_slice has registered callbacks (#3391)

Inline transactions do not acquire any locks and therefore they should not preempt. This is no longer true when db_slice has registered callbacks.

* disable inline transactions when db_slice has registered callbacks

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
This commit is contained in:
Kostas Kyrimis 2024-07-25 19:06:35 +03:00 committed by GitHub
parent a95cf2e857
commit 79d7f57b67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -423,6 +423,10 @@ class DbSlice {
//! at a time of the call.
uint64_t RegisterOnChange(ChangeCallback cb);
bool HasRegisteredCallbacks() const {
return !change_cb_.empty();
}
// Call registered callbacks with version less than upper_bound.
void FlushChangeToEarlierCallbacks(DbIndex db_ind, Iterator it, uint64_t upper_bound);

View File

@ -1420,8 +1420,9 @@ void Transaction::CancelBlocking(std::function<OpStatus(ArgSlice)> status_cb) {
bool Transaction::CanRunInlined() const {
auto* ss = ServerState::tlocal();
auto* es = EngineShard::tlocal();
if (unique_shard_cnt_ == 1 && unique_shard_id_ == ss->thread_index() &&
ss->AllowInlineScheduling()) {
ss->AllowInlineScheduling() && !GetDbSlice(es->shard_id()).HasRegisteredCallbacks()) {
ss->stats.tx_inline_runs++;
return true;
}