Skip to content

Commit

Permalink
adding comment
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldoglas committed Jun 4, 2024
1 parent 92f7272 commit 6daf253
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sqlitecluster/SQLiteNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,10 @@ void SQLiteNode::_onMESSAGE(SQLitePeer* peer, const SData& message) {
uint64_t threadAttemptStartTimestamp = STimeNow();
thread(&SQLiteNode::_replicate, this, peer, message, _dbPool->getIndex(false), threadAttemptStartTimestamp).detach();
} catch (const system_error& e) {

// If the server is strugling and falling behind on replication, we might have too many threads
// causing a resource exhaustion. If that happens, all the transations that are already threaded
// and waiting for the transaction that failed will be stuck in an infinite loop. To prevent that
// we're cancelling all threads that would need to wait on the transaction that is failing.
uint64_t cancelAfter = message.calcU64("NewCount") - 1;
_localCommitNotifier.cancel(cancelAfter);
_leaderCommitNotifier.cancel(cancelAfter);
Expand Down

0 comments on commit 6daf253

Please sign in to comment.