patchlevel / event-sourcing

An event sourcing library, complete with all the essential features, powered by the reliable Doctrine ecosystem and focused on developer experience.
https://event-sourcing.patchlevel.io
MIT License
116 stars 4 forks source link

move event bus dispatch outside of repository transaction #587

Closed DavidBadura closed 1 month ago

DavidBadura commented 1 month ago

Event Bus dispatching was in the transaction because we implemented the outbox pattern. Since we now offer the subscription engine, we have removed the outbox. Therefore, the dispatch in a transaction is no longer necessary.

On the contrary: the transaction makes implementations more difficult. If an error occurs in the listener, the transaction would take effect and rollback. This means that actions that happened on the same connection will be rollback, but other actions such as sending emails and changes in mongodb / elastic search would remain as before. The transaction also prevents us from triggering the subscription engine synchronously.

github-actions[bot] commented 1 month ago

Hello :wave:

here is the most recent benchmark result:

``` SplitStreamBench ================ +-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ | | time (kde mode) | memory | +-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ | subject | Tag: | Tag: base | time-diff | Tag: | Tag: base | memory-diff | +-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ | benchLoad10000Events () | 4.861ms (±0.00%) | 4.803ms (±0.00%) | +1.22% | 37.573mb | 37.578mb | -0.02% | | benchSave10000Events () | 345.000ms (±0.00%) | 355.158ms (±0.00%) | -2.86% | 37.573mb | 37.070mb | +1.36% | +-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ SimpleSetupBench ================ +----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ | | time (kde mode) | memory | +----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ | subject | Tag: | Tag: base | time-diff | Tag: | Tag: base | memory-diff | +----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ | benchLoad1Event () | 945.400μs (±0.00%) | 939.300μs (±0.00%) | +0.65% | 33.762mb | 33.762mb | -0.00% | | benchLoad10000Events () | 49.581ms (±0.00%) | 50.398ms (±0.00%) | -1.62% | 33.763mb | 33.763mb | -0.00% | | benchSave1Event () | 1.255ms (±0.00%) | 998.000μs (±0.00%) | +25.74% | 33.762mb | 33.762mb | -0.00% | | benchSave10000Events () | 217.075ms (±0.00%) | 215.781ms (±0.00%) | +0.60% | 33.764mb | 33.764mb | -0.00% | | benchSave10000Aggregates () | 8.504s (±0.00%) | 8.346s (±0.00%) | +1.90% | 33.763mb | 33.763mb | -0.00% | | benchSave10000AggregatesTransaction () | 6.910s (±0.00%) | 6.828s (±0.00%) | +1.21% | 33.763mb | 33.763mb | -0.00% | +----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ SnapshotsBench ============== +----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ | | time (kde mode) | memory | +----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ | subject | Tag: | Tag: base | time-diff | Tag: | Tag: base | memory-diff | +----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ | benchLoad10000EventsMissingSnapshot () | 51.098ms (±0.00%) | 48.879ms (±0.00%) | +4.54% | 33.763mb | 33.763mb | -0.00% | | benchLoad10000Events () | 899.300μs (±0.00%) | 881.900μs (±0.00%) | +1.97% | 33.763mb | 33.763mb | -0.00% | +----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ PersonalDataBench ================= +----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ | | time (kde mode) | memory | +----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ | subject | Tag: | Tag: base | time-diff | Tag: | Tag: base | memory-diff | +----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ | benchLoad1Event () | 878.500μs (±0.00%) | 853.200μs (±0.00%) | +2.97% | 34.892mb | 34.892mb | -0.00% | | benchLoad10000Events () | 83.239ms (±0.00%) | 81.957ms (±0.00%) | +1.56% | 34.892mb | 34.892mb | -0.00% | | benchSave1Event () | 1.468ms (±0.00%) | 1.427ms (±0.00%) | +2.93% | 34.892mb | 34.892mb | -0.00% | | benchSave10000Events () | 249.039ms (±0.00%) | 240.391ms (±0.00%) | +3.60% | 34.894mb | 34.894mb | -0.00% | | benchSave10000Aggregates () | 12.564s (±0.00%) | 12.286s (±0.00%) | +2.27% | 34.892mb | 34.893mb | -0.00% | | benchSave10000AggregatesTransaction () | 11.071s (±0.00%) | 10.866s (±0.00%) | +1.89% | 35.394mb | 35.394mb | -0.00% | +----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+ SubscriptionEngineBench ======================= +---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+ | | time (kde mode) | memory | +---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+ | subject | Tag: | Tag: base | time-diff | Tag: | Tag: base | memory-diff | +---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+ | benchHandle10000Events () | 3.131s (±0.00%) | 3.123s (±0.00%) | +0.25% | 34.162mb | 34.162mb | -0.00% | +---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+ ```

This comment gets update everytime a new commit comes in!