Skip to content

Commit 4fba663

Browse files
committed
[fix](lance) Guard storage-routing endpoints and make ANN bounds master-only
Storage-routing keys now belong to the Lance target identity fingerprint. A job persists only a URI, and s3.endpoint and its family are routing, not credentials: a changed endpoint or region can land the same URI on a different storage service. The guard therefore covers the canonical endpoint/region spellings of every S3-compatible property family the Lance chain actually consumes - for s3 datasets LanceS3StorageProvider reads whichever S3-compatible configuration the catalog carries (preferring a concrete family over the generic s3 keys), and for oss datasets the OSS provider reads the oss keys - while access keys, secret keys and session tokens stay rotatable. The two static ANN bounds (lance_index_max_num_partitions, lance_index_max_num_sub_vectors) become masterOnly: validation runs only on the master's validate path, so a follower-side single-node ADMIN SET FRONTEND CONFIG would report success with no effect. Use ADMIN SET ALL FRONTENDS CONFIG for cluster-wide changes.
1 parent dc54320 commit 4fba663

4 files changed

Lines changed: 54 additions & 13 deletions

File tree

‎fe/fe-common/src/main/java/org/apache/doris/common/Config.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4254,13 +4254,13 @@ public void handle(Field field, String value) throws Exception {
42544254
"Max unresolved Lance index jobs across all catalogs (global)."})
42554255
public static long lance_index_job_max_unresolved_global = 256;
42564256

