[NO ISSUE][MD] Drop pending libraries during recovery
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- Drop pending libraries during metadata recovery
Change-Id: I41d0d9cb4a58d6a12e0c8356b80e376452767a8b
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/9343
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Dmitry Lychagin <dmitry.lychagin@couchbase.com>
Reviewed-by: Ian Maxon <imaxon@uci.edu>
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataBootstrap.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataBootstrap.java
index cf089fa..2aca994 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataBootstrap.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataBootstrap.java
@@ -60,6 +60,7 @@
import org.apache.asterix.metadata.entities.InternalDatasetDetails;
import org.apache.asterix.metadata.entities.InternalDatasetDetails.FileStructure;
import org.apache.asterix.metadata.entities.InternalDatasetDetails.PartitioningStrategy;
+import org.apache.asterix.metadata.entities.Library;
import org.apache.asterix.metadata.entities.Node;
import org.apache.asterix.metadata.entities.NodeGroup;
import org.apache.asterix.metadata.feeds.BuiltinFeedPolicies;
@@ -457,6 +458,12 @@
for (Dataset dataset : datasets) {
recoverDataset(mdTxnCtx, dataset);
}
+
+ List<Library> libraries =
+ MetadataManager.INSTANCE.getDataverseLibraries(mdTxnCtx, dataverse.getDataverseName());
+ for (Library library : libraries) {
+ recoverLibrary(mdTxnCtx, library);
+ }
}
}
@@ -501,6 +508,17 @@
}
}
+ private static void recoverLibrary(MetadataTransactionContext mdTxnCtx, Library library)
+ throws AlgebricksException {
+ if (library.getPendingOp() != MetadataUtil.PENDING_NO_OP) {
+ // drop pending library
+ MetadataManager.INSTANCE.dropLibrary(mdTxnCtx, library.getDataverseName(), library.getName());
+ if (LOGGER.isInfoEnabled()) {
+ LOGGER.info("Dropped a pending library: " + library.getDataverseName() + "." + library.getName());
+ }
+ }
+ }
+
public static boolean isNewUniverse() {
return isNewUniverse;
}