Skip to content
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

Ability to track offsets of filtered events #12602

Merged
merged 1 commit into from
Apr 18, 2024
Merged
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 @@ -307,6 +307,8 @@ public void deleteSegmentFile() {

private final StreamPartitionMsgOffset _latestStreamOffsetAtStartupTime;
private final CompletionMode _segmentCompletionMode;
private final List<String> _filteredMessageOffsets = new ArrayList<>();
ankitsultana marked this conversation as resolved.
Show resolved Hide resolved
private boolean _trackFilteredMessageOffsets = false;

// TODO each time this method is called, we print reason for stop. Good to print only once.
private boolean endCriteriaReached() {
Expand Down Expand Up @@ -609,6 +611,9 @@ private boolean processStreamEvents(MessageBatch messageBatch, long idlePipeSlee
if (reusedResult.getSkippedRowCount() > 0) {
realtimeRowsDroppedMeter = _serverMetrics.addMeteredTableValue(_clientId, ServerMeter.REALTIME_ROWS_FILTERED,
reusedResult.getSkippedRowCount(), realtimeRowsDroppedMeter);
if (_trackFilteredMessageOffsets) {
_filteredMessageOffsets.add(offset.toString());
}
}
if (reusedResult.getIncompleteRowCount() > 0) {
realtimeIncompleteRowsConsumedMeter =
Expand Down Expand Up @@ -1421,6 +1426,12 @@ public RealtimeSegmentDataManager(SegmentZKMetadata segmentZKMetadata, TableConf
.createRateLimiter(_streamConfig, _tableNameWithType, _serverMetrics, _clientId);
_serverRateLimiter = RealtimeConsumptionRateManager.getInstance().getServerRateLimiter();

if (tableConfig.getIngestionConfig() != null
&& tableConfig.getIngestionConfig().getStreamIngestionConfig() != null) {
_trackFilteredMessageOffsets =
tableConfig.getIngestionConfig().getStreamIngestionConfig().isTrackFilteredMessageOffsets();
}

List<String> sortedColumns = indexLoadingConfig.getSortedColumns();
String sortedColumn;
if (sortedColumns.isEmpty()) {
Expand Down Expand Up @@ -1758,6 +1769,12 @@ private void updateCurrentDocumentCountMetrics() {
_segmentLogger.info(
"Consumed {} events from (rate:{}/s), currentOffset={}, numRowsConsumedSoFar={}, numRowsIndexedSoFar={}",
rowsConsumed, consumedRate, _currentOffset, _numRowsConsumed, _numRowsIndexed);
if (_filteredMessageOffsets.size() > 0) {
if (_trackFilteredMessageOffsets) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This check is redundant

Copy link
Contributor Author

@tibrewalpratik17 tibrewalpratik17 Apr 18, 2024

Choose a reason for hiding this comment

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

I left it on purpose if anyone changes the logic to pushing to _filteredMessageOffsets in the future for any other usecase we can still ensure that the config is enabled.

_segmentLogger.info("Filtered events with offsets: {}", _filteredMessageOffsets);
tibrewalpratik17 marked this conversation as resolved.
Show resolved Hide resolved
}
Comment on lines +1773 to +1775
Copy link
Contributor Author

Choose a reason for hiding this comment

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

self-review: adding a nested-if instead of combining it to ensure that _filteredMessageOffsets gets clear every time just in case in future someone changes the logic of pushing to _filteredMessageOffsets.

_filteredMessageOffsets.clear();
}
_lastConsumedCount = _numRowsConsumed;
_lastLogTime = now;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public class StreamIngestionConfig extends BaseJsonConfig {
@JsonPropertyDescription("Whether to use column major mode when creating the segment.")
private boolean _columnMajorSegmentBuilderEnabled = true;

@JsonPropertyDescription("Whether to track offsets of the filtered stream messages during consumption.")
private boolean _trackFilteredMessageOffsets = false;

@JsonCreator
public StreamIngestionConfig(@JsonProperty("streamConfigMaps") List<Map<String, String>> streamConfigMaps) {
_streamConfigMaps = streamConfigMaps;
Expand All @@ -53,4 +56,12 @@ public void setColumnMajorSegmentBuilderEnabled(boolean enableColumnMajorSegment
public boolean getColumnMajorSegmentBuilderEnabled() {
return _columnMajorSegmentBuilderEnabled;
}

public void setTrackFilteredMessageOffsets(boolean trackFilteredMessageOffsets) {
_trackFilteredMessageOffsets = trackFilteredMessageOffsets;
}

public boolean isTrackFilteredMessageOffsets() {
return _trackFilteredMessageOffsets;
}
}
Loading