Skip to content

feat(mailserver): stop reconciling history if we were online - #7673

Open
jrainville wants to merge 1 commit into
developfrom
feat/stop-reconciling-when-online
Open

feat(mailserver): stop reconciling history if we were online#7673
jrainville wants to merge 1 commit into
developfrom
feat/stop-reconciling-when-online

Conversation

@jrainville

@jrainville jrainville commented Jul 29, 2026

Copy link
Copy Markdown
Member

Fixes #7568
Status-app PR: status-im/status-app#21714

Summary

  • bound automatic history reconciliation to observed unreliable-delivery windows
  • introduce typed reconciliation events carrying fixed From and To bounds
  • retain, retry, and coalesce pending windows while preserving disjoint outages
  • prevent stable online periods from being queried during later reconciliation
  • use mailserver_topics.last_request as a monotonic “known complete through” cursor
  • checkpoint initialized topic cursors during reliable full-node connectivity
  • schedule bounded reconciliation for offline recovery, sleep/wake, and pause/resume
  • remove duplicate startup fetching and retain one cursor-based startup catch-up
  • wake retained work when mobile-network syncing is enabled
  • bound newest-community-description queries to the reconciliation window
  • preserve existing behavior for initial topic history, manual requests, and archive backfills

Testing

  • added coverage for reliable and unreliable connectivity transitions
  • added overlapping/disjoint window coalescing and concurrent queue tests
  • added fixed retry-bound and blocked-work retention coverage
  • added cursor initialization, checkpointing, and monotonic update tests
  • added pause/resume and community-description window tests
  • ran focused Waku and protocol tests, including race coverage
  • ran messaging package compilation and go vet
  • ran protocol tests with -tags lint because libsds.h is unavailable in this checkout

Fixes #7568

## Summary

- bound automatic history reconciliation to observed unreliable-delivery windows
- introduce typed reconciliation events carrying fixed `From` and `To` bounds
- retain, retry, and coalesce pending windows while preserving disjoint outages
- prevent stable online periods from being queried during later reconciliation
- use `mailserver_topics.last_request` as a monotonic “known complete through” cursor
- checkpoint initialized topic cursors during reliable full-node connectivity
- schedule bounded reconciliation for offline recovery, sleep/wake, and pause/resume
- remove duplicate startup fetching and retain one cursor-based startup catch-up
- wake retained work when mobile-network syncing is enabled
- bound newest-community-description queries to the reconciliation window
- preserve existing behavior for initial topic history, manual requests, and archive backfills

## Testing

- added coverage for reliable and unreliable connectivity transitions
- added overlapping/disjoint window coalescing and concurrent queue tests
- added fixed retry-bound and blocked-work retention coverage
- added cursor initialization, checkpointing, and monotonic update tests
- added pause/resume and community-description window tests
- ran focused Waku and protocol tests, including race coverage
- ran messaging package compilation and `go vet`
- ran protocol tests with `-tags lint` because `libsds.h` is unavailable in this checkout
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refines mailserver (store node) history reconciliation so that the protocol only queries history for periods where live delivery may have been missed (offline/unreliable windows), while tracking a monotonic per-topic “known complete through” cursor and checkpointing it during reliably connected full-node operation.

Changes:

  • Introduces typed reconciliation windows (HistoryReconcileWindow) and updates the Waku → Transport → Messaging API surface accordingly.
  • Reworks Messenger historic sync into a queued, bounded-window worker that coalesces/retries reconciliation requests without expanding into reliably-online time.
  • Updates mailserver topic cursor persistence semantics (0 = uninitialized; monotonic advancement) and adds unit coverage around windowing, coalescing, pause/resume, and cursor checkpointing.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
