Commit 2ce0744
authored
test(spanner): unflake EndpointLifecycleManagerTest requestEndpointRecreationSkippedWhenAddressNotActive (#14474)
In EndpointLifecycleManagerTest,
requestEndpointRecreationSkippedWhenAddressNotActive registers two
addresses concurrently ("server1", "server2"). EndpointLifecycleManager
dispatches background endpoint creation tasks across its 2-thread
scheduler, which concurrently invoked get() on the test double
FakeEndpointCache.
Because FakeEndpointCache stored endpoints in an unsynchronized
java.util.HashMap (unlike production GrpcChannelEndpointCache, which
uses ConcurrentHashMap), concurrent computeIfAbsent() calls on the
uninitialized map raced inside HashMap.resize(), silently dropping one
of the endpoints and causing awaitCondition to time out after 5s.
Fix:
- Use ConcurrentHashMap in FakeEndpointCache to match production channel
cache behavior.
- Mark mutable state fields in FakeEndpoint and FakeManagedChannel
volatile.
- Add regression test
concurrentBackgroundEndpointCreationDoesNotLoseEndpoints in
EndpointLifecycleManagerTest.1 parent 1db9757 commit 2ce0744
1 file changed
Lines changed: 5 additions & 5 deletions
File tree
- java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | 42 | | |
44 | 43 | | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
1925 | 1925 | | |
1926 | 1926 | | |
1927 | 1927 | | |
1928 | | - | |
| 1928 | + | |
1929 | 1929 | | |
1930 | | - | |
| 1930 | + | |
1931 | 1931 | | |
1932 | 1932 | | |
1933 | 1933 | | |
| |||
1977 | 1977 | | |
1978 | 1978 | | |
1979 | 1979 | | |
1980 | | - | |
| 1980 | + | |
1981 | 1981 | | |
1982 | 1982 | | |
1983 | 1983 | | |
| |||
2042 | 2042 | | |
2043 | 2043 | | |
2044 | 2044 | | |
2045 | | - | |
| 2045 | + | |
2046 | 2046 | | |
2047 | 2047 | | |
2048 | 2048 | | |
| |||
0 commit comments