Skip to content

Commit

Permalink
HDDS-8272. DBStore not closed properly in ReconStorageContainerManage…
Browse files Browse the repository at this point in the history
…rFacade (#4469)
  • Loading branch information
adoroszlai committed Mar 27, 2023
1 parent 1508370 commit 1ed9a73
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@
import org.apache.hadoop.hdds.server.events.FixedThreadPoolWithAffinityExecutor;
import org.apache.hadoop.hdds.upgrade.HDDSLayoutVersionManager;
import org.apache.hadoop.hdds.utils.HddsServerUtil;
import org.apache.hadoop.hdds.utils.IOUtils;
import org.apache.hadoop.hdds.utils.db.DBCheckpoint;
import org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition;
import org.apache.hadoop.hdds.utils.db.DBStore;
import org.apache.hadoop.hdds.utils.db.DBStoreBuilder;
import org.apache.hadoop.hdds.utils.db.Table;
import org.apache.hadoop.hdds.utils.db.Table.KeyValue;
import org.apache.hadoop.hdds.utils.db.TableIterator;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.ozone.recon.ReconServerConfigKeys;
import org.apache.hadoop.ozone.recon.ReconUtils;
import org.apache.hadoop.ozone.recon.fsck.ContainerHealthTask;
Expand Down Expand Up @@ -426,11 +426,7 @@ public void stop() {
IOUtils.cleanupWithLogger(LOG, pipelineManager);
LOG.info("Flushing container replica history to DB.");
containerManager.flushReplicaHistoryMapToDB(true);
try {
dbStore.close();
} catch (Exception e) {
LOG.error("Can't close dbStore ", e);
}
IOUtils.close(LOG, dbStore);
}

@Override
Expand Down Expand Up @@ -604,8 +600,9 @@ private void initializeNewRdbStore(File dbFile) throws IOException {
ReconSCMDBDefinition.CONTAINERS.getTable(newStore));
nodeManager.reinitialize(
ReconSCMDBDefinition.NODES.getTable(newStore));
IOUtils.close(LOG, dbStore);
deleteOldSCMDB();
setDbStore(newStore);
dbStore = newStore;
File newDb = new File(dbFile.getParent() +
OZONE_URI_DELIMITER + ReconSCMDBDefinition.RECON_SCM_DB_NAME);
boolean success = dbFile.renameTo(newDb);
Expand Down Expand Up @@ -636,10 +633,6 @@ private DBStore createDBAndAddSCMTablesAndCodecs(File dbFile,
return dbStoreBuilder.build();
}

public void setDbStore(DBStore dbStore) {
this.dbStore = dbStore;
}

@Override
public NodeManager getScmNodeManager() {
return nodeManager;
Expand Down

0 comments on commit 1ed9a73

Please sign in to comment.