Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -476,7 +476,7 @@ private boolean assertTableRowCount(int expectedCount,
return count.get() == expectedCount;
}

private void syncDataFromOM() {
private void syncDataFromOM() throws IOException {
// Sync data from Ozone Manager to Recon.
OzoneManagerServiceProviderImpl impl = (OzoneManagerServiceProviderImpl)
cluster.getReconServer().getOzoneManagerServiceProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

import com.google.common.collect.Iterators;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.hadoop.hdds.recon.ReconConfigKeys;
import org.apache.hadoop.hdds.utils.db.RocksDatabase;
import org.apache.hadoop.hdds.utils.db.Table;
import org.apache.hadoop.hdds.utils.db.TableIterator;
import org.apache.hadoop.hdds.utils.db.managed.ManagedWriteBatch;
import org.apache.hadoop.hdds.utils.db.managed.ManagedWriteOptions;
import org.apache.hadoop.hdfs.web.URLConnectionFactory;
Expand Down Expand Up @@ -260,6 +263,22 @@ public void start() {
omMetadataManager.start(configuration);
} catch (IOException ioEx) {
LOG.error("Error starting Recon OM Metadata Manager.", ioEx);
} catch (RuntimeException runtimeException) {
LOG.warn("Unexpected runtime error starting Recon OM Metadata Manager.", runtimeException);
LOG.warn("Trying to delete existing recon OM snapshot DB and fetch new one.");
metrics.incrNumSnapshotRequests();
LOG.info("Fetching full snapshot from Ozone Manager");
// Update local Recon OM DB to new snapshot.
try {
boolean success = updateReconOmDBWithNewSnapshot();
if (success) {
LOG.info("Successfully fetched a full snapshot from Ozone Manager");
} else {
LOG.error("Failed fetching a full snapshot from Ozone Manager");
}
} catch (IOException e) {
throw new RuntimeException(e);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Why do we want to mask IOException and send a RuntimeException?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Why do we want to mask IOException and send a RuntimeException?

Here this is a special corner case we would like to handle, so we know that when Recon OM DB snapshot was getting corrupted for unknown failures (RuntimeException) and OMMetaManager service was failing to start with RuntimeException thrown, then we would like to handle by falling back to full snapshot and if full snapshot fetch also failed due to any exception including IOException, we know that we are still not able to bring the OMMetaManager service up, so want to throw RuntimeException as was thrown earlier in its parent catch block.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have logged IOException as error now. Pls re-review.

}
}
reconTaskController.start();
Comment thread
ArafatKhan2198 marked this conversation as resolved.
long initialDelay = configuration.getTimeDuration(
Expand Down Expand Up @@ -537,6 +556,7 @@ boolean innerGetAndApplyDeltaUpdatesFromOM(long fromSequenceNumber,
/**
* Based on current state of Recon's OM DB, we either get delta updates or
* full snapshot from Ozone Manager.
* @return true or false if sync operation between Recon and OM was successful or failed.
*/
@VisibleForTesting
public boolean syncDataFromOM() {
Expand Down Expand Up @@ -613,6 +633,7 @@ public boolean syncDataFromOM() {
reconContext.updateErrors(ReconContext.ErrorCode.GET_OM_DB_SNAPSHOT_FAILED);
}
}
printOMDBMetaInfo();
} finally {
isSyncDataFromOMRunning.set(false);
}
Expand All @@ -623,6 +644,27 @@ public boolean syncDataFromOM() {
return true;
}

private void printOMDBMetaInfo() {
printTableCount("fileTable");
printTableCount("keyTable");
}

private void printTableCount(String tableName) {
Table table = omMetadataManager.getTable(tableName);
if (table == null) {
LOG.error("Table {} not found in OM Metadata.", tableName);
return;
}
if (LOG.isDebugEnabled()) {
try (TableIterator<String, ? extends Table.KeyValue<String, ?>> iterator = table.iterator()) {
long count = Iterators.size(iterator);
LOG.debug("{} Table count: {}", tableName, count);
} catch (IOException ioException) {
LOG.error("Unexpected error while iterating table for table count: {}", tableName);
}
}
}

public void checkAndValidateReconDbPermissions() {
File dbDir = new File(reconDbDir.getPath());
if (!dbDir.exists()) {
Expand Down