[fix](journal) Fix infinite block due to initial BDB journal failed (#29205)
Opening a BDBJournal will acquire the max journal id, but it doesn't need to check whether the replica txn is matched with the master.
This commit is contained in:
@ -271,6 +271,15 @@ public class BDBJEJournal implements Journal { // CHECKSTYLE IGNORE THIS LINE: B
|
||||
|
||||
@Override
|
||||
public long getMaxJournalId() {
|
||||
return getMaxJournalIdInternal(true);
|
||||
}
|
||||
|
||||
// get max journal id but do not check whether the txn is matched.
|
||||
private long getMaxJournalIdWithoutCheck() {
|
||||
return getMaxJournalIdInternal(false);
|
||||
}
|
||||
|
||||
private long getMaxJournalIdInternal(boolean checkTxnMatched) {
|
||||
long ret = -1;
|
||||
if (bdbEnvironment == null) {
|
||||
return ret;
|
||||
@ -287,7 +296,7 @@ public class BDBJEJournal implements Journal { // CHECKSTYLE IGNORE THIS LINE: B
|
||||
String dbName = dbNames.get(index).toString();
|
||||
long dbNumberName = dbNames.get(index);
|
||||
Database database = bdbEnvironment.openDatabase(dbName);
|
||||
if (!isReplicaTxnAreMatched(database, dbNumberName)) {
|
||||
if (checkTxnMatched && !isReplicaTxnAreMatched(database, dbNumberName)) {
|
||||
LOG.warn("The current replica hasn't synced up with the master, current db name: {}", dbNumberName);
|
||||
if (index != 0) {
|
||||
// Because roll journal occurs after write, the previous write must have
|
||||
@ -419,7 +428,7 @@ public class BDBJEJournal implements Journal { // CHECKSTYLE IGNORE THIS LINE: B
|
||||
}
|
||||
|
||||
// set next journal id
|
||||
nextJournalId.set(getMaxJournalId() + 1);
|
||||
nextJournalId.set(getMaxJournalIdWithoutCheck() + 1);
|
||||
|
||||
break;
|
||||
} catch (InsufficientLogException insufficientLogEx) {
|
||||
|
||||
Reference in New Issue
Block a user