Repository navigation
refactor: read the DS outbox through receive - #9603
Merged
Merged
Conversation
The DS reads the DO's outbox through P2PConnection.receive() and mark_processed(), as the DO reads its inbox. receive() takes an optional after, the msg_id of the last message processed, which Drive turns into its timestamp filter. The DS cache keeps last_msg_id_per_peer and one sync_down. Outbox compaction is unchanged.
- A message that fails to download ends the outbox list, so the bookmark never passes it. - A message that can never be read comes back as None with a warning and the DS moves past it, instead of failing every sync. One from a peer that is not set up yet waits for the next sync. - The DS lists back OUTBOX_LOOKBACK_SECONDS (60s) before its bookmark and skips the messages in already_received, so a message that lands after newer ones is still received. - The restored bookmark is keyed by the lowercased peer email, and restoring it is split into small helpers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The DS now reads the outbox of the DO through
P2PConnection.receive()/mark_processed(), the same way the DO already reads its inbox. This is the step before a WebRTC P2P connection (over a fake channel): WebRTC has no Drive file ids or timestamps, so the DS could not read from it before.receive()takes an optionalafter: themsg_idof the newest message the receiver processed, andalready_received: the ids of the ones it has. Drive keeps outbox messages (the DS rebuilds a lost cache from them), so it lists from a bit beforeafterand skipsalready_receivedbefore downloading (see the look-back below). A connection that drops processed messages ignores both. They go away with send-and-forget.DriveP2PConnection.receive(FILE_EVENTS)lists the outbox once and downloads in parallel through the existing_download_all.mark_processedon file events does nothing on Drive.last_msg_id_per_peer(waslast_event_timestamp_per_peer) andreceived_msg_ids, both rebuilt from saved messages on start.sync_downandsync_down_parallelare merged into onesync_down.watcher_receive_events_messages;owner_mark_all_processedis nowmark_all_processed, used by both roles. Removed the Drive-only reads:watcher_get_events_messages,watcher_get_outbox_file_metadatas,outbox_messages,outbox_message_metadatas.Outbox compaction is unchanged; it still uses the Drive-only methods and moves in a later PR.
Fixes from review
Nonewith a warning, and the DS moves past it instead of failing every sync. One from a peer that is not set up yet ends that peer's list and waits for the next sync; other peers continue.OUTBOX_LOOKBACK_SECONDS(60s) before its bookmark and skips what it already received. The bookmark only moves forward. A message that lands more than 60s late is still missed._load_saved_messages,_restore_receivedand_restore_file_hashes.Drive API calls: one listing per peer plus one download per new message, as before. The look-back can add a listing page when more than 100 messages fall in it; messages already received are not downloaded again.
Tests
Noneand stops at one not readable yet; a DS sync for each fix; a restored bookmark is found for the peer email in another case.tests/migrations: 115 passed