Skip to content

Subscription: adapt pipe completion signal for automatically drop subscription#12647

Closed
VGalaxies wants to merge 37 commits intoapache:masterfrom
VGalaxies:sub-drop
Closed

Subscription: adapt pipe completion signal for automatically drop subscription#12647
VGalaxies wants to merge 37 commits intoapache:masterfrom
VGalaxies:sub-drop

Conversation

@VGalaxies
Copy link
Contributor

@VGalaxies VGalaxies commented Jun 3, 2024

  • Add topic parameter mode
    • query
    • subscribe
  • When to commit PipeTerminateEvent
    • After the DN-side subscription sink receives the PipeTerminateEvent, it reduces the reference count and commits directly, marking the corresponding pipe task as complete.
  • How to notify the client
    • When the pipe is automatically dropped and the prefetching queue is unbound, the corresponding prefetching queue is marked as complete (unbind).
    • When the client pulls from a prefetching queue marked as complete, it will get an event containing a TerminationPayload. The client will automatically unsubscribe from the topic of this event.
  • How to release resources
    • Upon all associated consumers unsubscribing from the associated topic, reclaim the corresponding prefetching queue (remove).
    • Until all consumers unsubscribe from that topic, all prefetching queues on all DN remain.

Example: org.apache.iotdb.SubscriptionSessionExample#dataSubscription3, org.apache.iotdb.SubscriptionSessionExample#dataSubscription4

@VGalaxies VGalaxies marked this pull request as draft June 3, 2024 13:00
@VGalaxies VGalaxies marked this pull request as ready for review June 4, 2024 01:12
@SteveYurongSu SteveYurongSu self-requested a review June 4, 2024 01:40
@SteveYurongSu SteveYurongSu self-assigned this Jun 4, 2024
topicNames,
topicNameToUnsubscribe,
commitContext.getDataNodeId());
unsubscribe(topicNameToUnsubscribe);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that since the pipe is automatically dropped, the "DropPipeProcedure"s in "DropSubscriptionProcedure" will encounter failure in validation... Need to add some checks or else the procedure will fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In DropPipeProcedureV2, no exception will be occurred even if the pipe does not exist...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, checked that there are not.... However there will be a warn log in PipeDataNodeRemainingEventAndTimeMetrics#deregister. Can you remove it incidentally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, checked that there are not.... However there will be a warn log in PipeDataNodeRemainingEventAndTimeMetrics#deregister. Can you remove it incidentally?

added a boolean return value to dropPipe...


@Override
protected void rollbackFromOperateOnDataNodes(ConfigNodeProcedureEnv env) throws IOException {
protected void rollbackFromOperateOnDataNodes(final ConfigNodeProcedureEnv env)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 3 points for the rollback function:

  1. Usually when we do rollback, we roll back from the last executed to the first executed.
  2. We do not rollback DataNode and ConfigNode execution of dropping pipe.
  3. Whether the drop subscription procedure needs to be rolled back may need to be considered twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually when we do rollback, we roll back from the last executed to the first executed.

The DropSubscriptionProcedure has been appropriately modified. The CreateSubscriptionProcedure will be modified in subsequent metadata restructuring.

Whether the drop subscription procedure needs to be rolled back may need to be considered twice.

Before metadata restructuring, considering that the process of changing the topic meta and consumer group meta involves multiple procedures, there could be failures during execution. Therefore, it is currently necessary to consider rolling back part of the procedure to ensure CN metadata consistency.

In the subsequent metadata restructuring, we will consider mapping the drop subscription procedure to a single procedure. At that time we can consider not performing rollback to prevent the occurrence of create subscription after the rollback of drop subscription.


public class SubscriptionTerminationException extends SubscriptionRuntimeCriticalException {

public SubscriptionTerminationException(final String message) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider whether to use it before merge.

@VGalaxies VGalaxies changed the title Subscription: adapt pipe completion signal for automatically drop subscription Subscription: adapt pipe completion signal for automatically drop subscription & improve parsing logic when using JAVA SDK client Jun 7, 2024
@VGalaxies VGalaxies changed the title Subscription: adapt pipe completion signal for automatically drop subscription & improve parsing logic when using JAVA SDK client Subscription: adapt pipe completion signal for automatically drop subscription Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants