Skip to content

Commit

Permalink
0003671: If a table doesn't exist, but it has a sym_trigger_hist row and
Browse files Browse the repository at this point in the history
a sym_table_reload_request, it gets a nullpointerexception
  • Loading branch information
chenson42 committed Aug 12, 2018
1 parent 35406c8 commit cb8234d
Showing 1 changed file with 30 additions and 25 deletions.
Expand Up @@ -921,34 +921,39 @@ private void insertLoadBatchesForReload(Node targetNode, long loadId, String cre
triggerHistory.getSourceCatalogName(), triggerHistory.getSourceSchemaName(),
triggerHistory.getSourceTableName(), false);

processInfo.setCurrentTableName(table.getName());

long rowCount = getDataCountForReload(table, targetNode, selectSql);
long transformMultiplier = getTransformMultiplier(table, triggerRouter);

// calculate the number of batches needed for table.
long numberOfBatches = 1;
long lastBatchSize = channel.getMaxBatchSize();

if (rowCount > 0) {
numberOfBatches = (rowCount * transformMultiplier / channel.getMaxBatchSize()) + 1;
lastBatchSize = rowCount % numberOfBatches;
}
if (table != null) {
processInfo.setCurrentTableName(table.getName());

long rowCount = getDataCountForReload(table, targetNode, selectSql);
long transformMultiplier = getTransformMultiplier(table, triggerRouter);

// calculate the number of batches needed for table.
long numberOfBatches = 1;
long lastBatchSize = channel.getMaxBatchSize();

long startBatchId = -1;
long endBatchId = -1;
for (int i = 0; i < numberOfBatches; i++) {
long batchSize = i == numberOfBatches-1 ? lastBatchSize : channel.getMaxBatchSize();
// needs to grab the start and end batch id
endBatchId = insertReloadEvent(transaction, targetNode, triggerRouter,
triggerHistory, selectSql, true, loadId, createBy, Status.RQ, null, batchSize);
if (startBatchId == -1) {
startBatchId = endBatchId;
if (rowCount > 0) {
numberOfBatches = (rowCount * transformMultiplier / channel.getMaxBatchSize()) + 1;
lastBatchSize = rowCount % numberOfBatches;
}

long startBatchId = -1;
long endBatchId = -1;
for (int i = 0; i < numberOfBatches; i++) {
long batchSize = i == numberOfBatches - 1 ? lastBatchSize : channel.getMaxBatchSize();
// needs to grab the start and end batch id
endBatchId = insertReloadEvent(transaction, targetNode, triggerRouter, triggerHistory, selectSql, true,
loadId, createBy, Status.RQ, null, batchSize);
if (startBatchId == -1) {
startBatchId = endBatchId;
}
}

engine.getDataExtractorService().requestExtractRequest(transaction, targetNode.getNodeId(), channel.getQueue(),
triggerRouter, startBatchId, endBatchId);
} else {
log.warn("The table defined by trigger_hist row %d no longer exists. A load will not be queue'd up for the table", triggerHistory.getTriggerHistoryId());

}

engine.getDataExtractorService().requestExtractRequest(transaction,
targetNode.getNodeId(), channel.getQueue(), triggerRouter, startBatchId, endBatchId);
} else {
insertReloadEvent(transaction, targetNode, triggerRouter, triggerHistory,
selectSql, true, loadId, createBy, Status.NE, null, -1);
Expand Down

0 comments on commit cb8234d

Please sign in to comment.