Skip to content

add subscription cleanup feature#807

Merged
DavidBadura merged 4 commits into3.17.xfrom
subscriber-cleanup-hook
Feb 12, 2026
Merged

add subscription cleanup feature#807
DavidBadura merged 4 commits into3.17.xfrom
subscriber-cleanup-hook

Conversation

@DavidBadura
Copy link
Member

@DavidBadura DavidBadura commented Jan 13, 2026

closes #806

Add an alternative way to clean up subscriptions without requiring the subscriber to still exist in the code.

When creating a subscription, the engine checks if a cleanup method exists. If so, it is called, and the cleanup tasks, along with other metadata, are stored in the subscription store. When the subscriber is removed, instead of executing the teardown method, the tasks from the store are used, and the corresponding handlers are called. This eliminates the need for the subscriber code itself. By default, we have added two tasks for Doctrine/dbal: DropTableTask and DropIndexTask. It is extensible. Users can also create their own tasks and handlers, for example, if they are using MongoDB.

@DavidBadura DavidBadura added this to the 3.16.0 milestone Jan 13, 2026
@DavidBadura DavidBadura added the enhancement New feature or request label Jan 13, 2026
@github-actions
Copy link

github-actions bot commented Jan 13, 2026

Hello 👋

here is the most recent benchmark result:

SubscriptionEngineBench
=======================

+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+
|                           | time (kde mode)                               | memory                                     |
+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+
| subject                   | Tag: <current>  | Tag: base       | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+
| benchHandle10000Events () | 3.284s (±0.00%) | 3.299s (±0.00%) | -0.43%    | 47.489mb        | 48.005mb   | -1.07%      |
+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+

SimpleSetupBench
================

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad1Event ()                     | 1.024ms (±0.00%)   | 1.022ms (±0.00%)   | +0.22%    | 34.976mb        | 34.976mb   | 0.00%       |
| benchLoad10000Events ()                | 61.131ms (±0.00%)  | 60.883ms (±0.00%)  | +0.41%    | 34.977mb        | 34.977mb   | 0.00%       |
| benchSave1Event ()                     | 1.188ms (±0.00%)   | 1.170ms (±0.00%)   | +1.56%    | 34.976mb        | 34.976mb   | 0.00%       |
| benchSave10000Events ()                | 221.849ms (±0.00%) | 222.980ms (±0.00%) | -0.51%    | 34.977mb        | 34.977mb   | 0.00%       |
| benchSave10000Aggregates ()            | 7.903s (±0.00%)    | 8.184s (±0.00%)    | -3.43%    | 34.977mb        | 34.977mb   | 0.00%       |
| benchSave10000AggregatesTransaction () | 5.280s (±0.00%)    | 5.277s (±0.00%)    | +0.06%    | 34.977mb        | 34.977mb   | 0.00%       |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

CommandToQueryBench
===================

+----------------+------------------+------------------+-----------+-----------------+------------+-------------+
|                | time (kde mode)                                 | memory                                     |
+----------------+------------------+------------------+-----------+-----------------+------------+-------------+
| subject        | Tag: <current>   | Tag: base        | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------+------------------+------------------+-----------+-----------------+------------+-------------+
| benchCreate () | 3.104ms (±0.00%) | 3.113ms (±0.00%) | -0.30%    | 4.904mb         | 4.945mb    | -0.83%      |
| benchUpdate () | 3.998ms (±0.00%) | 3.792ms (±0.00%) | +5.44%    | 4.974mb         | 4.945mb    | +0.58%      |
| benchBoth ()   | 7.234ms (±0.00%) | 6.853ms (±0.00%) | +5.57%    | 4.975mb         | 5.066mb    | -1.79%      |
+----------------+------------------+------------------+-----------+-----------------+------------+-------------+

SnapshotsBench
==============

+----------------------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                   | memory                                     |
+----------------------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>    | Tag: base         | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
| benchLoad10000EventsMissingSnapshot () | 59.272ms (±0.00%) | 60.066ms (±0.00%) | -1.32%    | 34.981mb        | 34.981mb   | 0.00%       |
| benchLoad10000Events ()                | 1.244ms (±0.00%)  | 1.244ms (±0.00%)  | +0.02%    | 34.981mb        | 34.981mb   | 0.00%       |
+----------------------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+

SplitStreamBench
================

