ivandika3 commented on PR #1707: URL: https://github.com/apache/ratis/pull/1707#issuecomment-7154971616
Thanks @amaliujia for further reviews. > I'm concerned that readIndexAsync idea in this PR moves the linearizability contract from Ratis to every embedded caller: applications must query after the barrier, on the same division Yes, this is a valid concern since now the job of doing linearizable read is in the application and therefore can be misused by the application. However, this seems to be the way other systems like etcd implemented it so there is a precedence. The javadoc already specifies the guarantees of this API. I understand that this issue breaks the Raft encapsulation (althought internal logic like the actual readindex propagation and waiting for application is still handled by Ratis), but I believe this is the current best way to be flexibility and improves the performance profile. > against live state (not cache), and must handle a snapshot install happens in between. The current OM read already checks the cache which will be invalidated if it's already been applied to RocksDB. There should not be any extra logic needed to handle this. For snapshot install, even the previous readOnlyAsync does not handle cases where there is a snapshot install in `StateMachine#query` > Ratis can no longer enforce any of these. The returned Long also exposes a log index that callers might misuse (as it is just a number not a proto). Yes, misuse is possible, but changing it to protobuf does not really enforces anything and can introduce additional serde overhead. > The root cause in [RATIS-2831](https://issues.apache.org/jira/browse/RATIS-2831) is that thenCompose runs the query on the thread who completes the ReadIndex future. Could we fix that while keeping the read inside Ratis? > For example, replace the API to readOnlyAsync(clientId, type, query, Executor), which then uses thenComposeAsync? Per my understanding, now the gRPC thread bottleneck you mentioned is migrated off: the gRPC threads only need to do a lightweight submit, and the real query happens in the provided executor which is designed by the applications? I have thought about passing an executor and this would technically work. However, this requires us to create and manage another ReadIndex executor (or we can reuse one of the Ratis executors). This has an overhead of handing off to another set of executors instead of actually running it in the RPC threads, such as the handoff overhead, Java async scheduling, low level things like cache locality. Another issue is that this executor needs to be sized accordingly (e.g. we have to size it to the number RPC threads). In Ozone OM, the OM leader simply reads from the local read without handing off anything and this makes the read performance of leader read superior than anything that has to go through Ratis. I wanted to close this gap as much as possible. Hope this clarifies. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
