Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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,9 @@ 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_KEYS_INSERTED("rows", false),
UPSERT_KEYS_UPDATED("rows", false),
UPSERT_KEYS_DELETED("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 @@ -1229,6 +1229,16 @@ protected void removeDocId(IndexSegment segment, int docId) {
trackUpdatedSegmentsSinceLastSnapshot(segment);
}

protected void emitUpsertMetrics(RecordInfo recordInfo, boolean isNewKey) {
if (recordInfo.isDeleteRecord()) {
_serverMetrics.addMeteredTableValue(_tableNameWithType, ServerMeter.UPSERT_KEYS_DELETED, 1L);
} else if (isNewKey) {
_serverMetrics.addMeteredTableValue(_tableNameWithType, ServerMeter.UPSERT_KEYS_INSERTED, 1L);
} else {
_serverMetrics.addMeteredTableValue(_tableNameWithType, ServerMeter.UPSERT_KEYS_UPDATED, 1L);
}
}

protected void trackUpdatedSegmentsSinceLastSnapshot(IndexSegment segment) {
if (_enableSnapshot && segment instanceof ImmutableSegment) {
_updatedSegmentsSinceLastSnapshot.add(segment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ protected boolean doAddRecord(MutableSegment segment, RecordInfo recordInfo) {
}
replaceDocId(segment, validDocIds, queryableDocIds, currentSegment, currentDocId, newDocId, recordInfo);
}
emitUpsertMetrics(recordInfo, false);
return newRecordLocation;
} else {
// Out-of-order record
Expand All @@ -405,6 +406,7 @@ protected boolean doAddRecord(MutableSegment segment, RecordInfo recordInfo) {
} else {
// New primary key
addDocId(segment, validDocIds, queryableDocIds, newDocId, recordInfo);
emitUpsertMetrics(recordInfo, true);
return new RecordLocation(segment, newDocId, newComparisonValue);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ protected boolean doAddRecord(MutableSegment segment, RecordInfo recordInfo) {
int currentDocId = currentRecordLocation.getDocId();
if (segment == currentSegment) {
replaceDocId(segment, validDocIds, queryableDocIds, currentDocId, newDocId, recordInfo);
emitUpsertMetrics(recordInfo, false);
return new RecordLocation(segment, newDocId, newComparisonValue,
currentRecordLocation.getDistinctSegmentCount());
} else {
Expand All @@ -519,6 +520,7 @@ protected boolean doAddRecord(MutableSegment segment, RecordInfo recordInfo) {
_previousKeyToRecordLocationMap.put(primaryKey, currentRecordLocation);
}
replaceDocId(segment, validDocIds, queryableDocIds, currentSegment, currentDocId, newDocId, recordInfo);
emitUpsertMetrics(recordInfo, false);
return new RecordLocation(segment, newDocId, newComparisonValue,
RecordLocation.incrementSegmentCount(currentRecordLocation.getDistinctSegmentCount()));
}
Expand All @@ -538,6 +540,7 @@ protected boolean doAddRecord(MutableSegment segment, RecordInfo recordInfo) {
} else {
// New primary key
addDocId(segment, validDocIds, queryableDocIds, newDocId, recordInfo);
emitUpsertMetrics(recordInfo, true);
return new RecordLocation(segment, newDocId, newComparisonValue, 1);
}
});
Expand Down
Loading