Skip to content

fix(task): preserve overlapping notification batches - #197

Merged
bitxeno merged 1 commit into
bitxeno:masterfrom
YellowNest:fix/preserve-notification-batches
Oct 8, 2026
Merged

bitxeno merged 1 commit into
bitxeno:masterfrom
YellowNest:fix/preserve-notification-batches

Conversation

@YellowNest

Copy link
Copy Markdown
Contributor

Problem

Batch notification tracking keeps only one global currentBatch.

If another StartInstallApps call queues at least one distinct app while the current batch is still in flight, the later call replaces currentBatch. The install queue itself is FIFO and processed by a single consumer, so the older batch still finishes first — but trackBatchProgress then sees a different BatchID and drops that progress entirely.

The existing guard already preserves the current batch when a later call queues zero apps. It does not cover the same overlap when the later call actually queues work.

Fix

Keep later batch metadata in a FIFO pendingBatches queue while a batch is active.

When the current batch completes:

  • send its aggregated notification;
  • promote the next pending batch;
  • clear currentBatch only when no batches remain.

Calls that queue zero apps still leave the existing batch state untouched.

Regression coverage

TestStartInstallAppsKeepsDistinctBatchesInOrder reproduces the overlap with two distinct batches.

On upstream 6270e7f, it fails with:

first batch was displaced by later batch

With this change:

go test ./internal/task -count=1

passes, and the regression test also passes repeatedly with -count=10.

Scope

Two files, one commit, no API/UI/database changes.

@bitxeno
bitxeno merged commit e70b293 into bitxeno:master Oct 8, 2026
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

⌂ 换网址