"targetWriter" is a method parameter, and should not be used for synchronization.
- Vorherrschende Sprache
- Java
- Sterne
- 6.4k
- Forks
- 1.2k
- Ø Merge
- 1 T. 23 Std.
- Gemergte PRs (30 T.)
- 115
Beschreibung
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.
Beitragsleitfaden
Rechercherichtung
Beginne in server/src/main/java/org/apache/iotdb/db/engine/compaction/writer/AbstractCompactionWriter.java und untersuche die Methode, die targetWriter zur Synchronisierung verwendet. Bestätige, wie nebenläufige Aufrufe unterschiedliche Parameterinstanzen erhalten können. Die Aufgabe ist abgeschlossen, wenn die Synchronisierung nicht mehr von diesem Methodenparameter abhängt und das bestehende Verhalten bei nebenläufigen Aufrufen weiterhin sicher ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- databases
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100