Skip to content

Commit 3390e5c

Browse files
xds: Make timestamp tracking variables volatile in ExternalProcessorClientInterceptor (grpc#13003)
Make timestamp tracking variables volatile in ExternalProcessorClientInterceptor to fix data race reported by TSAN. These fields track timestamps for recording latency metrics. They were being read and written concurrently across multiple threads: The application thread calling the gRPC stub (e.g. start and halfClose). The data plane response thread (e.g., `onHeaders` and `onClose`). The external processor client response thread processing the response callback (e.g. `onNext` which invokes `proceedWithHalfClose`, `proceedWithHeaders`, etc.).
1 parent decc3a1 commit 3390e5c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎xds/src/main/java/io/grpc/xds/ExternalProcessorClientInterceptor.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,10 @@ private static class DataPlaneClientCall
297297
private final String backendService;
298298
private volatile Context callContext = Context.ROOT;
299299

300-
private long clientHeadersStartNanos;
301-
private long clientHalfCloseStartNanos;
302-
private long serverHeadersStartNanos;
303-
private long serverTrailersStartNanos;
300+
private volatile long clientHeadersStartNanos;
301+
private volatile long clientHalfCloseStartNanos;
302+
private volatile long serverHeadersStartNanos;
303+
private volatile long serverTrailersStartNanos;
304304

305305
private boolean protocolConfigSent = false;
306306
private ImmutableMap<String, Struct> collectedAttributes;

0 commit comments

Comments
 (0)