[HUDI-2809] Introduce a checksum mechanism for validating hoodie.properties (#4712)
Fix dependency conflict Fix repairs command Implement putIfAbsent for DDB lock provider Add upgrade step and validate while fetching configs Validate checksum for latest table version only while fetching config Move generateChecksum to BinaryUtil Rebase and resolve conflict Fix table version check
This commit is contained in:
@@ -1548,7 +1548,7 @@ public class TestHoodieBackedMetadata extends TestHoodieMetadataBase {
|
||||
assertTrue(currentStatus.getModificationTime() > prevStatus.getModificationTime());
|
||||
|
||||
initMetaClient();
|
||||
assertEquals(metaClient.getTableConfig().getTableVersion().versionCode(), HoodieTableVersion.THREE.versionCode());
|
||||
assertEquals(metaClient.getTableConfig().getTableVersion().versionCode(), HoodieTableVersion.FOUR.versionCode());
|
||||
assertTrue(fs.exists(new Path(metadataTableBasePath)), "Metadata table should exist");
|
||||
FileStatus newStatus = fs.getFileStatus(new Path(metadataTableBasePath));
|
||||
assertTrue(oldStatus.getModificationTime() < newStatus.getModificationTime());
|
||||
@@ -1630,7 +1630,7 @@ public class TestHoodieBackedMetadata extends TestHoodieMetadataBase {
|
||||
}
|
||||
|
||||
initMetaClient();
|
||||
assertEquals(metaClient.getTableConfig().getTableVersion().versionCode(), HoodieTableVersion.THREE.versionCode());
|
||||
assertEquals(metaClient.getTableConfig().getTableVersion().versionCode(), HoodieTableVersion.FOUR.versionCode());
|
||||
assertTrue(fs.exists(new Path(metadataTableBasePath)), "Metadata table should exist");
|
||||
FileStatus newStatus = fs.getFileStatus(new Path(metadataTableBasePath));
|
||||
assertTrue(oldStatus.getModificationTime() < newStatus.getModificationTime());
|
||||
|
||||
@@ -232,6 +232,43 @@ public class TestUpgradeDowngrade extends HoodieClientTestBase {
|
||||
assertTableProps(cfg);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpgradeDowngradeBetweenThreeAndCurrentVersion() throws IOException {
|
||||
// init config, table and client.
|
||||
Map<String, String> params = new HashMap<>();
|
||||
addNewTableParamsToProps(params);
|
||||
HoodieWriteConfig cfg = getConfigBuilder().withAutoCommit(false).withRollbackUsingMarkers(false).withProps(params).build();
|
||||
|
||||
// write inserts
|
||||
SparkRDDWriteClient client = getHoodieWriteClient(cfg);
|
||||
doInsert(client);
|
||||
|
||||
// current version should have TABLE_CHECKSUM key
|
||||
assertEquals(HoodieTableVersion.current(), metaClient.getTableConfig().getTableVersion());
|
||||
assertTableVersionFromPropertyFile(HoodieTableVersion.current());
|
||||
assertTrue(metaClient.getTableConfig().getProps().containsKey(HoodieTableConfig.TABLE_CHECKSUM.key()));
|
||||
String checksum = metaClient.getTableConfig().getProps().getString(HoodieTableConfig.TABLE_CHECKSUM.key());
|
||||
|
||||
// downgrade to version 3 and check TABLE_CHECKSUM is still present
|
||||
new UpgradeDowngrade(metaClient, cfg, context, SparkUpgradeDowngradeHelper.getInstance()).run(HoodieTableVersion.THREE, null);
|
||||
assertEquals(HoodieTableVersion.THREE.versionCode(), metaClient.getTableConfig().getTableVersion().versionCode());
|
||||
assertTableVersionFromPropertyFile(HoodieTableVersion.THREE);
|
||||
assertTrue(metaClient.getTableConfig().getProps().containsKey(HoodieTableConfig.TABLE_CHECKSUM.key()));
|
||||
assertEquals(checksum, metaClient.getTableConfig().getProps().getString(HoodieTableConfig.TABLE_CHECKSUM.key()));
|
||||
|
||||
// remove TABLE_CHECKSUM and upgrade to current version
|
||||
metaClient.getTableConfig().getProps().remove(HoodieTableConfig.TABLE_CHECKSUM.key());
|
||||
new UpgradeDowngrade(metaClient, cfg, context, SparkUpgradeDowngradeHelper.getInstance()).run(HoodieTableVersion.current(), null);
|
||||
|
||||
// verify upgrade and TABLE_CHECKSUM
|
||||
metaClient = HoodieTableMetaClient.builder().setConf(context.getHadoopConf().get()).setBasePath(cfg.getBasePath())
|
||||
.setLayoutVersion(Option.of(new TimelineLayoutVersion(cfg.getTimelineLayoutVersion()))).build();
|
||||
assertEquals(HoodieTableVersion.current().versionCode(), metaClient.getTableConfig().getTableVersion().versionCode());
|
||||
assertTableVersionFromPropertyFile(HoodieTableVersion.current());
|
||||
assertTrue(metaClient.getTableConfig().getProps().containsKey(HoodieTableConfig.TABLE_CHECKSUM.key()));
|
||||
assertEquals(checksum, metaClient.getTableConfig().getProps().getString(HoodieTableConfig.TABLE_CHECKSUM.key()));
|
||||
}
|
||||
|
||||
private void addNewTableParamsToProps(Map<String, String> params) {
|
||||
params.put(KeyGeneratorOptions.RECORDKEY_FIELD_NAME.key(), "uuid");
|
||||
params.put(KeyGeneratorOptions.PARTITIONPATH_FIELD_NAME.key(), "partition_path");
|
||||
|
||||
Reference in New Issue
Block a user