Skip to content

Add per-table insert/update counters to upsert metadata managers#18427

Open
priyen-stripe wants to merge 3 commits intoapache:masterfrom
priyen:more-upsert-metrics
Open

Add per-table insert/update counters to upsert metadata managers#18427
priyen-stripe wants to merge 3 commits intoapache:masterfrom
priyen:more-upsert-metrics

Conversation

@priyen-stripe
Copy link
Copy Markdown
Contributor

@priyen-stripe priyen-stripe commented May 5, 2026

Summary

  • Adds UPSERT_KEYS_INSERTED, UPSERT_KEYS_UPDATED, and UPSERT_KEYS_DELETED to ServerMeter to distinguish append, update, and delete traffic in upsert tables
  • Emits metrics inline inside the ConcurrentHashMap.compute() lambda, directly next to addDocId/replaceDocId, in both ConcurrentMapPartitionUpsertMetadataManager and ConcurrentMapPartitionUpsertMetadataManagerForConsistentDeletes
  • Delete records (tombstones) increment UPSERT_KEYS_DELETED instead of the insert/update counters, keeping the metric contract correct for delete-heavy workloads
  • Out-of-order records increment none of these counters, consistent with the existing UPSERT_OUT_OF_ORDER meter
  • Removed the isNewKey AtomicBoolean — the lambda structure itself determines which metric to emit, same as handleOutOfOrderEvent which already emits metrics inside the lambda

New metric names:

  • UPSERT_KEYS_INSERTED
  • UPSERT_KEYS_UPDATED
  • UPSERT_KEYS_DELETED

Testing

Tested internally at Stripe on test tables, worked:
image

Label

observability

…metrics

Emits per-table counters in both ConcurrentMapPartitionUpsertMetadataManager
and its consistent-deletes variant to distinguish append (new PK) from update
(existing PK) traffic in upsert tables. Out-of-order records are counted by
neither metric, consistent with the existing UPSERT_OUT_OF_ORDER meter.

Prometheus metric names:
  pinot_server_upsertNewKeysInserted
  pinot_server_upsertExistingKeysUpdated

Co-authored-by: Priyen Patel <priyenpatel2014@gmail.com>
@priyen-stripe
Copy link
Copy Markdown
Contributor Author

cc @Jackie-Jiang @suvodeep-pyne

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.59%. Comparing base (b870804) to head (bfb60fc).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18427      +/-   ##
============================================
- Coverage     63.61%   63.59%   -0.02%     
  Complexity     1717     1717              
============================================
  Files          3252     3252              
  Lines        199051   199146      +95     
  Branches      30838    30876      +38     
============================================
+ Hits         126618   126652      +34     
- Misses        62352    62418      +66     
+ Partials      10081    10076       -5     
Flag Coverage Δ
custom-integration1 100.00% <ø> (ø)
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-21 63.59% <100.00%> (-0.02%) ⬇️
temurin 63.59% <100.00%> (-0.02%) ⬇️
unittests 63.59% <100.00%> (-0.02%) ⬇️
unittests1 55.67% <21.42%> (+0.02%) ⬆️
unittests2 34.92% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@xiangfu0 xiangfu0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found two high-signal metric-contract issues; see inline comments.

}
});

if (isNewKey.get()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block increments the new meters for every non-out-of-order record, including tombstones. On delete-enabled upsert tables, a first-seen delete will hit UPSERT_NEW_KEYS_INSERTED and a delete for an existing PK will hit UPSERT_EXISTING_KEYS_UPDATED, even though neither is an insert/update row. Because these are new exported Prometheus counters, that makes the public metric contract wrong for delete-heavy workloads. Please guard these counters with !recordInfo.isDeleteRecord() or add a separate delete meter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, pushed commit to fix this

}
});

if (isNewKey.get()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue here: delete records are counted under the new insert/update meters. In delete-enabled tables this misclassifies tombstone traffic as inserts/updates, so the exposed per-table counters become incorrect even though the underlying upsert state is handled correctly. This needs the same !recordInfo.isDeleteRecord() guard or a dedicated delete counter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, pushed commit to fix this

…meter

Address PR feedback:
- Guard insert/update metrics against delete records by moving metric
  emission inline next to addDocId/replaceDocId inside the compute() lambda.
- Add dedicated UPSERT_KEYS_DELETED counter for tombstone ingestion.
- Remove isNewKey AtomicBoolean since it's no longer needed.

Co-authored-by: Priyen Patel <priyenpatel2014@gmail.com>
@priyen priyen force-pushed the more-upsert-metrics branch from 0e17219 to 03d4f3e Compare May 6, 2026 15:10
Consolidate duplicated upsert metric emission into a shared
BasePartitionUpsertMetadataManager.emitUpsertMetrics() method.
Rename UPSERT_NEW_KEYS_INSERTED/UPSERT_EXISTING_KEYS_UPDATED to
UPSERT_KEYS_INSERTED/UPSERT_KEYS_UPDATED for consistent naming.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
@priyen-stripe priyen-stripe requested a review from xiangfu0 May 6, 2026 17:06
@priyen-stripe
Copy link
Copy Markdown
Contributor Author

@xiangfu0 thanks for the review, address your feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants