Skip to content

Commit ea9d174

Browse files
committed
[fix](iceberg) Prepare row-level isolation before backend writes
### What problem does this PR solve? Issue Number: N/A Related PR: #69702 Problem Summary: Standard-only isolation selection made existing tables configured with delete_isolation_level=snapshot fall back to serializable and reject previously permitted concurrent appends. Parsing an invalid selected value only during commit also failed after backend files had been reported, when normal rollback could no longer reclaim them. Resolve the operation's standard property, legacy compatibility property, then SDK default. Parse and cache the SDK isolation enum from the opened transaction's metadata before publishing the prepared transaction or returning a backend sink. Commit uses that cached selection while retaining the other row-delta validations. ### Release note Iceberg row-level writes retain valid legacy isolation settings and reject invalid selected isolation values before backend file creation. ### Check List (For Author) - Test: Unit Test - run-fe-ut.sh --run: six targeted connector/planner classes, 237 tests discovered, 236 passed, one pre-existing unrelated disabled test - Independent Checkstyle for fe-connector-iceberg and fe-core: zero violations - Scoped git diff --check and added-lines checks passed - Behavior changed: Yes, preserve legacy-only isolation compatibility and validate the selected isolation before backend writes, fixed for the statement lifetime - Does this need documentation: No
1 parent a4dc943 commit ea9d174

3 files changed

Lines changed: 244 additions & 33 deletions

File tree

‎fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorTransaction.java‎

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
public class IcebergConnectorTransaction implements ConnectorTransaction, RewriteCapableTransaction {
131131

132132
private static final Logger LOG = LogManager.getLogger(IcebergConnectorTransaction.class);
133+
private static final String LEGACY_DELETE_ISOLATION_LEVEL = "delete_isolation_level";
133134
// Scope of a bare INSERT OVERWRITE (no PARTITION clause). Key + values are byte-identical to the fe-core
134135
// SessionVariable constants (the connector cannot import fe-core); the value reaches the commit through
135136
// ConnectorSession.getProperty, which reads the session-variable registry by name.
@@ -165,6 +166,7 @@ public class IcebergConnectorTransaction implements ConnectorTransaction, Rewrit
165166
// Op context captured at begin time, consumed by commit() (the volatile transaction write at the end of
166167
// beginWrite publishes these plain writes to the commit thread).
167168
private WriteOperation writeOperation = WriteOperation.INSERT;
169+
private IsolationLevel rowLevelIsolationLevel;
168170
private boolean staticPartitionOverwrite;
169171
// True when iceberg_partition_overwrite_mode = 'static': a bare INSERT OVERWRITE clears the whole table
170172
// (every partition spec) instead of replacing only the partitions the new data lands in. Captured at begin
@@ -287,15 +289,23 @@ public void beginWrite(ConnectorSession session, String db, String tableName, Ic
287289
if (writeSchemaContext != null) {
288290
writeSchemaContext.validateCurrentSchema(loaded, ctx.isOverwrite());
289291
}
292+
// Reject invalid isolation before a sink can dispatch BE file writes. Read the SDK
293+
// transaction's refreshed metadata and keep that selection for this statement's commit.
294+
IsolationLevel isolationLevel = null;
295+
if (writeOperation == WriteOperation.DELETE || writeOperation == WriteOperation.UPDATE
296+
|| writeOperation == WriteOperation.MERGE) {
297+
isolationLevel = resolveIsolationLevel(opened.table(), writeOperation);
298+
}
290299
synchronized (beginLock) {
291300
if (closed) {
292301
this.table = null;
293302
throw new IllegalStateException(
294303
"Iceberg transaction closed while its write table was loading");
295304
}
296-
this.transaction = opened;
305+
this.rowLevelIsolationLevel = isolationLevel;
297306
this.tableLease = retained;
298307
retained = null;
308+
this.transaction = opened;
299309
writeStarted = true;
300310
}
301311
return null;
@@ -1194,7 +1204,7 @@ private void applyRowDeltaValidations(RowDelta rowDelta, Table icebergTable,
11941204
List<TIcebergCommitData> commitData, List<String> referencedDataFiles) {
11951205
applyBaseSnapshotValidation(rowDelta);
11961206
applyConflictDetectionFilter(rowDelta, icebergTable, commitData);
1197-
if (isSerializableIsolationLevel(icebergTable, writeOperation)) {
1207+
if (rowLevelIsolationLevel == IsolationLevel.SERIALIZABLE) {
11981208
rowDelta.validateNoConflictingDataFiles();
11991209
}
12001210
rowDelta.validateDeletedFiles();
@@ -1349,32 +1359,32 @@ private List<String> extractPartitionValues(TIcebergCommitData commitData) {
13491359
return Collections.emptyList();
13501360
}
13511361

1352-
boolean isSerializableIsolationLevel(Table icebergTable, WriteOperation operation) {
1353-
if (icebergTable == null) {
1354-
return true;
1355-
}
1356-
String level;
1362+
IsolationLevel resolveIsolationLevel(Table icebergTable, WriteOperation operation) {
1363+
String property;
1364+
String defaultLevel;
13571365
switch (operation) {
13581366
case DELETE:
1359-
level = icebergTable.properties().getOrDefault(
1360-
TableProperties.DELETE_ISOLATION_LEVEL,
1361-
TableProperties.DELETE_ISOLATION_LEVEL_DEFAULT);
1367+
property = TableProperties.DELETE_ISOLATION_LEVEL;
1368+
defaultLevel = TableProperties.DELETE_ISOLATION_LEVEL_DEFAULT;
13621369
break;
13631370
case UPDATE:
1364-
level = icebergTable.properties().getOrDefault(
1365-
TableProperties.UPDATE_ISOLATION_LEVEL,
1366-
TableProperties.UPDATE_ISOLATION_LEVEL_DEFAULT);
1371+
property = TableProperties.UPDATE_ISOLATION_LEVEL;
1372+
defaultLevel = TableProperties.UPDATE_ISOLATION_LEVEL_DEFAULT;
13671373
break;
13681374
case MERGE:
1369-
level = icebergTable.properties().getOrDefault(
1370-
TableProperties.MERGE_ISOLATION_LEVEL,
1371-
TableProperties.MERGE_ISOLATION_LEVEL_DEFAULT);
1375+
property = TableProperties.MERGE_ISOLATION_LEVEL;
1376+
defaultLevel = TableProperties.MERGE_ISOLATION_LEVEL_DEFAULT;
13721377
break;
13731378
default:
13741379
throw new IllegalArgumentException(
13751380
"Unsupported iceberg row-level write operation: " + operation);
13761381
}
1377-
return IsolationLevel.fromName(level) == IsolationLevel.SERIALIZABLE;
1382+
// Standard per-operation settings take precedence; existing legacy-only tables retain their
1383+
// configured isolation until they migrate. Parse only the selected value, including invalid ones.
1384+
Map<String, String> properties = icebergTable.properties();
1385+
String level = properties.getOrDefault(property,
1386+
properties.getOrDefault(LEGACY_DELETE_ISOLATION_LEVEL, defaultLevel));
1387+
return IsolationLevel.fromName(level);
13781388
}
13791389

13801390
// ─────────────────── V3 deletion-vector "rewrite previous delete files" (legacy :786-851) ───────────────────

0 commit comments

Comments
 (0)