1
0

[HUDI-4484] Add default lock config options for flink metadata table (#6222)

This commit is contained in:
Danny Chan
2022-07-28 20:57:13 +08:00
committed by GitHub
parent 0a5ce000bf
commit 07eedd3ef6
8 changed files with 60 additions and 30 deletions

View File

@@ -85,6 +85,10 @@ public class TransactionManager implements Serializable {
}
}
public LockManager getLockManager() {
return lockManager;
}
public Option<HoodieInstant> getLastCompletedTransactionOwner() {
return lastCompletedTxnOwnerInstant;
}

View File

@@ -311,6 +311,16 @@ public class HoodieLockConfig extends HoodieConfig {
return this;
}
public HoodieLockConfig.Builder withFileSystemLockPath(String path) {
lockConfig.setValue(FILESYSTEM_LOCK_PATH, path);
return this;
}
public HoodieLockConfig.Builder withFileSystemLockExpire(Integer expireTime) {
lockConfig.setValue(FILESYSTEM_LOCK_EXPIRE, String.valueOf(expireTime));
return this;
}
public HoodieLockConfig build() {
lockConfig.setDefaults(HoodieLockConfig.class.getName());
return lockConfig;

View File

@@ -267,14 +267,21 @@ public class HoodieFlinkWriteClient<T extends HoodieRecordPayload> extends
if (this.metadataWriter == null) {
initMetadataWriter();
}
// refresh the timeline
try {
// guard the metadata writer with concurrent lock
this.txnManager.getLockManager().lock();
// Note: the data meta client is not refreshed currently, some code path
// relies on the meta client for resolving the latest data schema,
// the schema expects to be immutable for SQL jobs but may be not for non-SQL
// jobs.
this.metadataWriter.initTableMetadata();
this.metadataWriter.update(metadata, instantTime, getHoodieTable().isTableServiceAction(actionType));
// refresh the timeline
// Note: the data meta client is not refreshed currently, some code path
// relies on the meta client for resolving the latest data schema,
// the schema expects to be immutable for SQL jobs but may be not for non-SQL
// jobs.
this.metadataWriter.initTableMetadata();
this.metadataWriter.update(metadata, instantTime, getHoodieTable().isTableServiceAction(actionType));
} finally {
this.txnManager.getLockManager().unlock();
}
}
/**