This is an automated email from the ASF dual-hosted git repository.
jackie 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 0929b4cdd1 Disallow peer download when replication is < 2 (#11469)
0929b4cdd1 is described below
commit 0929b4cdd1b3526824db551b6d7e1e5fe25aee52
Author: Saurabh Dubey <[email protected]>
AuthorDate: Wed Sep 13 05:14:04 2023 +0530
Disallow peer download when replication is < 2 (#11469)
---
.../segment/local/utils/TableConfigUtils.java | 4 ++++
.../segment/local/utils/TableConfigUtilsTest.java | 26 +++++++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletion(-)
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 75a2f23054..7d1b5d6ca3 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
@@ -277,6 +277,10 @@ public final class TableConfigUtils {
throw new IllegalStateException("Invalid value '" +
peerSegmentDownloadScheme
+ "' for peerSegmentDownloadScheme. Must be one of http or https");
}
+
+ if (tableConfig.getReplication() < 2) {
+ throw new IllegalStateException("peerSegmentDownloadScheme can't be
used when replication is < 2");
+ }
}
validateRetentionConfig(tableConfig);
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 985c0be825..0ea7acfeb6 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
@@ -35,6 +35,7 @@ import org.apache.pinot.spi.config.table.HashFunction;
import org.apache.pinot.spi.config.table.ReplicaGroupStrategyConfig;
import org.apache.pinot.spi.config.table.RoutingConfig;
import org.apache.pinot.spi.config.table.SegmentPartitionConfig;
+import org.apache.pinot.spi.config.table.SegmentsValidationAndRetentionConfig;
import org.apache.pinot.spi.config.table.StarTreeIndexConfig;
import org.apache.pinot.spi.config.table.TableConfig;
import org.apache.pinot.spi.config.table.TableTaskConfig;
@@ -320,8 +321,31 @@ public class TableConfigUtilsTest {
// expected
}
- // invalid filter config since Groovy is disabled
+ // Using peer download scheme with replication of 1
ingestionConfig.setTransformConfigs(null);
+ SegmentsValidationAndRetentionConfig segmentsValidationAndRetentionConfig =
+ new SegmentsValidationAndRetentionConfig();
+ segmentsValidationAndRetentionConfig.setReplication("1");
+
segmentsValidationAndRetentionConfig.setPeerSegmentDownloadScheme(CommonConstants.HTTP_PROTOCOL);
+ tableConfig.setValidationConfig(segmentsValidationAndRetentionConfig);
+ try {
+ TableConfigUtils.validate(tableConfig, schema);
+ Assert.fail("Should fail when peer download scheme is used with
replication of 1");
+ } catch (IllegalStateException e) {
+ // expected
+ Assert.assertEquals(e.getMessage(), "peerSegmentDownloadScheme can't be
used when replication is < 2");
+ }
+
+ segmentsValidationAndRetentionConfig.setReplication("2");
+ tableConfig.setValidationConfig(segmentsValidationAndRetentionConfig);
+ try {
+ TableConfigUtils.validate(tableConfig, schema);
+ } catch (IllegalStateException e) {
+ // expected
+ Assert.fail("Should not fail when peer download scheme is used with
replication of > 1");
+ }
+
+ // invalid filter config since Groovy is disabled
ingestionConfig.setFilterConfig(new FilterConfig("Groovy({timestamp > 0},
timestamp)"));
try {
TableConfigUtils.validate(tableConfig, schema, null, true);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]