You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by ab...@apache.org on 2026/01/29 21:32:29 UTC

(druid) branch improve_logging created (now 2b308a344c2)

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

abhishekrb pushed a change to branch improve_logging
in repository https://gitbox.apache.org/repos/asf/druid.git


      at 2b308a344c2 Add new metrics and logging whenever the table schema is updated.

This branch includes the following new commits:

     new 2b308a344c2 Add new metrics and logging whenever the table schema is updated.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


(druid) 01/01: Add new metrics and logging whenever the table schema is updated.

Posted by ab...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

abhishekrb pushed a commit to branch improve_logging
in repository https://gitbox.apache.org/repos/asf/druid.git

commit 2b308a344c23b19853032ebad40328ac0f379033
Author: Abhishek Balaji Radhakrishnan <ab...@gmail.com>
AuthorDate: Thu Jan 29 13:29:56 2026 -0800

    Add new metrics and logging whenever the table schema is updated.
    
    We encountered a schema synchronization bug that sometimes results in
    invalid plans. Will add more details later. But wanted to get some
    observability improvements whenever the broker updates its metadata cache
    similar to the other schema refreshes.
---
 .../org/apache/druid/segment/metadata/Metric.java  |  3 +++
 .../calcite/schema/BrokerSegmentMetadataCache.java | 30 +++++++++++++++++++---
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/server/src/main/java/org/apache/druid/segment/metadata/Metric.java b/server/src/main/java/org/apache/druid/segment/metadata/Metric.java
index a29f4a7eaff..358720b98a8 100644
--- a/server/src/main/java/org/apache/druid/segment/metadata/Metric.java
+++ b/server/src/main/java/org/apache/druid/segment/metadata/Metric.java
@@ -53,6 +53,9 @@ public class Metric
   public static final String REFRESH_SKIPPED_TOMBSTONES = PREFIX + "refresh/tombstone/count";
   public static final String REFRESH_DURATION_MILLIS = PREFIX + "refresh/time";
   public static final String DATASOURCE_REMOVED = PREFIX + "dataSource/removed";
+  public static final String SCHEMA_ROW_SIGNATURE_INITIALIZED = PREFIX + "rowSignature/initialized";
+  public static final String SCHEMA_ROW_SIGNATURE_CHANGED = PREFIX + "rowSignature/changed";
+  public static final String SCHEMA_ROW_SIGNATURE_COLUMN_COUNT = PREFIX + "rowSignature/column/count";
 
   /**
    * Number of used cold segments in the metadata store.
diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/schema/BrokerSegmentMetadataCache.java b/sql/src/main/java/org/apache/druid/sql/calcite/schema/BrokerSegmentMetadataCache.java
index 084671d25e4..c93a5ea8343 100644
--- a/sql/src/main/java/org/apache/druid/sql/calcite/schema/BrokerSegmentMetadataCache.java
+++ b/sql/src/main/java/org/apache/druid/sql/calcite/schema/BrokerSegmentMetadataCache.java
@@ -358,10 +358,34 @@ public class BrokerSegmentMetadataCache extends AbstractSegmentMetadataCache<Phy
   private void updateDSMetadata(String dataSource, PhysicalDatasourceMetadata physicalDatasourceMetadata)
   {
     final PhysicalDatasourceMetadata oldTable = tables.put(dataSource, physicalDatasourceMetadata);
-    if (oldTable == null || !oldTable.getRowSignature().equals(physicalDatasourceMetadata.getRowSignature())) {
-      log.info("[%s] has new signature: %s.", dataSource, physicalDatasourceMetadata.getRowSignature());
+    final RowSignature newRowSignature = physicalDatasourceMetadata.getRowSignature();
+    final int newRowSignatureColumnCount = newRowSignature.getColumnNames().size();
+
+    final ServiceMetricEvent.Builder builder =
+        new ServiceMetricEvent.Builder().setDimension(DruidMetrics.DATASOURCE, dataSource);
+
+    if (oldTable == null) {
+      log.info(
+          "Row signature for datasource[%s] initialized with [%d] columns - signature[%s]",
+          dataSource, newRowSignatureColumnCount, newRowSignature
+      );
+
+      emitMetric(Metric.SCHEMA_ROW_SIGNATURE_INITIALIZED, 1, builder);
+      emitMetric(Metric.SCHEMA_ROW_SIGNATURE_COLUMN_COUNT, newRowSignatureColumnCount, builder);
+      return;
+    }
+
+    final RowSignature oldRowSignature = oldTable.getRowSignature();
+    if (!oldRowSignature.equals(newRowSignature)) {
+      log.info(
+          "Row signature for datasource[%s] updated from [%d] columns to [%d] columns - new signature[%s]",
+          dataSource, oldRowSignature.getColumnNames().size(), newRowSignatureColumnCount, newRowSignature
+      );
+
+      emitMetric(Metric.SCHEMA_ROW_SIGNATURE_CHANGED, 1, builder);
+      emitMetric(Metric.SCHEMA_ROW_SIGNATURE_COLUMN_COUNT, newRowSignatureColumnCount, builder);
     } else {
-      log.debug("[%s] signature is unchanged.", dataSource);
+      log.debug("Row signature for datasource[%s] is unchanged.", dataSource);
     }
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org