[bug](bdbje) Add retry for reSetupBdbEnvironment() restore.execute() (#18777)

* In reSetupBdbEnvironment() `restore.execute()` may throw NullPointerException,
  add retry for `restore.execute()`
This commit is contained in:
Lei Zhang
2023-04-21 20:58:42 +08:00
committed by GitHub
parent 317d9ee152
commit 0ae3a6df7e

View File

@ -375,10 +375,25 @@ public class BDBJEJournal implements Journal { // CHECKSTYLE IGNORE THIS LINE: B
// ATTN: here we use `getServingEnv()`, because only serving catalog has
// helper nodes.
HostInfo helperNode = Env.getServingEnv().getHelperNode();
NetworkRestore restore = new NetworkRestore();
NetworkRestoreConfig config = new NetworkRestoreConfig();
config.setRetainLogFiles(false);
restore.execute(insufficientLogEx, config);
for (int i = 0; i < RETRY_TIME; i++) {
try {
NetworkRestore restore = new NetworkRestore();
NetworkRestoreConfig config = new NetworkRestoreConfig();
config.setRetainLogFiles(false);
restore.execute(insufficientLogEx, config);
break;
} catch (Exception e) {
LOG.warn("retry={}, reSetupBdbEnvironment exception:", i, e);
try {
Thread.sleep(5 * 1000);
LOG.warn("after sleep insufficientLogEx:", insufficientLogEx);
} catch (InterruptedException e1) {
LOG.warn("InterruptedException", e1);
}
}
}
bdbEnvironment.close();
bdbEnvironment.setup(new File(environmentPath), selfNodeName, selfNodeHostPort,
helperNode.getIp() + ":" + helperNode.getPort(), Env.getServingEnv().isElectable());