fix(spanner): fix flakiness and race conditions in multiplexed session tests#12949
fix(spanner): fix flakiness and race conditions in multiplexed session tests#12949sakthivelmanii merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new helper method, ofMinimumAndRandomTimeAndStickyException, in MockSpannerServiceImpl to simulate RPC delays alongside persistent exceptions. Corresponding tests in MultiplexedSessionDatabaseClientMockServerTest were updated to utilize this method. Feedback suggests replacing the magic number 200 with a named constant for better clarity and considering a more targeted reset of execution times instead of using the broad removeAllExecutionTimes() method.
| mockSpanner.setCreateSessionExecutionTime( | ||
| SimulatedExecutionTime.ofStickyException(Status.DEADLINE_EXCEEDED.asRuntimeException())); | ||
| SimulatedExecutionTime.ofMinimumAndRandomTimeAndStickyException( | ||
| 200, 0, Status.DEADLINE_EXCEEDED.asRuntimeException())); |
There was a problem hiding this comment.
| // The CreateSession RPC will be retried, and as the exception is removed by the first call, | ||
| // The CreateSession RPC will be retried, and as we manually clear the exception, | ||
| // the second attempt will succeed. | ||
| mockSpanner.removeAllExecutionTimes(); |
There was a problem hiding this comment.
The use of removeAllExecutionTimes() is quite broad as it clears all simulated execution times for all RPC methods. While safe in this specific test context, consider using a more targeted reset (e.g., setCreateSessionExecutionTime(null)) if available, to avoid unintended side effects in more complex test scenarios where other RPCs might have configured behaviors.
e55d353 to
15b11ed
Compare
| } | ||
|
|
||
| private void maybeFreezeAndRecordRequest(AbstractMessage request) { | ||
| synchronized (lock) { |
There was a problem hiding this comment.
(Probably does not matter much, but still): Do you really need to take the lock here?
15b11ed to
acc5b8c
Compare
No description provided.