iotdb icon indicating copy to clipboard operation
iotdb copied to clipboard

"targetWriter" is a method parameter, and should not be used for synchronization.

Open MinaQin opened this issue 3 years ago • 1 comments

Code Path:server/src/main/java/org/apache/iotdb/db/engine/compaction/writer/AbstractCompactionWriter.java image Synchronizing on a class field synchronizes not on the field itself, but on the object assigned to it. So synchronizing on a non-final field makes it possible for the field’s value to change while a thread is in a block synchronized on the old value. That would allow a second thread, synchronized on the new value, to enter the block at the same time.

The story is very similar for synchronizing on parameters; two different threads running the method in parallel could pass two different object instances in to the method as parameters, completely undermining the synchronization.

MinaQin avatar May 12 '22 11:05 MinaQin

i will try my best to do it,please assign to me

mroccyen avatar Sep 13 '22 02:09 mroccyen