Jackie-Jiang commented on code in PR #12794:
URL: https://github.com/apache/pinot/pull/12794#discussion_r1559881321
##########
pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/memory/unsafe/DirectMemory.java:
##########
@@ -55,23 +54,18 @@ public void flush() {
}
@Override
- public void close()
- throws IOException {
+ public synchronized void close() {
if (!_closed) {
- synchronized (this) {
- if (!_closed) {
- Unsafer.UNSAFE.freeMemory(_address);
- _closed = true;
- }
- }
+ Unsafer.UNSAFE.freeMemory(_address);
Review Comment:
Why would multiple threads trying to close the same buffer? If that happens,
that means the buffer ownership is messed up. In regular case, this method
should only be invoked exactly once.
I think double-checked locking might have performance gain when used in a
singleton, but not here
--
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]