services/mailservers/database.go Makes topic upserts monotonic and adds AdvanceLastRequest to checkpoint initialized topic cursors.
services/mailservers/api_test.go Extends DB tests for cursor advancement and non-regression behavior.
protocol/messenger.go Adjusts pause/resume and connectivity handling to enqueue bounded reconciliation windows and checkpoint cursors.
protocol/messenger_settings.go Wakes the historic sync worker when mobile-network syncing is enabled.
protocol/messenger_pause_play_test.go Adds coverage ensuring resume enqueues a single bounded catch-up window.
protocol/messenger_mailserver.go Adds window-aware historic sync options, bounds reconciliation queries, and makes cursor updates monotonic.
protocol/messenger_mailserver_window_test.go New tests for window flooring, window translation, and concurrent/coalesced queue behavior.
protocol/messenger_mailserver_test.go Adds coverage that community-description fetch respects reconciliation window bounds.
protocol/messenger_mailserver_cycle.go Implements queued historic sync requests, coalescing, retry/defer semantics, and periodic cursor checkpointing.
pkg/messaging/waku/types/waku.go Updates the Waku interface to emit typed reconcile windows and report delivery reliability.
pkg/messaging/waku/types/connection.go Defines the HistoryReconcileWindow type.
pkg/messaging/waku/history_reconcile.go Emits unreliable-delivery windows instead of a level-trigger signal; adds reliability tracking and HistoryDeliveryReliable.
pkg/messaging/waku/history_reconcile_test.go Adds tests for window tracking bounds/disjointness and light-node reliability behavior.
pkg/messaging/waku/gowaku.go Updates the reconcile channel type/buffering to carry windows.
pkg/messaging/types/connection_status.go Re-exports HistoryReconcileWindow from the waku layer.
pkg/messaging/layers/transport/transport.go Surfaces typed reconcile windows and delivery-reliability reporting from transport.
pkg/messaging/api.go Exposes typed reconcile windows and delivery-reliability reporting on the messaging API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 110 to 113
select {
case w.historyReconcileNeeded <- struct{}{}:
default: // a signal is already pending; coalesce
case w.historyReconcileNeeded <- window:
case <-w.ctx.Done():
}
@status-im-auto

status-im-auto commented Jul 29, 2026

Copy link
Copy Markdown
Member

Jenkins Builds

Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 354b595 1 2026-07-29 20:28:26 ~6 min macos/status-go 📦zip
✔️ 354b595 1 2026-07-29 20:30:31 ~8 min windows/status-go 📦zip
✔️ 354b595 1 2026-07-29 20:32:53 ~10 min tests 📄log
✔️ 354b595 1 2026-07-29 20:35:17 ~13 min linux/status-go 📦zip
✔️ 354b595 1 2026-07-29 20:49:44 ~27 min tests-rpc 📄log
✖️ 354b595 1 2026-07-29 21:32:06 ~1 hr 9 min tests-rpc-compat 📄log

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.79381% with 59 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.25%. Comparing base (986045c) to head (354b595).

Files with missing lines Patch % Lines
protocol/messenger_mailserver_cycle.go 83.42% 21 Missing and 10 partials ⚠️
protocol/messenger_mailserver.go 76.53% 17 Missing and 6 partials ⚠️
pkg/messaging/waku/history_reconcile.go 90.00% 3 Missing and 1 partial ⚠️
protocol/messenger_settings.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7673      +/-   ##
===========================================
- Coverage    62.28%   62.25%   -0.03%     
===========================================
  Files          868      868              
  Lines       120152   120461     +309     
===========================================
+ Hits         74834    74997     +163     
- Misses       37674    37811     +137     
- Partials      7644     7653       +9     
Flag Coverage Δ
functional 42.13% <80.15%> (-0.09%) ⬇️
unit 55.97% <65.97%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/messaging/api.go 46.80% <100.00%> (+2.36%) ⬆️
pkg/messaging/layers/transport/transport.go 62.80% <100.00%> (+0.14%) ⬆️
pkg/messaging/waku/gowaku.go 70.39% <100.00%> (ø)
pkg/messaging/waku/types/connection.go 100.00% <ø> (ø)
pkg/messaging/waku/types/waku.go 65.51% <ø> (ø)
protocol/messenger.go 62.00% <100.00%> (-0.10%) ⬇️
services/mailservers/database.go 78.83% <100.00%> (+1.66%) ⬆️
protocol/messenger_settings.go 23.43% <0.00%> (ø)
pkg/messaging/waku/history_reconcile.go 93.84% <90.00%> (-3.30%) ⬇️
protocol/messenger_mailserver.go 48.37% <76.53%> (+5.59%) ⬆️
... and 1 more

... and 22 files with indirect coverage changes

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.

Stop constantly reconciling history with store nodes

3 participants