"targetWriter" is a method parameter, and should not be used for synchronization.
- Langage dominant
- Java
- Étoiles
- 6.4k
- Forks
- 1.2k
- Merge moyen
- 1 j 23 h
- PR mergées (30 j)
- 115
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez dans server/src/main/java/org/apache/iotdb/db/engine/compaction/writer/AbstractCompactionWriter.java et examinez la méthode qui utilise targetWriter pour la synchronisation. Confirmez comment des appels concurrents peuvent recevoir différentes instances du paramètre. La tâche est terminée lorsque la synchronisation ne dépend plus de ce paramètre de méthode et que le comportement existant reste sûr pour les appels concurrents.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java
- Domaine
- databases
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100