FrankChen021 commented on code in PR #19830:
URL: https://github.com/apache/druid/pull/19830#discussion_r3853033063
##########
extensions-core/druid-catalog/src/main/java/org/apache/druid/catalog/sync/CatalogClient.java:
##########
@@ -105,23 +107,58 @@ public ResolvedTable resolveTable(TableId id)
/**
* Creates a table for the given {@link TableId} and {@link TableSpec}.
* If a table already exists for this id, it is overwritten.
- * <p>
- * This method is currently used only in tests.
*/
public void createTable(TableId tableId, TableSpec tableSpec)
{
- getResult(postCreateTable(tableId, tableSpec));
+ getResult(postCreateTable(tableId, tableSpec, false, true));
+ }
+
+ /**
+ * Creates a table for the given {@link TableId} and {@link TableSpec}.
+ *
+ * @param ifNotExists leave an existing table alone rather than failing
+ * @param overwrite replace the spec of an existing table
+ */
+ public void createTable(TableId tableId, TableSpec tableSpec, boolean
ifNotExists, boolean overwrite)
+ {
+ FutureUtils.getUnchecked(postCreateTable(tableId, tableSpec, ifNotExists,
overwrite), true);
+ }
+
+ /**
+ * Applies an edit to an existing table's catalog entry.
+ * <p>
+ * API: {@code POST
/druid/coordinator/v1/catalog/schemas/{schema}/tables/{name}/edit}
+ */
+ public void editTable(TableId tableId, TableEditRequest editRequest)
+ {
+ String path = tablePath(TABLE_EDIT_PATH, tableId);
+ FutureUtils.getUnchecked(
+ serviceClient.asyncRequest(
Review Comment:
I agree that compare-and-set prevents a retry from overwriting a concurrent
update, and that the retry policy predates this PR for createTable. The
remaining issue is the new editTable POST: ADD COLUMN, ADD PROJECTION without
IF NOT EXISTS, and base-table edits without existence flags all use the same
retrying CatalogClient. If the Coordinator commits the first request but its
response is lost, the retry reads the new version and runs the guard again,
returning an error such as already exists even though the DDL committed. CAS
prevents stale concurrent writes; it does not deduplicate post-commit replays.
Please track this explicitly as a write-retry/idempotency follow-up, or disable
retries for mutating calls. Reviewed 11 of 45 changed files.
<!-- mergelens:review -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]