-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add per-table insert/update counters to upsert metadata managers #18427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
a88498d
03d4f3e
bfb60fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -486,6 +486,7 @@ protected void clearPrevKeyToRecordLocation() { | |
| @Override | ||
| protected boolean doAddRecord(MutableSegment segment, RecordInfo recordInfo) { | ||
| AtomicBoolean isOutOfOrderRecord = new AtomicBoolean(false); | ||
| AtomicBoolean isNewKey = new AtomicBoolean(false); | ||
| ThreadSafeMutableRoaringBitmap validDocIds = Objects.requireNonNull(segment.getValidDocIds()); | ||
| ThreadSafeMutableRoaringBitmap queryableDocIds = segment.getQueryableDocIds(); | ||
| int newDocId = recordInfo.getDocId(); | ||
|
|
@@ -537,11 +538,17 @@ protected boolean doAddRecord(MutableSegment segment, RecordInfo recordInfo) { | |
| } | ||
| } else { | ||
| // New primary key | ||
| isNewKey.set(true); | ||
| addDocId(segment, validDocIds, queryableDocIds, newDocId, recordInfo); | ||
| return new RecordLocation(segment, newDocId, newComparisonValue, 1); | ||
| } | ||
| }); | ||
|
|
||
| if (isNewKey.get()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch, pushed commit to fix this |
||
| _serverMetrics.addMeteredTableValue(_tableNameWithType, ServerMeter.UPSERT_NEW_KEYS_INSERTED, 1L); | ||
| } else if (!isOutOfOrderRecord.get()) { | ||
| _serverMetrics.addMeteredTableValue(_tableNameWithType, ServerMeter.UPSERT_EXISTING_KEYS_UPDATED, 1L); | ||
| } | ||
| updatePrimaryKeyGauge(); | ||
| return !isOutOfOrderRecord.get(); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
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_INSERTEDand a delete for an existing PK will hitUPSERT_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.There was a problem hiding this comment.
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