4257-
@ConfField(mutable = true, masterOnly = false,
4257+
@ConfField(mutable = true, masterOnly = true,
42584258
callback = LanceIndexConfigValidator.PositiveIntConfigHandler.class,
42594259
description = {"Lance IVF_PQ 索引 num_partitions 的静态上限。",
42604260
"Static upper bound for num_partitions of Lance IVF_PQ indexes."})
42614261
public static int lance_index_max_num_partitions = 4096;
42624262

4263-
@ConfField(mutable = true, masterOnly = false,
4263+
@ConfField(mutable = true, masterOnly = true,
42644264
callback = LanceIndexConfigValidator.PositiveIntConfigHandler.class,
42654265
description = {"Lance IVF_PQ 索引 num_sub_vectors 的静态上限。",
42664266
"Static upper bound for num_sub_vectors of Lance IVF_PQ indexes."})

‎fe/fe-common/src/test/java/org/apache/doris/common/LanceIndexConfigValidatorTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public void testConfFieldWiring() throws Exception {
5252
LanceIndexConfigValidator.PositiveLongConfigHandler.class);
5353
assertCallbackWiring("lance_index_job_max_unresolved_global", true,
5454
LanceIndexConfigValidator.PositiveLongConfigHandler.class);
55-
assertCallbackWiring("lance_index_max_num_partitions", false,
55+
assertCallbackWiring("lance_index_max_num_partitions", true,
5656
LanceIndexConfigValidator.PositiveIntConfigHandler.class);
57-
assertCallbackWiring("lance_index_max_num_sub_vectors", false,
57+
assertCallbackWiring("lance_index_max_num_sub_vectors", true,
5858
LanceIndexConfigValidator.PositiveIntConfigHandler.class);
5959

6060
ConfigBase.ConfField gate = Config.class.getField("enable_lance_index_mutation")

‎fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogMgr.java‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,25 @@ public class CatalogMgr implements Writable, GsonPostProcessable {
9393
/**
9494
* The Lance catalog properties whose change moves the persisted target identity
9595
* (provider, stable locator, or namespace mapping) out from under unresolved index
96-
* jobs. Credential and other properties are not target-changing and stay unguarded.
97-
* Keys match case-insensitively because the catalog property chain performs no key
96+
* jobs. Credentials stay unguarded and may be rotated freely: an access key, secret
97+
* key or session token authenticates to the same target. Storage-routing properties
98+
* are part of the identity instead, because a job persists only a URI and a different
99+
* endpoint or region can land that same URI on a different storage service. The
100+
* routing entries are the canonical endpoint/region spellings of every S3-compatible
101+
* property family the Lance storage chain consumes: an s3 dataset reads whichever
102+
* S3-compatible configuration the catalog carries (LanceS3StorageProvider prefers a
103+
* concrete family over the generic s3 keys), while an oss dataset reads the oss keys
104+
* only. Other properties are not target-changing and stay unguarded. Keys match
105+
* case-insensitively because the catalog property chain performs no key
98106
* normalization.
99107
*/
100108
private static final Set<String> LANCE_TARGET_IDENTITY_KEYS = ImmutableSet.of(
101109
"lance.catalog.type", "warehouse",
102-
"lance.namespace.parent", "lance.namespace.delimiter", "lance.namespace.root_database");
110+
"lance.namespace.parent", "lance.namespace.delimiter", "lance.namespace.root_database",
111+
"s3.endpoint", "s3.region", "oss.endpoint", "oss.region",
112+
"cos.endpoint", "cos.region", "obs.endpoint", "obs.region",
113+
"minio.endpoint", "minio.region", "gs.endpoint",
114+
"ozone.endpoint", "ozone.region");
103115

104116
private final MonitoredReentrantReadWriteLock lock = new MonitoredReentrantReadWriteLock(true);
105117

‎fe/fe-core/src/test/java/org/apache/doris/datasource/CatalogMgrLanceGuardTest.java‎

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,22 @@
5555
/**
5656
* Coverage for the Lance catalog DDL guard in {@link CatalogMgr}: while the catalog has
5757
* unresolved Lance index jobs, ALTER CATALOG ... SET PROPERTIES must reject actual value
58-
* changes of the five target identity keys (lance.catalog.type, warehouse,
58+
* changes of the target identity keys - the namespace keys (lance.catalog.type, warehouse,
5959
* lance.namespace.parent, lance.namespace.delimiter, lance.namespace.root_database) and
60-
* DROP CATALOG must be rejected; credential-only/unrelated property changes, same-value
61-
* rewrites, renames, and the replay path stay unguarded. The guard message must stay
62-
* neutral: no locator and no release-statement syntax.
60+
* the storage-routing keys (the s3.endpoint/s3.region family) that can land the same
61+
* persisted URI on a different storage service - and DROP CATALOG must be rejected;
62+
* credential-only/unrelated property changes, same-value rewrites, renames, and the
63+
* replay path stay unguarded. The guard message must stay neutral: no locator and no
64+
* release-statement syntax.
6365
*/
6466
public class CatalogMgrLanceGuardTest {
6567
private static final long CATALOG_ID = 10L;
6668
private static final String CATALOG_NAME = "lance_catalog";
6769
private static final String LOCATOR = "s3://bucket/dataset";
6870
private static final String[] IDENTITY_KEYS = {
6971
"lance.catalog.type", "warehouse",
70-
"lance.namespace.parent", "lance.namespace.delimiter", "lance.namespace.root_database"};
72+
"lance.namespace.parent", "lance.namespace.delimiter", "lance.namespace.root_database",
73+
"s3.endpoint", "s3.region"};
7174

7275
private static final class Fixture {
7376
private final CatalogMgr catalogMgr = new CatalogMgr();
@@ -87,6 +90,7 @@ private static final class Fixture {
8790
oldProperties.put("lance.namespace.root_database", "root_db");
8891
oldProperties.put("s3.access_key", "ak");
8992
oldProperties.put("s3.endpoint", "https://s3.example.com");
93+
oldProperties.put("s3.region", "us-east-1");
9094

9195
AtomicReference<String> catalogName = new AtomicReference<>(CATALOG_NAME);
9296
Mockito.when(catalog.getId()).thenReturn(CATALOG_ID);
@@ -223,9 +227,10 @@ public void testCredentialAndUnrelatedKeyChangesAreAllowed() throws Exception {
223227
Fixture fixture = new Fixture("filesystem");
224228
fixture.admitUnresolvedJob();
225229
Map<String, String> newProperties = new HashMap<>();
230+
// Credentials authenticate to the same target, so rotating them stays allowed;
231+
// storage routing (s3.endpoint and family) is identity and is covered below.
226232
newProperties.put("s3.access_key", "rotated-ak");
227233
newProperties.put("s3.secret_key", "rotated-sk");
228-
newProperties.put("s3.endpoint", "https://s3.other-example.com");
229234
newProperties.put("custom.unrelated.property", "value");
230235
try (MockedStatic<Env> mockedEnv = fixture.mockCurrentEnv()) {
231236
fixture.catalogMgr.alterCatalogProps(CATALOG_NAME, newProperties);
@@ -234,6 +239,30 @@ public void testCredentialAndUnrelatedKeyChangesAreAllowed() throws Exception {
234239
}
235240
}
236241

242+
@Test
243+
public void testStorageRoutingKeyChangeWithUnresolvedJobIsBlocked() throws Exception {
244+
// s3.endpoint and its family route the persisted URI to storage rather than
245+
// authenticate to it: a changed endpoint can be a different storage service, so
246+
// it is target identity, not a credential.
247+
Fixture fixture = new Fixture("filesystem");
248+
fixture.admitUnresolvedJob();
249+
try (MockedStatic<Env> mockedEnv = fixture.mockCurrentEnv()) {
250+
DdlException e = Assertions.assertThrows(DdlException.class,
251+
() -> fixture.catalogMgr.alterCatalogProps(CATALOG_NAME,
252+
ImmutableMap.of("s3.endpoint", "https://s3.other-example.com")));
253+
assertNeutralGuardMessage(e);
254+
// A routing key the catalog never carried still counts as a change from its
255+
// implicit absence, exactly like the namespace identity keys.
256+
DdlException absent = Assertions.assertThrows(DdlException.class,
257+
() -> fixture.catalogMgr.alterCatalogProps(CATALOG_NAME,
258+
ImmutableMap.of("oss.endpoint", "https://oss.example.com")));
259+
assertNeutralGuardMessage(absent);
260+
Mockito.verify(fixture.editLog, Mockito.never())
261+
.logCatalogLog(Mockito.anyShort(), Mockito.any());
262+
Mockito.verify(fixture.catalog, Mockito.never()).modifyCatalogProps(Mockito.any());
263+
}
264+
}
265+
237266
@Test
238267
public void testDropCatalogIsBlockedWithUnresolvedJob() throws Exception {
239268
Fixture fixture = new Fixture("filesystem");

0 commit comments

Comments
 (0)