Skip to content

Commit

Permalink
Remove non-functional error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerkaraszewski committed Jan 14, 2025
1 parent 05aa8c9 commit d7be8ac
Showing 1 changed file with 13 additions and 32 deletions.
45 changes: 13 additions & 32 deletions sqlitecluster/SQLiteNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,38 +187,19 @@ void SQLiteNode::_replicate() {
_replicateQueue.pop();
uint64_t dequeueTime = STimeNow();

bool shouldGoSearchingAndExit = false;
try {
if (SIEquals(command.methodLine, "BEGIN_TRANSACTION")) {
auto start = chrono::steady_clock::now();
_handleBeginTransaction(db, peer, command);
_handlePrepareTransaction(db, peer, command, dequeueTime);
auto duration = chrono::steady_clock::now() - start;
SINFO("[performance] Wrote replicate transaction in " << chrono::duration_cast<chrono::microseconds>(duration).count() << "us.");
} else if (SIEquals(command.methodLine, "COMMIT_TRANSACTION")) {
int result = _handleCommitTransaction(db, peer, command.calcU64("NewCount"), command["NewHash"]);
if (result != SQLITE_OK) {
STHROW("commit failed");
}
} else if (SIEquals(command.methodLine, "ROLLBACK_TRANSACTION")) {
_handleRollbackTransaction(db, peer, command);
shouldGoSearchingAndExit = true;
}
} catch (const SException& e) {
SALERT("Caught SException in replication thread. Assuming this means we want to stop following. Exception: " << e.what());
shouldGoSearchingAndExit = true;
db.rollback();
}
if (shouldGoSearchingAndExit) {
SALERT("Attempted to handle " << command.serialize() << " but got error. Will give up and go SEARCHING");
// We can lock here for this state change because we're in our own thread, and this won't be recursive with
// the calling thread. This is also a really weird exception case that should never happen, so the performance
// implications aren't significant so long as we don't break.
unique_lock<decltype(_stateMutex)> uniqueLock(_stateMutex);
_changeState(SQLiteNodeState::SEARCHING);

// Currently, _changeState above causes this thread to wait for itself to join.
return;
if (SIEquals(command.methodLine, "BEGIN_TRANSACTION")) {
auto start = chrono::steady_clock::now();
_handleBeginTransaction(db, peer, command);
_handlePrepareTransaction(db, peer, command, dequeueTime);
auto duration = chrono::steady_clock::now() - start;
SINFO("[performance] Wrote replicate transaction in " << chrono::duration_cast<chrono::microseconds>(duration).count() << "us.");
} else if (SIEquals(command.methodLine, "COMMIT_TRANSACTION")) {
int result = _handleCommitTransaction(db, peer, command.calcU64("NewCount"), command["NewHash"]);
if (result != SQLITE_OK) {
STHROW("commit failed");
}
} else if (SIEquals(command.methodLine, "ROLLBACK_TRANSACTION")) {
_handleRollbackTransaction(db, peer, command);
}
}
}
Expand Down

0 comments on commit d7be8ac

Please sign in to comment.