Skip to content

Commit

Permalink
Metadata table bulk file columns deleted on upgrade
Browse files Browse the repository at this point in the history
Deletes the bulk file columns from the metadata table on upgrade to 4.x, if they exist.
closes apache#4637, related to apache#4587
  • Loading branch information
kevinrr888 committed Jul 3, 2024
1 parent e6833ad commit 35d4c0b
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public void upgradeMetadata(ServerContext context) {
removeMetaDataBulkLoadFilter(context, AccumuloTable.METADATA.tableId());
LOG.info("Removing compact columns from user tables");
removeCompactColumnsFromTable(context, AccumuloTable.METADATA.tableName());
LOG.info("Removing bulk file columns from metadata table");
removeBulkFileColumnsFromTable(context, AccumuloTable.METADATA.tableName());
}

private void createFateTable(ServerContext context) {
Expand Down Expand Up @@ -184,6 +186,31 @@ private void removeCompactColumnsFromTable(ServerContext context, String tableNa
}
}

private void removeBulkFileColumnsFromTable(ServerContext context, String tableName) {
// FATE transaction ids have changed from 3.x to 4.x which are used as the value for the bulk
// file column. FATE ops won't persist through upgrade, so these columns can be safely deleted
// if they exist.
try (var scanner = context.createScanner(tableName);
var writer = context.createBatchWriter(tableName)) {
scanner.setRange(MetadataSchema.TabletsSection.getRange());
scanner.fetchColumnFamily(TabletsSection.BulkFileColumnFamily.NAME);
for (Map.Entry<Key,Value> entry : scanner) {
var key = entry.getKey();
Mutation m = new Mutation(key.getRow());
Preconditions.checkState(
key.getColumnFamily().equals(TabletsSection.BulkFileColumnFamily.NAME),
"Expected family %s, saw %s ", TabletsSection.BulkFileColumnFamily.NAME,
key.getColumnFamily());
Preconditions.checkState(key.getColumnVisibilityData().length() == 0,
"Expected empty visibility, saw %s ", key.getColumnVisibilityData());
m.putDelete(key.getColumnFamily(), key.getColumnQualifier());
writer.addMutation(m);
}
} catch (Exception e) {
throw new IllegalStateException(e);
}
}

private void removeUnusedZKNodes(ServerContext context) {
try {
final String zkRoot = ZooUtil.getRoot(context.getInstanceID());
Expand Down Expand Up @@ -283,7 +310,7 @@ private void deleteExternalCompactions(ServerContext context) {
Mutation m = new Mutation(key.getRow());
Preconditions.checkState(key.getColumnFamily().equals(ExternalCompactionColumnFamily.NAME),
"Expected family %s, saw %s ", ExternalCompactionColumnFamily.NAME,
key.getColumnVisibilityData());
key.getColumnFamily());
Preconditions.checkState(key.getColumnVisibilityData().length() == 0,
"Expected empty visibility, saw %s ", key.getColumnVisibilityData());
m.putDelete(key.getColumnFamily(), key.getColumnQualifier());
Expand Down

0 comments on commit 35d4c0b

Please sign in to comment.