-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Time out SUBSCRIBE query instead of forking. #1783
Changes from 6 commits
6d1d40b
ff798a0
4236694
8663412
e146093
ed58715
e3a1370
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -2132,12 +2132,29 @@ void SQLiteNode::_queueSynchronize(const SQLiteNode* const node, SQLitePeer* pee | |||
// Figure out how much to send it | ||||
uint64_t fromIndex = peerCommitCount + 1; | ||||
uint64_t toIndex = targetCommit; | ||||
if (!sendAll) | ||||
uint64_t timeoutLimitUS = 0; | ||||
if (sendAll) { | ||||
SINFO("Sending all commits with synchronize message, from " << fromIndex << " to " << toIndex); | ||||
|
||||
// We set this for all commits because this only gets all commits in response to SUBSCRIBE, which is done synchronously, and blocks the commit thread. | ||||
// For asynchronous queries, there's nothing being blocked, so it doesn't much matter how long these take. | ||||
// This is really not the correct encapsulation for this, but we can improve that later. | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pet peeve, but this is a TODO in a comment. Can we make a GH issue for it instead?
Suggested change
|
||||
timeoutLimitUS = 10'000'000; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the cluster gives up on the leader node after 30s, should we make this higher and closer to 30s, say 25? If there's a reason for 10 and it's not an arbitrary number, let's add a comment |
||||
} else { | ||||
toIndex = min(toIndex, fromIndex + 100); // 100 transactions at a time | ||||
if (!db.getCommits(fromIndex, toIndex, result)) | ||||
STHROW("error getting commits"); | ||||
if ((uint64_t)result.size() != toIndex - fromIndex + 1) | ||||
} | ||||
int resultCode = db.getCommits(fromIndex, toIndex, result, timeoutLimitUS); | ||||
if (resultCode) { | ||||
if (resultCode == SQLITE_INTERRUPT) { | ||||
STHROW("synchronization query timeout"); | ||||
} else { | ||||
STHROW("error getting commits"); | ||||
} | ||||
} | ||||
|
||||
if ((uint64_t)result.size() != toIndex - fromIndex + 1) { | ||||
STHROW("mismatched commit count"); | ||||
} | ||||
|
||||
// Wrap everything into one huge message | ||||
PINFO("Synchronizing commits from " << peerCommitCount + 1 << "-" << targetCommit); | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be calling
clearTimeout
here?