This is an automated email from the ASF dual-hosted git repository.

xiangfu0 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 90712e2f487 Reject partial upsert and out-of-order record handling on 
new pauseless tables (#20301)
90712e2f487 is described below

commit 90712e2f4872cfec9180b8142651aadbbb2de8ca
Author: Chaitanya Deepthi <[email protected]>
AuthorDate: Thu Nov 19 08:45:01 2026 -0800

    Reject partial upsert and out-of-order record handling on new pauseless 
tables (#20301)
---
 .../segment/local/utils/TableConfigUtils.java      | 49 +++++++++++++-
 .../segment/local/utils/TableConfigUtilsTest.java  | 75 ++++++++++++++++++++++
 2 files changed, 122 insertions(+), 2 deletions(-)

diff --git 
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
 
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
index f3b9fc3a809..9948eceacb3 100644
--- 
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
+++ 
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
@@ -48,6 +48,7 @@ import 
org.apache.pinot.common.request.context.ExpressionContext;
 import org.apache.pinot.common.request.context.FunctionContext;
 import org.apache.pinot.common.request.context.RequestContextUtils;
 import org.apache.pinot.common.tier.TierFactory;
+import org.apache.pinot.common.utils.PauselessConsumptionUtils;
 import org.apache.pinot.common.utils.config.TagNameUtils;
 import org.apache.pinot.segment.local.aggregator.ValueAggregator;
 import org.apache.pinot.segment.local.aggregator.ValueAggregatorFactory;
@@ -1102,7 +1103,8 @@ public final class TableConfigUtils {
   /// [#validateUpsertAndDedupCommonConfig]), the OFFLINE restrictions (no 
partial upsert, segment partition config,
   /// comparison or time column), no multi-tier / star-tree, comparison / 
delete-record / out-of-order columns are
   /// valid, deleted-keys compaction consistency, post-partial-upsert 
transforms, consistency-mode constraints, and
-  /// delegates to [#validateTTLForUpsertConfig] and 
[#validatePartialUpsertStrategies]; rejects MD5 when disabled.
+  /// delegates to [#validateTTLForUpsertConfig], 
[#validatePartialUpsertStrategies] and
+  /// [#validatePauselessUpsertModes]; rejects MD5 when disabled.
   @VisibleForTesting
   static void validateUpsertConfig(TableConfig tableConfig, Schema schema) {
     validateUpsertConfig(tableConfig, schema, null);
@@ -1272,6 +1274,7 @@ public final class TableConfigUtils {
     validateTTLForUpsertConfig(tableConfig, schema);
     validatePartialUpsertStrategies(tableConfig, schema);
     validateConsumptionDuringUpsertRevert(tableConfig);
+    validatePauselessUpsertModes(tableConfig, existingTableConfig);
     Preconditions.checkState(!(PinotMd5Mode.isPinotMd5Disabled() && 
upsertConfig.getHashFunction() == HashFunction.MD5),
         "Upsert hash function MD5 is disabled via '%s=true'", 
CommonConstants.CONFIG_OF_PINOT_MD5_DISABLED);
   }
@@ -1321,6 +1324,40 @@ public final class TableConfigUtils {
         policy != null ? "parallelSegmentConsumptionPolicy " + policy : 
"allowPartialUpsertConsumptionDuringCommit");
   }
 
+  /// Rejects partial upsert and out-of-order record handling 
(`dropOutOfOrderRecord` or `outOfOrderRecordColumn`) on a
+  /// new pauseless table. A pauseless segment is committed before it is 
built, so a failed build is repaired by
+  /// consuming its offsets again, and for these modes that second pass can 
produce different rows: a partial upsert
+  /// merge, and whether a record is dropped or marked out of order, depend on 
the upsert metadata at the time each
+  /// record arrives.
+  ///
+  /// An update is not checked here. One that turns the combination on is a 
backward compatibility violation (see
+  /// [#validateBackwardCompatibility]), so `force=true` can apply it, and one 
that keeps it is allowed.
+  @VisibleForTesting
+  static void validatePauselessUpsertModes(TableConfig tableConfig, @Nullable 
TableConfig existingTableConfig) {
+    if (existingTableConfig != null || 
!PauselessConsumptionUtils.isPauselessEnabled(tableConfig)) {
+      return;
+    }
+    UpsertConfig upsertConfig = tableConfig.getUpsertConfig();
+    Preconditions.checkState(upsertConfig.getMode() != 
UpsertConfig.Mode.PARTIAL,
+        "Partial upsert cannot be used with pauseless consumption. If a 
segment is recovered after a failure, "
+            + "merged values can change. Set upsertConfig.mode to FULL or "
+            + 
"ingestionConfig.streamIngestionConfig.pauselessConsumptionEnabled to false");
+    Preconditions.checkState(!upsertConfig.isDropOutOfOrderRecord() && 
upsertConfig.getOutOfOrderRecordColumn() == null,
+        "dropOutOfOrderRecord and outOfOrderRecordColumn cannot be used with 
pauseless consumption. If a segment is "
+            + "recovered after a failure, different records can be dropped or 
marked out of order. Set "
+            + "upsertConfig.dropOutOfOrderRecord to false or remove 
upsertConfig.outOfOrderRecordColumn, or set "
+            + 
"ingestionConfig.streamIngestionConfig.pauselessConsumptionEnabled to false");
+  }
+
+  /// Returns whether the table is pauseless and uses partial upsert, 
`dropOutOfOrderRecord` or
+  /// `outOfOrderRecordColumn`, see [#validatePauselessUpsertModes].
+  private static boolean hasPauselessUnsafeUpsertMode(TableConfig tableConfig) 
{
+    UpsertConfig upsertConfig = tableConfig.getUpsertConfig();
+    return upsertConfig != null && 
PauselessConsumptionUtils.isPauselessEnabled(tableConfig) && (
+        upsertConfig.getMode() == UpsertConfig.Mode.PARTIAL || 
upsertConfig.isDropOutOfOrderRecord()
+            || upsertConfig.getOutOfOrderRecordColumn() != null);
+  }
+
   /// Checks if a data type is valid for time-based comparison operations 
(upsert/dedup).
   /// Valid types include numeric types and types with stored data as a 
numeric type:
   ///   e.g. TIMESTAMP which is stored as LONG internally.
@@ -1756,7 +1793,9 @@ public final class TableConfigUtils {
 
   /// Validates that critical upsert configuration fields are not changed 
during table config update.
   /// Checks: mode, hashFunction, comparisonColumns, timeColumn (when no 
comparison columns),
-  /// deleteRecordColumn, dropOutOfOrderRecord, outOfOrderRecordColumn.
+  /// deleteRecordColumn, dropOutOfOrderRecord, outOfOrderRecordColumn, and 
that the update does not turn on partial
+  /// upsert, dropOutOfOrderRecord or outOfOrderRecordColumn on a pauseless 
table, by any of those settings or by adding
+  /// the upsert config.
   ///
   /// Partial-upsert strategy maps and the default partial-upsert strategy are 
intentionally
   /// not validated here — they may be added, removed, or changed on existing 
tables.
@@ -1766,6 +1805,12 @@ public final class TableConfigUtils {
   /// @param violations list to collect violation messages
   private static void validateUpsertConfigUpdate(TableConfig newConfig, 
TableConfig existingConfig,
       List<String> violations) {
+    // When one of these upsert settings changes, this adds to that field's 
violation and says why it is unsafe
+    if (hasPauselessUnsafeUpsertMode(newConfig) && 
!hasPauselessUnsafeUpsertMode(existingConfig)) {
+      violations.add("pauseless consumption with partial upsert, 
dropOutOfOrderRecord or outOfOrderRecordColumn "
+          + "(merged values, or which records are dropped or marked out of 
order, can change when a segment is "
+          + "recovered after a failure)");
+    }
     boolean existingUpsertEnabled = existingConfig.isUpsertEnabled();
     boolean newUpsertEnabled = newConfig.isUpsertEnabled();
 
diff --git 
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/TableConfigUtilsTest.java
 
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/TableConfigUtilsTest.java
index 6deb0aca427..4b46b0d0689 100644
--- 
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/TableConfigUtilsTest.java
+++ 
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/TableConfigUtilsTest.java
@@ -2858,6 +2858,81 @@ public class TableConfigUtilsTest {
     }
   }
 
+  @Test
+  public void testValidatePauselessUpsertModes() {
+    UpsertConfig fullUpsertConfig = new UpsertConfig(UpsertConfig.Mode.FULL);
+    UpsertConfig partialUpsertConfig = new 
UpsertConfig(UpsertConfig.Mode.PARTIAL);
+    UpsertConfig dropOutOfOrderConfig = new 
UpsertConfig(UpsertConfig.Mode.FULL);
+    dropOutOfOrderConfig.setDropOutOfOrderRecord(true);
+    UpsertConfig outOfOrderColumnConfig = new 
UpsertConfig(UpsertConfig.Mode.FULL);
+    outOfOrderColumnConfig.setOutOfOrderRecordColumn("isOutOfOrder");
+    TableConfig pauselessFull = 
createTableConfigWithConsumptionPolicy(fullUpsertConfig, null, true);
+    TableConfig pauselessPartial = 
createTableConfigWithConsumptionPolicy(partialUpsertConfig, null, true);
+    TableConfig pauselessDropOutOfOrder = 
createTableConfigWithConsumptionPolicy(dropOutOfOrderConfig, null, true);
+    TableConfig partial = 
createTableConfigWithConsumptionPolicy(partialUpsertConfig, null, false);
+    TableConfig dropOutOfOrder = 
createTableConfigWithConsumptionPolicy(dropOutOfOrderConfig, null, false);
+    TableConfig pauselessOutOfOrderColumn = 
createTableConfigWithConsumptionPolicy(outOfOrderColumnConfig, null, true);
+    TableConfig outOfOrderColumn = 
createTableConfigWithConsumptionPolicy(outOfOrderColumnConfig, null, false);
+
+    // A new pauseless table cannot use partial upsert or dropOutOfOrderRecord
+    IllegalStateException e = expectThrows(IllegalStateException.class,
+        () -> TableConfigUtils.validatePauselessUpsertModes(pauselessPartial, 
null));
+    assertTrue(e.getMessage().startsWith("Partial upsert cannot be used with 
pauseless consumption."),
+        e.getMessage());
+    e = expectThrows(IllegalStateException.class,
+        () -> 
TableConfigUtils.validatePauselessUpsertModes(pauselessDropOutOfOrder, null));
+    assertTrue(e.getMessage().startsWith(
+        "dropOutOfOrderRecord and outOfOrderRecordColumn cannot be used with 
pauseless consumption."), e.getMessage());
+    e = expectThrows(IllegalStateException.class,
+        () -> 
TableConfigUtils.validatePauselessUpsertModes(pauselessOutOfOrderColumn, null));
+    assertTrue(e.getMessage().startsWith(
+        "dropOutOfOrderRecord and outOfOrderRecordColumn cannot be used with 
pauseless consumption."), e.getMessage());
+    TableConfigUtils.validatePauselessUpsertModes(pauselessFull, null);
+    TableConfigUtils.validatePauselessUpsertModes(partial, null);
+    TableConfigUtils.validatePauselessUpsertModes(dropOutOfOrder, null);
+    TableConfigUtils.validatePauselessUpsertModes(outOfOrderColumn, null);
+
+    // An update is left to the backward compatibility check, so force=true 
can apply it
+    TableConfigUtils.validatePauselessUpsertModes(pauselessPartial, partial);
+    TableConfigUtils.validatePauselessUpsertModes(pauselessDropOutOfOrder, 
pauselessFull);
+
+    // An update that turns either combination on is a violation, whether it 
enables pauseless, changes the upsert
+    // mode or dropOutOfOrderRecord, or adds the upsert config
+    TableConfig pauselessNoUpsert = 
createTableConfigWithConsumptionPolicy(null, null, true);
+    assertPauselessUpsertViolation(pauselessPartial, partial, true);
+    assertPauselessUpsertViolation(pauselessDropOutOfOrder, dropOutOfOrder, 
true);
+    assertPauselessUpsertViolation(pauselessPartial, pauselessFull, true);
+    assertPauselessUpsertViolation(pauselessDropOutOfOrder, pauselessFull, 
true);
+    assertPauselessUpsertViolation(pauselessPartial, pauselessNoUpsert, true);
+    assertPauselessUpsertViolation(pauselessOutOfOrderColumn, 
outOfOrderColumn, true);
+    assertPauselessUpsertViolation(pauselessOutOfOrderColumn, pauselessFull, 
true);
+
+    // An update of a table that already has a combination, or that does not 
turn one on, is not
+    assertPauselessUpsertViolation(pauselessPartial, pauselessPartial, false);
+    assertPauselessUpsertViolation(pauselessDropOutOfOrder, 
pauselessDropOutOfOrder, false);
+    assertPauselessUpsertViolation(pauselessOutOfOrderColumn, 
pauselessOutOfOrderColumn, false);
+    assertPauselessUpsertViolation(pauselessFull, pauselessFull, false);
+    assertPauselessUpsertViolation(partial, pauselessPartial, false);
+
+    // The check is part of the upsert validation
+    Schema schema = new Schema.SchemaBuilder().setSchemaName(TABLE_NAME)
+        .addSingleValueDimension("myCol", DataType.STRING)
+        .setPrimaryKeyColumns(List.of("myCol"))
+        .build();
+    e = expectThrows(IllegalStateException.class,
+        () -> TableConfigUtils.validateUpsertConfig(pauselessDropOutOfOrder, 
schema));
+    assertTrue(e.getMessage().startsWith(
+        "dropOutOfOrderRecord and outOfOrderRecordColumn cannot be used with 
pauseless consumption."), e.getMessage());
+  }
+
+  private static void assertPauselessUpsertViolation(TableConfig newConfig, 
TableConfig existingConfig,
+      boolean expected) {
+    List<String> violations = 
TableConfigUtils.validateBackwardCompatibility(newConfig, existingConfig);
+    assertEquals(violations.stream()
+        .anyMatch(v -> v.startsWith("pauseless consumption with partial 
upsert, dropOutOfOrderRecord")), expected,
+        violations.toString());
+  }
+
   @Test
   public void testConsumptionPolicyMatrix() {
     ConsumingSegmentConsistencyModeListener listener = 
ConsumingSegmentConsistencyModeListener.getInstance();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to