Skip to content

Commit

Permalink
First adjustment. Compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerkaraszewski committed Jun 21, 2024
1 parent 92aaa14 commit 6d1d40b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 7 additions & 1 deletion sqlitecluster/SQLite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,13 @@ bool SQLite::getCommits(uint64_t fromIndex, uint64_t toIndex, SQResult& result)
(toIndex ? " AND id <= " + SQ(toIndex) : "")});
SDEBUG("Getting commits #" << fromIndex << "-" << toIndex);
query = "SELECT hash, query FROM (" + query + ") ORDER BY id";
return !SQuery(_db, "getting commits", query, result);

// Set timeout to 10 seconds.
_timeoutLimit = STimeNow() + 10'000'000;
int queryResult = SQuery(_db, "getting commits", query, result);
_timeoutLimit = 0;

return !queryResult;
}

int64_t SQLite::getLastInsertRowID() {
Expand Down
11 changes: 8 additions & 3 deletions sqlitecluster/SQLiteNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2132,12 +2132,17 @@ 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)
if (sendAll) {
SINFO("Sending all commits with synchronize message, from " << fromIndex << " to " << toIndex);
} else {
toIndex = min(toIndex, fromIndex + 100); // 100 transactions at a time
if (!db.getCommits(fromIndex, toIndex, result))
}
if (!db.getCommits(fromIndex, toIndex, result)) {
STHROW("error getting commits");
if ((uint64_t)result.size() != toIndex - fromIndex + 1)
}
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);
Expand Down

0 comments on commit 6d1d40b

Please sign in to comment.