We’re trying to figure out what the best approach will be for us to handle modifying projections once our system has gone live for the cases of handling bug fixes or enhancements.
We currently have a stream for events (source code commit messages and metadata), let’s call it Commits.
If a commit messages contains a pattern like S-12345 or D-98765 then a projection named CommitsLink uses linkTo(‘workitem-S-12345’, event) or linkTo(‘workitem-D-98765’). Then, another system, which has the context of S-12345 or D-98765 already, simply queries these streams. That part is working just fine.
We made a mistake in not at first accounting for messages like “S-12345 and D-98765 and T-77886”. That is, a single commit message that mentions 3 distinct workitems.
We corrected the logic in our development branch and everything is fine. We’ve already got a semi-production deployment though that we’ve pumped data into, and thus all commits that have more than one item mentioned, are just having the 0th linkTo()ed now.
Does the following sound like a legitimate approach to handle “upgrading” the system?
- Before modifying the existing CommitsLink projection, create a new projection, CommitsLinkHistoricalFixUp, which pays attention to the sequenceNumber value that events have, and passes over all the existing events, and for ones that fall into a range for the sequenceNumber, then simply links the 2nd - N mentions, ignoring the 1st, since we know that’s already been handled by the existing projection
- Stop the CommitsLinkHistoricalFixUp projection now that it has handled all historically missed events
- Modify the CommitsLink projection to have the new code from the corrected version in our development branch
- Now, I suppose both could co-exist forever, but that makes the system more difficult to understand later for other developers
- Check whether any events came in after we stopped the CommitsLinkHistoricalFixUp and rectified the CommitsLink projection
- If so, modify the range inside this projection and re-run it to handle those missed events.
- I suppose there might still be a change of missing events, but it seems pretty low in our case and current throughput
- And, it seems like inspecting the Position value in the projection meta-data will help mitigate this anyway.
Example event:
data: {message: “Implemented styling for the apply button. close:T-77886 fix:D-98765 ready:S-12345” }
branch: “teamRoomUX2_S-12345”
eventType: “Commit”
isJson: true
linkMetadataRaw: “”
metadataRaw: “”
metadata_: null
partition: “”
sequenceNumber: “2194”
streamId: “Commits”
Here’s something we tried which does NOT seem like the best way to do this!
- Stopped the CommitsLink projection that does the linkTo and modified it to have the new logic to handle 0 -> N.
- Result: no problem, saved fine. Events Processed count set back to 0, pointer at the end of the Commits stream. That’s fine.
- Reset the CommitsLink projection
- Result: duplicates the events into the various workitem- streams.
- I think this the expected and proper EventStore behavior, but not the correct approach for us
Thanks!
Josh