messaging: move topic handling to vtgate#5181
messaging: move topic handling to vtgate#5181derekperkins wants to merge 1 commit intovitessio:masterfrom
Conversation
Signed-off-by: Derek Perkins <derek@derekperkins.com>
|
Another benefit of registering topic tables in the vschema is that they aren't reliant on a subscriber. In the current design, a topic is created only when at least one subscriber is subscribed, meaning that if the last subscription was removed, it would break anyone publishing to the topic. The correct behavior would be to just return early and successfully if there are no subscribers. |
|
We just stumbled onto another flaw with the current implementation. We often use sequences to generate message table ids, but that no longer functions correctly. |
|
This changes the nature of the feature quite a bit. We should first look at undoing #5011. That will keep the vttablet code more maintainable. We also have to consider other issues related to this approach. The big one is: what about transactions. If you don't enable 2PC, then messages can get lost. As for filtering, I think we can apply what we learned from vreplication. Specify the filtering rule as a select statement, which leads us to the inevitable question: Could this be achieved through vreplication? The topic would be a physical table, and messages would become vreplication targets. This will guarantee that no messages will be lost. However, there is some write amplification because the topic becomes a physical table, and it needs to be purged also. |
|
I would definitely revert most of #5011 as a part of this change, but we're already using that style of topics, so we would want a replacement merged before removing the older style of topics. I REALLY like the idea of doing it via vreplication: PRO:
CON:
I think we should definitely move forward with this powered by vreplication. I think that the configuration should still live in the vschema, so I believe that the design of this PR is still a step in the right direction. |
|
Clsoing this. We've agreed to use the vreplication route. Also, we're leaning towards a separate place to store this type of metadata as the vschema is mainly used for routing requests. |
I think the design of topics as implemented in #5011 is flawed. Topics are handled at the vttablet level, which has two use cases that cause unexpected data loss and cannot be fixed at the tablet layer:
IMO, the correct solution should be handled at vtgate, where it can fanout inserts across keyspaces and maintain data integrity regardless of sharding columns. This has a further benefit of taking a burden off of vttablet, which will come into play as we add more advanced features like subscription filtering (#5180).
In this PR, I am proposing new vschema fields/messages to describe these subscriptions. I have also included a rough draft for what subscription filters might look like, to support the need for subscriptions to live in the vschema. The actual proto definition and implementation details are out of the scope of this PR. I will remove all these fields once the overall design is approved.