Copilot commented on code in PR #15976:
URL: https://github.com/apache/pinot/pull/15976#discussion_r2122914097
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeSegmentDataManager.java:
##########
@@ -1057,10 +1058,13 @@ public Map<String, ConsumerPartitionState>
getConsumerPartitionState() {
*/
public Map<String, PartitionLagState> getPartitionToLagState(
Map<String, ConsumerPartitionState> consumerPartitionStateMap) {
- if (_partitionMetadataProvider == null) {
+ StreamMetadataProvider provider = _partitionMetadataProvider.get();
+ if (provider == null) {
createPartitionMetadataProvider("Get Partition Lag State");
+ provider = _partitionMetadataProvider.get();
Review Comment:
Multiple threads may reach this null-check simultaneously and trigger
concurrent calls to createPartitionMetadataProvider. Consider using a
compareAndSet or synchronized block to ensure only one initialization occurs at
a time.
```suggestion
if (_partitionMetadataProvider.compareAndSet(null,
createPartitionMetadataProvider("Get Partition Lag State"))) {
provider = _partitionMetadataProvider.get();
} else {
provider = _partitionMetadataProvider.get();
}
```
--
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]