Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public enum ServerMeter implements AbstractMetrics.Meter {
UPSERT_MISSED_VALID_DOC_ID_SNAPSHOT_COUNT("segments", false),
UPSERT_MISSED_QUERYABLE_DOC_ID_SNAPSHOT_COUNT("segments", false),
UPSERT_PRELOAD_FAILURE("count", false),
UPSERT_NEW_KEYS_INSERTED("rows", false),
UPSERT_EXISTING_KEYS_UPDATED("rows", false),
ROWS_WITH_ERRORS("rows", false),
LLC_CONTROLLER_RESPONSE_NOT_SENT("messages", true),
LLC_CONTROLLER_RESPONSE_COMMIT("messages", true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,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();
Expand Down Expand Up @@ -404,11 +405,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);
}
});

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

_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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()) {
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

_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();
}
Expand Down
Loading