"targetWriter" is a method parameter, and should not be used for synchronization.
- Lingua principale
- Java
- Stelle
- 6.4k
- Fork
- 1.2k
- Merge medio
- 1g 23h
- PR unite (30g)
- 115
Descrizione
Code Path:server/src/main/java/org/apache/iotdb/db/engine/compaction/writer/AbstractCompactionWriter.java
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.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia in server/src/main/java/org/apache/iotdb/db/engine/compaction/writer/AbstractCompactionWriter.java e analizza il metodo che usa targetWriter per la sincronizzazione. Verifica come chiamate concorrenti possano ricevere istanze diverse del parametro. Il lavoro è completato quando la sincronizzazione non dipende più da quel parametro del metodo e il comportamento esistente rimane sicuro per le chiamate concorrenti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java
- Ambito
- databases
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100