RATIS-2497. Pass server to the dummy watch request in OrderedAsync#1438
RATIS-2497. Pass server to the dummy watch request in OrderedAsync#1438szetszwo merged 2 commits intoapache:masterfrom
Conversation
| return TraceClient.asyncSend( | ||
| () -> client.getOrderedAsync().send(type, message, server), type, server); | ||
| () -> client.getOrderedAsync(server).send(type, message, server), type, server); |
There was a problem hiding this comment.
Currently, if the server is not a leader, it will throw NotLeaderException since watchAsync calls checkLeaderState. This might cause AsyncStreamObservers#completeReplyExceptionally which will trigger client to invalidate all the pending replies.
One idea is to allow follower to accept the watch request if the RaftClientRequest serverId matches, but currently WatchRequests is stored in the LeaderStateImpl. So we might want to make WATCH(0) to be a special "bootstrap" request that can be handled by follower, otherwise the watch should throw NotLeaderException to preserve the watch semantics.
Also, could you help to add some tests to test to behavior similar to #1433? Set the dummy request to true for LinearizableReadTests should be enough.
There was a problem hiding this comment.
... watchAsync calls checkLeaderState ...
You are right -- we should use staleRead instead.
There was a problem hiding this comment.
... Set the dummy request to true for LinearizableReadTests should be enough.
Sure. Let me include the change.
@ivandika3 , Tried to set a special minIndex (e.g. Long.MAX_VALUE/MIN_VALUE) to staleRead but it became an incompatible change since users might also set it. Then, found that watch request passed a null message and users could not set it. So, we may send a watch request with a "DUMMY" message. The server can detect it and return immediately without leader check. LinearizableReadTests can pass. |
|
@szetszwo Thanks for the patch. LGTM +1.
Yes, we should not use
This is a good workaround.
Thanks, do you think we should include tests like |
|
@OneSizeFitsQuorum Would you like to take a look? |
|
LGTM~ |
|
@ivandika3 , @OneSizeFitsQuorum , thanks for reviewing this!
|
See RATIS-2497