VGalaxies commented on PR #13032: URL: https://github.com/apache/iotdb/pull/13032#issuecomment-2254929606
Explain why the `onEventInternal` method needs to be synchronized; otherwise, it may cause event loss. Consider two threads, A and B, both blocking at the `batch.onEvent(event)` call. When thread A calls `batch.onEvent(event)` and the returned events are not empty, it indicates that this batch has already been sealed. At this point, when thread B call `batch.onEvent(event)`, the returned events are empty. Note that the event corresponding to thread B has not entered tht batch. **If thread B's return in `getAndUpdate` executes earlier than thread A**, thread B's `getAndUpdate` will mistakenly believe that the event corresponding to thread B has already entered the batch, causing event loss. -- 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]
