[HUDI-4484] Add default lock config options for flink metadata table (#6222)
This commit is contained in:
@@ -85,6 +85,10 @@ public class TransactionManager implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public LockManager getLockManager() {
|
||||
return lockManager;
|
||||
}
|
||||
|
||||
public Option<HoodieInstant> getLastCompletedTransactionOwner() {
|
||||
return lastCompletedTxnOwnerInstant;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user