Skip to content

fix(sync): stop event batch after failure - #4297

Draft
MohamadJaara wants to merge 1 commit into
developfrom
mo/fix-incremental-sync-batch-failures
Draft

fix(sync): stop event batch after failure#4297
MohamadJaara wants to merge 1 commit into
developfrom
mo/fix-incremental-sync-batch-failures

Conversation

@MohamadJaara

Copy link
Copy Markdown
Member

Intent

Prevent one failed event from amplifying side effects across the rest of an incremental-sync page.

Root cause

The worker eagerly processed every envelope with map before folding the results. If an early event failed, later events still ran, but the transaction returned failure and no event IDs were marked processed. Those later events and their side effects were then replayed with the page.

Reproduction

  1. Return a page containing at least two events.
  2. Make the first event fail.
  3. Observe that the second event is still processed.
  4. Observe that the page fails and no IDs are marked, causing the second event to run again on retry.

Fix

Event processing now happens inside the existing foldToEitherWhileRight, which stops invoking processors after the first failure. The all-or-nothing transaction boundary is preserved, and pending side effects are not flushed on a failed page.

Regression coverage verifies that later events, side-effect flushing, and processed-ID marking do not run after an earlier failure.

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Test Results

0 tests   - 5 871   0 ✅  - 5 730   0s ⏱️ - 4m 25s
0 suites  -   889   0 💤  -   141 
0 files    -   889   0 ❌ ±    0 

Results for commit ef2ea4c. ± Comparison against base commit d57f18f.

♻️ This comment has been updated with latest results.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.30%. Comparing base (d57f18f) to head (ef2ea4c).

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #4297   +/-   ##
==========================================
  Coverage      61.30%   61.30%           
  Complexity      4022     4022           
==========================================
  Files           2163     2163           
  Lines          69467    69467           
  Branches        6901     6901           
==========================================
  Hits           42590    42590           
  Misses         24114    24114           
  Partials        2763     2763           
Files with missing lines Coverage Δ
...um/logic/sync/incremental/IncrementalSyncWorker.kt 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d57f18f...ef2ea4c. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branch${GITHUB_HEAD_REF}
Testbedubuntu-latest

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymicroseconds (µs)
com.wire.kalium.benchmarks.logic.CoreLogicBenchmark.createObjectInFiles📈 view plot
⚠️ NO THRESHOLD
880.87 µs
com.wire.kalium.benchmarks.logic.CoreLogicBenchmark.createObjectInMemory📈 view plot
⚠️ NO THRESHOLD
333,615.01 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.inboxPagingDeepPageBenchmark📈 view plot
⚠️ NO THRESHOLD
134,564.08 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.inboxPagingFirstPageBenchmark📈 view plot
⚠️ NO THRESHOLD
130,635.71 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.localMarkAsReadBenchmark📈 view plot
⚠️ NO THRESHOLD
3,660.46 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.messagePagingDeepPageBenchmark📈 view plot
⚠️ NO THRESHOLD
37,448.93 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.messagePagingFirstPageBenchmark📈 view plot
⚠️ NO THRESHOLD
22,162.23 µs
com.wire.kalium.benchmarks.persistence.MessagesNoPragmaTuneBenchmark.messageInsertionBenchmark📈 view plot
⚠️ NO THRESHOLD
1,263,460.16 µs
com.wire.kalium.benchmarks.persistence.MessagesNoPragmaTuneBenchmark.queryMessagesBenchmark📈 view plot
⚠️ NO THRESHOLD
20,301.47 µs
🐰 View full continuous benchmarking report in Bencher

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