Skip to content
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

[fix](bdb) Write OP_TIMESTAMP operation until it successed #34061

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,21 @@ public synchronized long write(short op, Writable writable) throws IOException {
MetricRepo.COUNTER_EDIT_LOG_SIZE_BYTES.increase((long) theData.getSize());
MetricRepo.COUNTER_CURRENT_EDIT_LOG_SIZE_BYTES.increase((long) theData.getSize());
}
LOG.debug("opCode = {}, journal size = {}", op, theData.getSize());
if (LOG.isDebugEnabled()) {
LOG.debug("opCode = {}, journal size = {}", op, theData.getSize());
}

// Write the key value pair to bdb.
boolean writeSucceed = false;
for (int i = 0; i < RETRY_TIME; i++) {
// ATTN: If all the followers exit except master, master should continue provide
// query service, so do not exit if the write operation is OP_TIMESTAMP.
//
// Because BDBJE will replicate the committed txns to FOLLOWERs after the connection
// resumed, directly reseting the next journal id and returning will cause subsequent
// txn written to the same journal ID not to be replayed by the FOLLOWERS. So for
// OP_TIMESTAMP operation, try to write until it succeeds here.
int retryTimes = op == OperationType.OP_TIMESTAMP ? Integer.MAX_VALUE : RETRY_TIME;
for (int i = 0; i < retryTimes; i++) {
try {
// Parameter null means auto commit
if (currentJournalDB.put(null, theKey, theData) == OperationStatus.SUCCESS) {
Expand Down Expand Up @@ -190,17 +201,6 @@ public synchronized long write(short op, Writable writable) throws IOException {
}

if (!writeSucceed) {
if (op == OperationType.OP_TIMESTAMP) {
/*
* Do not exit if the write operation is OP_TIMESTAMP.
* If all the followers exit except master, master should continue provide query
* service.
* To prevent master exit, we should exempt OP_TIMESTAMP write
*/
nextJournalId.set(id);
LOG.warn("master can not achieve quorum. write timestamp fail. but will not exit.");
return -1;
}
String msg = "write bdb failed. will exit. journalId: " + id + ", bdb database Name: "
+ currentJournalDB.getDatabaseName();
LOG.error(msg);
Expand Down
Loading