use of org.voltdb.catalog.FilteredCatalogDiffEngine in project voltdb by VoltDB.
the class VoltCompiler method debugVerifyCatalog.
/**
* Internal method that takes the generated DDL from the catalog and builds a new catalog.
* The generated catalog is diffed with the original catalog to verify compilation and
* catalog generation consistency.
*/
private void debugVerifyCatalog(InMemoryJarfile origJarFile, Catalog origCatalog) {
final VoltCompiler autoGenCompiler = new VoltCompiler(m_isXDCR);
// Make the new compiler use the original jarfile's classloader so it can
// pull in the class files for procedures and imports
autoGenCompiler.m_classLoader = origJarFile.getLoader();
List<VoltCompilerReader> autogenReaderList = new ArrayList<>(1);
autogenReaderList.add(new VoltCompilerJarFileReader(origJarFile, AUTOGEN_DDL_FILE_NAME));
InMemoryJarfile autoGenJarOutput = new InMemoryJarfile();
autoGenCompiler.m_currentFilename = AUTOGEN_DDL_FILE_NAME;
// This call is purposely replicated in retryFailedCatalogRebuildUnderDebug,
// where it provides an opportunity to set a breakpoint on a do-over when this
// mainline call produces a flawed catalog that fails the catalog diff.
// Keep the two calls in synch to allow debugging under the same exact conditions.
Catalog autoGenCatalog = autoGenCompiler.compileCatalogInternal(null, null, autogenReaderList, autoGenJarOutput);
if (autoGenCatalog == null) {
Log.info("Did not verify catalog because it could not be compiled.");
return;
}
FilteredCatalogDiffEngine diffEng = new FilteredCatalogDiffEngine(origCatalog, autoGenCatalog, false);
String diffCmds = diffEng.commands();
if (diffCmds != null && !diffCmds.equals("")) {
// that is only triggered in hopeless cases.
if (RETRY_FAILED_CATALOG_REBUILD_UNDER_DEBUG) {
autoGenCatalog = replayFailedCatalogRebuildUnderDebug(autoGenCompiler, autogenReaderList, autoGenJarOutput);
}
// Re-run a failed diff more verbosely as a pre-crash test diagnostic.
diffEng = new FilteredCatalogDiffEngine(origCatalog, autoGenCatalog, true);
diffCmds = diffEng.commands();
String crashAdvice = "Catalog Verification from Generated DDL failed! " + "VoltDB dev: Consider" + (RETRY_FAILED_CATALOG_REBUILD_UNDER_DEBUG ? "" : " setting VoltCompiler.RETRY_FAILED_CATALOG_REBUILD_UNDER_DEBUG = true and") + " setting a breakpoint in VoltCompiler.replayFailedCatalogRebuildUnderDebug" + " to debug a replay of the faulty catalog rebuild roundtrip. ";
VoltDB.crashLocalVoltDB(crashAdvice + "The offending diffcmds were: " + diffCmds);
} else {
Log.info("Catalog verification completed successfuly.");
}
}
Aggregations