+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                         | time (kde mode)                                     | memory                                     |
+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                 | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad10000Events () | 5.342ms (±0.00%)   | 5.298ms (±0.00%)   | +0.84%    | 35.581mb        | 35.581mb   | 0.00%       |
| benchSave10000Events () | 335.056ms (±0.00%) | 338.897ms (±0.00%) | -1.13%    | 35.584mb        | 35.583mb   | +0.00%      |
+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

SimpleSetupStreamStoreBench
===========================

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad1Event ()                     | 1.151ms (±0.00%)   | 1.165ms (±0.00%)   | -1.26%    | 35.138mb        | 35.138mb   | 0.00%       |
| benchLoad10000Events ()                | 68.565ms (±0.00%)  | 66.213ms (±0.00%)  | +3.55%    | 35.138mb        | 35.138mb   | 0.00%       |
| benchSave1Event ()                     | 1.175ms (±0.00%)   | 1.174ms (±0.00%)   | +0.08%    | 35.138mb        | 35.138mb   | 0.00%       |
| benchSave10000Events ()                | 283.590ms (±0.00%) | 283.408ms (±0.00%) | +0.06%    | 35.138mb        | 35.138mb   | 0.00%       |
| benchSave10000Aggregates ()            | 8.124s (±0.00%)    | 8.153s (±0.00%)    | -0.36%    | 35.138mb        | 35.138mb   | 0.00%       |
| benchSave10000AggregatesTransaction () | 5.387s (±0.00%)    | 5.425s (±0.00%)    | -0.71%    | 35.138mb        | 35.138mb   | 0.00%       |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

PersonalDataBench
=================

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad1Event ()                     | 1.096ms (±0.00%)   | 1.099ms (±0.00%)   | -0.23%    | 35.582mb        | 35.582mb   | 0.00%       |
| benchLoad10000Events ()                | 94.790ms (±0.00%)  | 92.197ms (±0.00%)  | +2.81%    | 35.582mb        | 35.582mb   | 0.00%       |
| benchSave1Event ()                     | 1.680ms (±0.00%)   | 1.698ms (±0.00%)   | -1.09%    | 35.582mb        | 35.582mb   | 0.00%       |
| benchSave10000Events ()                | 249.899ms (±0.00%) | 250.461ms (±0.00%) | -0.22%    | 35.655mb        | 35.655mb   | 0.00%       |
| benchSave10000Aggregates ()            | 12.478s (±0.00%)   | 12.405s (±0.00%)   | +0.59%    | 35.582mb        | 35.582mb   | 0.00%       |
| benchSave10000AggregatesTransaction () | 9.642s (±0.00%)    | 9.656s (±0.00%)    | -0.14%    | 36.041mb        | 36.041mb   | 0.00%       |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

SubscriptionEngineBatchBench
============================

+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
|                           | time (kde mode)                                   | memory                                     |
+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
| subject                   | Tag: <current>    | Tag: base         | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
| benchHandle10000Events () | 85.214ms (±0.00%) | 80.453ms (±0.00%) | +5.92%    | 35.476mb        | 35.476mb   | 0.00%       |
+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+

This comment gets update everytime a new commit comes in!

@DavidBadura DavidBadura force-pushed the subscriber-cleanup-hook branch from 6c88df2 to 3796db9 Compare January 14, 2026 09:46
@DanielBadura DanielBadura removed this from the 3.16.0 milestone Feb 10, 2026
@DavidBadura DavidBadura changed the base branch from 3.16.x to 3.17.x February 11, 2026 12:31
@DavidBadura DavidBadura added this to the 3.17.0 milestone Feb 11, 2026
@DavidBadura DavidBadura force-pushed the subscriber-cleanup-hook branch from efef5a8 to 8258f60 Compare February 11, 2026 12:34
@DavidBadura DavidBadura marked this pull request as ready for review February 11, 2026 12:41
Copy link
Member

@DanielBadura DanielBadura left a comment

Choose a reason for hiding this comment

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

LGTM, maybe add some more tests as we have on the diff only a coverage of 40%. That is pretty low

@DavidBadura DavidBadura merged commit dd900c2 into 3.17.x Feb 12, 2026
40 of 41 checks passed
@DavidBadura DavidBadura deleted the subscriber-cleanup-hook branch February 12, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

2 participants