Skip to content

Commit 26c2ce0

Browse files
Correctly synchronize RecoveryState#Translog internal state (#81528)
* Correctly synchronize RecoveryState#Translog internal state We must synchronize all access to the internal state, otherwise there's no read/write memory barriers when deserializing/serialize the state from the wire. * Remove synchronization from the constructor Co-authored-by: Elastic Machine <[email protected]>
1 parent e421477 commit 26c2ce0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

server/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,12 @@ public Translog(StreamInput in) throws IOException {
486486
@Override
487487
public void writeTo(StreamOutput out) throws IOException {
488488
super.writeTo(out);
489-
out.writeVInt(recovered);
490-
out.writeVInt(total);
491-
out.writeVInt(totalOnStart);
492-
out.writeVInt(totalLocal);
489+
synchronized (this) {
490+
out.writeVInt(recovered);
491+
out.writeVInt(total);
492+
out.writeVInt(totalOnStart);
493+
out.writeVInt(totalLocal);
494+
}
493495
}
494496

495497
public synchronized void reset() {

0 commit comments

Comments
 (0)