Copilot commented on code in PR #17071:
URL: https://github.com/apache/pinot/pull/17071#discussion_r2644832249
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeSegmentDataManager.java:
##########
@@ -630,13 +634,22 @@ private boolean processStreamEvents(MessageBatch
messageBatch, long idlePipeSlee
StreamPartitionMsgOffset nextOffset = metadata.getNextOffset();
int rowSizeInBytes = metadata.getRecordSerializedSize();
if (decodedRow.getException() != null) {
- // TODO: based on a config, decide whether the record should be
silently dropped or stop further consumption on
- // decode error
- realtimeRowsDroppedMeter =
- _serverMetrics.addMeteredTableValue(_clientId,
ServerMeter.INVALID_REALTIME_ROWS_DROPPED, 1,
- realtimeRowsDroppedMeter);
- _numRowsErrored++;
- _numBytesDropped += rowSizeInBytes;
+ boolean stopOnDecodeError = _streamConfig.getStreamConfigsMap()
+ .getOrDefault("stopOnDecodeError",
"false").equalsIgnoreCase("true");
Review Comment:
The configuration parameter 'stopOnDecodeError' is accessed directly as a
string from the stream config map. This approach lacks input validation and
type safety. Consider defining this as a named constant and using a dedicated
configuration property with proper documentation, or add validation to ensure
the value is a valid boolean string.
```suggestion
String stopOnDecodeErrorConfig =
_streamConfig.getStreamConfigsMap().get("stopOnDecodeError");
boolean stopOnDecodeError;
if (stopOnDecodeErrorConfig == null) {
// Default behavior when config is not provided: do not stop on
decode error.
stopOnDecodeError = false;
} else if ("true".equalsIgnoreCase(stopOnDecodeErrorConfig)) {
stopOnDecodeError = true;
} else if ("false".equalsIgnoreCase(stopOnDecodeErrorConfig)) {
stopOnDecodeError = false;
} else {
// Invalid value; log and fall back to default to avoid silent
misconfiguration.
_segmentLogger.warn("Invalid value '{}' for configuration
'stopOnDecodeError'; "
+ "expected 'true' or 'false'. Defaulting to 'false'.",
stopOnDecodeErrorConfig);
stopOnDecodeError = false;
}
```
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeSegmentDataManager.java:
##########
@@ -630,13 +634,22 @@ private boolean processStreamEvents(MessageBatch
messageBatch, long idlePipeSlee
StreamPartitionMsgOffset nextOffset = metadata.getNextOffset();
int rowSizeInBytes = metadata.getRecordSerializedSize();
if (decodedRow.getException() != null) {
- // TODO: based on a config, decide whether the record should be
silently dropped or stop further consumption on
- // decode error
- realtimeRowsDroppedMeter =
- _serverMetrics.addMeteredTableValue(_clientId,
ServerMeter.INVALID_REALTIME_ROWS_DROPPED, 1,
- realtimeRowsDroppedMeter);
- _numRowsErrored++;
- _numBytesDropped += rowSizeInBytes;
+ boolean stopOnDecodeError = _streamConfig.getStreamConfigsMap()
+ .getOrDefault("stopOnDecodeError",
"false").equalsIgnoreCase("true");
+ if (stopOnDecodeError) {
+ String errorMessage = "Stopping consumption due to decode error at
offset: " + offset;
+ _segmentLogger.error(errorMessage, decodedRow.getException());
+ _realtimeTableDataManager.addSegmentError(_segmentNameStr,
+ new SegmentErrorInfo(now(), errorMessage,
decodedRow.getException()));
+ throw new RuntimeException("Stopping consumption due to decode
error", decodedRow.getException());
Review Comment:
The error message is duplicated in three places: the log statement, the
SegmentErrorInfo, and the RuntimeException. Consider extracting this to a
single constant or variable to ensure consistency and easier maintenance.
```suggestion
throw new RuntimeException(errorMessage,
decodedRow.getException());
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]