Skip to content

feat(release-worker): assign sequence to new releases - #586

Open
alisawavezen12 wants to merge 3 commits into
masterfrom
feat/release-worker-sequence
Open

feat(release-worker): assign sequence to new releases#586
alisawavezen12 wants to merge 3 commits into
masterfrom
feat/release-worker-sequence

Conversation

@alisawavezen12

@alisawavezen12 alisawavezen12 commented Sep 10, 2026

Copy link
Copy Markdown

Summary

Add first-seen sequencing for newly registered releases in release-worker.

The sequence will be used by the upcoming release validator to determine the previous release of a project. This is required for comparing event groups between releases and identifying errors that likely stopped occurring after a release.

What changed

  • Add an optional releaseSequence field to new release documents.
  • Store the sequence directly in the existing releases collection.
  • Start numbering from 1 independently for each project.
  • Assign the sequence only when a unique (projectId, release) is first registered.
  • Keep the same sequence when the release receives additional commits or source maps.
  • Create the release document before saving commits or source maps.
  • Remove the fallback release creation from source-map processing so every new release goes through the same sequence assignment logic.
  • Keep legacy release documents without releaseSequence unchanged.
  • Do not create release documents for regular events without a release.

Sequence assignment

The current release worker is configured to process messages sequentially:

SIMULTANEOUS_TASKS=1

Therefore, the next sequence is calculated from the maximum existing sequence for the project:

max(releaseSequence) + 1

The sequence is stored on the release document and can later be used to find the previous release.

This PR intentionally does not add a separate counter collection. If the release worker is horizontally scaled or starts processing release messages concurrently in the future, sequence assignment must be revisited and protected with an atomic counter or another concurrency-safe mechanism.

Processing flow

POST /release
→ collector
→ release queue
→ release-worker
→ ensure the release exists with releaseSequence
→ save commits and/or source maps

Repeated uploads for the same release only update the existing document and do not create a new sequence.

Regular error events without a release continue through the normal event pipeline and do not create release documents.

Why

RabbitMQ delivery order cannot be used as the release timeline because messages may be delayed or redelivered. The stored sequence provides a stable first-registration order for new releases and will allow the future validator to compare a release with its predecessor.

Backward compatibility

  • Existing release documents may not contain releaseSequence.
  • Legacy releases are not migrated in this PR.
  • New sequence numbering starts from 1 for releases created after this change.
  • Existing commits/source maps behavior remains unchanged.

Scope

This PR only prepares release ordering data. It does not include:

  • the release validation queue;
  • the release-validator worker;
  • likelyFixed calculation;
  • event status storage;
  • API or Garage changes.

const hasFiles = Array.isArray(payload.files) && payload.files.length > 0;

if (!validCommits && !hasFiles) {
return;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

add debug log about release skipping with project id

return;
}

await this.ensureRelease(projectId, payload.release);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

name is not clear

Comment on lines +126 to +128
* Ensure that a release gets one stable first-seen sequence.
*
* Release processing is intentionally sequential in the current deployment.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please, provide more clear explaination

Comment on lines 246 to 250
/**
* - insert new record with saved maps
* or
* - update previous record with adding new saved maps
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

docs are not actual

* or
* - update previous record with adding new saved maps
*/
if (!existedRelease) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why this code has been removed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This code was moved to createReleaseIfMissing, which runs before saveSourceMap. So saveSourceMap only updates an existing release now.

* Error code of MongoDB key duplication error
*/
/* eslint-disable @typescript-eslint/no-magic-numbers */
const DB_DUPLICATE_KEY_ERROR = '11000';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

unexpected change. It was used to handle worker scaling.

projection: { releaseSequence: 1 },
});

const releaseSequence = (lastRelease?.releaseSequence || 0) + 1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure it will work properly in case of several workers running in parallel.

@neSpecc

neSpecc commented Sep 12, 2026

Copy link
Copy Markdown
Member

The sequence will be used by the upcoming release validator to determine the previous release of a project

why not to resolve it by date?

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.

2 participants