Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix $by_category processing of "stream deleted" events #1900

Merged
merged 2 commits into from Apr 15, 2019

Conversation

3 participants
@shaan1337
Copy link
Member

commented Mar 25, 2019

The $by_category projection was designed to process "stream deleted" events (obtained from either the stream's metadata stream (checking for $tb) for soft deleted streams or verifying the $streamDeleted event from the stream itself for hard deletions). If such an event was found, it would be emitted to the $ce-<category> stream so that it could be processed on the client side to know the stream was deleted (by verifying the $deleted json property)

A bug in the above process would cause all stream metadata events to be emitted to the $ce-<category> stream instead of only stream deleted events. It is not harmful to have these extra events in the $ce-category but it can be confusing. Furthermore, if the metadata of the stream has changed, these events will appear as broken link tos in the emitted stream (since metadata streams have a max count of 1), causing more confusion.

The following example shows how it can happen with a combination of changing ACLs, the $streams projection and $by_category projection although there are other ways to reproduce it.

Reproduction steps:

  1. Start EventStore with all projections stopped
  2. Create a stream: mycategory-stream by adding an event
  3. Edit ACL of stream mycategory-stream, setting everything to $admins (you can also add custom metadata to the stream, having the same effect)
    This will create the $$mycategory-stream stream with event 0.
  4. Start the $streams projection. This will create 2 events in $streams stream:
    Event 0: Link to 0@mycategory-stream
    Event 1: Link to 0@$$mycategory-stream
  5. Start the $by_category projection. This will create 2 events in $ce-mycategory:
    Event 0: Link to 0@mycategory-stream
    Event 1: Link to 0@$$mycategory-stream <-- This is where the bug lies, the $by_category projection shouldn't have processed this event and emitted a link to $ce-mycategory

Extra steps to make a broken link:
6. Edit the ACL of stream mycategory-stream again (Just save it again)
This will create event 1 in $$mycategory-stream. At this point, 0@$$mycategory-stream is no longer readable (because of max count of 1 on metadata streams)

  1. Go to stream $ce-mycategory
    A broken link will exist to 0@$$mycategory-stream at event 1.

Resolution
Make sure only stream deleted events are emitted to $ce-<category>

@shaan1337 shaan1337 force-pushed the fix-deleted-stream-by-category branch from 021a066 to 76acc41 Mar 25, 2019

@shaan1337 shaan1337 requested a review from jageall Mar 25, 2019

@shaan1337 shaan1337 force-pushed the fix-deleted-stream-by-category branch from 76acc41 to acef0e4 Mar 25, 2019

@shaan1337 shaan1337 changed the title Fix $by_category processing of "stream deleted" metadata events Fix $by_category processing of "stream deleted" events Mar 25, 2019

@jen20 jen20 merged commit 22c57d7 into master Apr 15, 2019

9 checks passed

EventStore.EventStore Build #20190325.3 succeeded
Details
EventStore.EventStore (Centos 7 x64 Debug) Centos 7 x64 Debug succeeded
Details
EventStore.EventStore (Centos 7 x64 Release) Centos 7 x64 Release succeeded
Details
EventStore.EventStore (Ubuntu 14.04 x64 Debug) Ubuntu 14.04 x64 Debug succeeded
Details
EventStore.EventStore (Ubuntu 14.04 x64 Release) Ubuntu 14.04 x64 Release succeeded
Details
EventStore.EventStore (Windows x64 Debug) Windows x64 Debug succeeded
Details
EventStore.EventStore (Windows x64 Release) Windows x64 Release succeeded
Details
EventStore.EventStore (macOS x64 Debug) macOS x64 Debug succeeded
Details
EventStore.EventStore (macOS x64 Release) macOS x64 Release succeeded
Details

@jen20 jen20 deleted the fix-deleted-stream-by-category branch Apr 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.