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

KKcorps 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 4e6445cc910 Add an overridable table-config-change callback distinct 
from index-loading-config fetch (#18792)
4e6445cc910 is described below

commit 4e6445cc91060721310d65db60a8c39bfa57bce6
Author: Krishan Goyal <[email protected]>
AuthorDate: Thu Jun 18 16:26:20 2026 +0530

    Add an overridable table-config-change callback distinct from 
index-loading-config fetch (#18792)
---
 .../core/data/manager/BaseTableDataManager.java    |  7 ++++++
 .../data/manager/BaseTableDataManagerTest.java     | 25 ++++++++++++++++++++++
 .../local/data/manager/TableDataManager.java       | 14 ++++++++++++
 .../helix/SegmentMessageHandlerFactory.java        |  5 +++--
 4 files changed, 49 insertions(+), 2 deletions(-)

diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java
 
b/pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java
index e0b2e76980b..5667b5d938d 100644
--- 
a/pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java
+++ 
b/pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java
@@ -447,6 +447,13 @@ public abstract class BaseTableDataManager implements 
TableDataManager {
     _cachedTableConfigAndSchema = Pair.of(tableConfig, schema);
   }
 
+  @Override
+  public void onTableConfigOrSchemaRefresh() {
+    // A genuine config/schema change: refresh the cached table config and 
schema from ZK. The returned index loading
+    // config is not needed here; the side effect of updating the cache is the 
contract of this callback.
+    fetchIndexLoadingConfig();
+  }
+
   @Override
   public void addNewOnlineSegment(SegmentZKMetadata zkMetadata, 
IndexLoadingConfig indexLoadingConfig)
       throws Exception {
diff --git 
a/pinot-core/src/test/java/org/apache/pinot/core/data/manager/BaseTableDataManagerTest.java
 
b/pinot-core/src/test/java/org/apache/pinot/core/data/manager/BaseTableDataManagerTest.java
index 88d7565c306..248ad28ca35 100644
--- 
a/pinot-core/src/test/java/org/apache/pinot/core/data/manager/BaseTableDataManagerTest.java
+++ 
b/pinot-core/src/test/java/org/apache/pinot/core/data/manager/BaseTableDataManagerTest.java
@@ -80,6 +80,7 @@ import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.testng.Assert.*;
 
@@ -897,6 +898,30 @@ public class BaseTableDataManagerTest {
     assertEquals(new SegmentMetadataImpl(dataDir).getTotalDocs(), 5);
   }
 
+  @Test
+  public void testOnTableConfigOrSchemaRefreshRefreshesCachedConfig()
+      throws Exception {
+    BaseTableDataManager tableDataManager = spy(createTableManager());
+    TableConfig refreshedConfig =
+        new 
TableConfigBuilder(TableType.OFFLINE).setTableName(RAW_TABLE_NAME).setNumReplicas(2).build();
+    Schema refreshedSchema = new 
Schema.SchemaBuilder().setSchemaName(RAW_TABLE_NAME)
+        .addSingleValueDimension(STRING_COLUMN, DataType.STRING).build();
+    // Stand in for the ZK fetch fetchIndexLoadingConfig performs: its 
contract is to refresh the cached config/schema.
+    doAnswer(invocation -> {
+      tableDataManager.updateCachedTableConfigAndSchema(refreshedConfig, 
refreshedSchema);
+      return new IndexLoadingConfig();
+    }).when(tableDataManager).fetchIndexLoadingConfig();
+
+    assertSame(tableDataManager.getCachedTableConfigAndSchema().getLeft(), 
DEFAULT_TABLE_CONFIG);
+
+    tableDataManager.onTableConfigOrSchemaRefresh();
+
+    // The default callback refreshes the cache via the index-loading-config 
fetch.
+    verify(tableDataManager).fetchIndexLoadingConfig();
+    assertSame(tableDataManager.getCachedTableConfigAndSchema().getLeft(), 
refreshedConfig);
+    assertSame(tableDataManager.getCachedTableConfigAndSchema().getRight(), 
refreshedSchema);
+  }
+
   // Has to be public class for the class loader to work.
   public static class FakePinotCrypter implements PinotCrypter {
     private File _origFile;
diff --git 
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/data/manager/TableDataManager.java
 
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/data/manager/TableDataManager.java
index cc12bfcec7a..a613906cd3f 100644
--- 
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/data/manager/TableDataManager.java
+++ 
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/data/manager/TableDataManager.java
@@ -350,6 +350,20 @@ public interface TableDataManager {
    */
   void updateCachedTableConfigAndSchema(TableConfig config, Schema schema);
 
+  /**
+   * Callback invoked when the table config or schema has actually changed 
(e.g. when a table config / schema refresh
+   * is delivered out of band, separate from any segment state transition or 
reload). This is distinct from
+   * {@link #fetchIndexLoadingConfig()}, which is also called incidentally 
during state transitions and reloads merely
+   * to obtain the index loading config; this callback is invoked only on a 
genuine config/schema change.
+   * <p>The default implementation refreshes the cached table config and 
schema (by fetching them from ZK), which
+   * preserves the historical behavior of the refresh path. Implementations 
that need to react to a config/schema
+   * change beyond refreshing the cache should override this method and 
additionally invoke {@code super}, or the
+   * default, to keep the cache refreshed.
+   */
+  default void onTableConfigOrSchemaRefresh() {
+    fetchIndexLoadingConfig();
+  }
+
   /**
    * Interface to handle segment state transitions from CONSUMING to DROPPED
    *
diff --git 
a/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/SegmentMessageHandlerFactory.java
 
b/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/SegmentMessageHandlerFactory.java
index a3ed05654af..cf7498b0dee 100644
--- 
a/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/SegmentMessageHandlerFactory.java
+++ 
b/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/SegmentMessageHandlerFactory.java
@@ -260,8 +260,9 @@ public class SegmentMessageHandlerFactory implements 
MessageHandlerFactory {
       try {
         TableDataManager tableDataManager = 
_instanceDataManager.getTableDataManager(_tableNameWithType);
         if (tableDataManager != null) {
-          // Update the table config and schema by fetching from ZK
-          tableDataManager.fetchIndexLoadingConfig();
+          // A genuine table config / schema change: notify the table data 
manager so it can refresh the cached config
+          // and schema (and react to the change) without going through the 
incidental index-loading-config fetch.
+          tableDataManager.onTableConfigOrSchemaRefresh();
         } else {
           _logger.warn("No data manager found for table: {}", 
_tableNameWithType);
         }


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

Reply via email to