gravitino: [Improvement] create and alter failed since the operations in catalog are async
What would you like to be improved?
there is a reload action in object (table and topic) alteration and creation, which used to obtain some values generated by the underlying catalog
-
reload table in alteration: https://github.com/datastrato/gravitino/blob/3a973abf63952dc3102b78c0684705ef6cee4dc0/core/src/main/java/com/datastrato/gravitino/catalog/TableOperationDispatcher.java#L234-L242
-
reload topic in creation: https://github.com/datastrato/gravitino/blob/3a973abf63952dc3102b78c0684705ef6cee4dc0/core/src/main/java/com/datastrato/gravitino/catalog/TopicOperationDispatcher.java#L143-L148
The create and alter may be failed since the operations in the catalog are async:
How should we improve?
Here are three solutions I can think of right now:
-
remove the reload action in creation and alteration If we choose to remove the reload operation, then we may need to refactor the API so that the return value is
viod, otherwise it will result in an inconsistency with the manual load -
add await timeout to the reload action If the corresponding operation is not completed after the timeout, whether to return success or failure to the client is a point that needs to be considered.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (8 by maintainers)
Commits related to this issue
- [#4572][#3729][#3496] refactor(core): remove reload action from create and alter schema/table/topic (#4590) ### What changes were proposed in this pull request? Remove reload action and fix the fo... — committed to yuqi1129/gravitino by noidname01 2 years ago
- [#6523] fix(core): Filter null prop when init properties (#6524) ### What changes were proposed in this pull request? Filters out any entries with null keys/values before collection, to prevent pote... — committed to apache/gravitino by TEOTEO520 2 years ago
@mchades Sorry for the inactiveness in this PR. I’ve created a draft PR, I have done the main logic modification, the remaining to-do works is modifying the logic of ITs, which still use reload logic.
@mchades Sure, will work on this and finish ASAP.
I think it’s acceptable, but we should clarify this in the API comment.
yeah. BTW, not only for creating topic, but the table and fileset are also need to bechanged
@mchades Sorry for the late reply, too.
I’ve done some research in how Kafka creates the topics. It seems there’s no difference between
createTopicsResult.all().whenComplete()andcreateTopicsResult.topicId().get(), because the Kafka server will return metadata all at once. And even though the create method returns, the topic also needs to be propagated in Kafka system. So there is an unmeasurable time diff between the time that the create method returns and the time the created topic can be described.To really solve this, I think add retry mechanism on reload action might be a feasible solution. WDYT?
Hi @mchades, I want to try to solve this issue.
I have done some code tracing from
createTopicinTopicOperationDispatcher. I think how about just makecreateTopicsynchronous by using likecreateTopicsResult.all().whenComplete()inKafkaCatalogOperationsand forming newpropertiesjust likeloadTopicimplementation. But it may have some performance issues, so just rewriting reload action to try and timeout is also a common solution. WDYT?