jtuglu-netflix commented on code in PR #17847:
URL: https://github.com/apache/druid/pull/17847#discussion_r2094783233
##########
server/src/main/java/org/apache/druid/segment/realtime/SegmentGenerationMetrics.java:
##########
@@ -55,6 +55,65 @@ public class SegmentGenerationMetrics
private final AtomicLong maxSegmentHandoffTime = new
AtomicLong(NO_EMIT_SEGMENT_HANDOFF_TIME);
+ public static class MessageGapStats
+ {
+ long minMessageGap = Long.MAX_VALUE;
+ long maxMessageGap = Long.MIN_VALUE;
+ long numMessageGap = 0;
+ double totalMessageGap = 0;
+
+ public synchronized double avgMessageGap()
Review Comment:
Yeah, since the reference only guards access to the pointer to the object
itself, you don't get mutual exclusion assurances on operations within that
object (why the only "thread-safe" pattern for writes with AtomicReference is a
new object creation every time, which is slow; slower than a plain 'ol lock in
hot loop). Even with a `getAndUpdate` that would just affect the pointer to the
object, not the object itself, hence why I added the `synchronize` annotations
to avoid
([this](https://github.com/apache/druid/pull/17847#discussion_r2094612845)).
The case I mentioned above should only happen on a single reporting call.
--
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]