Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Optimize backfill receiving to have less missing prev_event thrashing (v2) #13970

Conversation

MadLittleMods
Copy link
Contributor

@MadLittleMods MadLittleMods commented Sep 30, 2022

Addressing:

-- #10737

So Synapse is fast enough to merge this MSC2716 Complement test for importing many batches, matrix-org/complement#214 (comment)


Complement tests: matrix-org/complement#214


Spawned from scratch changes in, #13864

Dev notes

pseudo_events = [
    { "event": 'eventBefore1', "depth": 1 },
    { "event": 'eventBefore2', "depth": 2 },
    { "event": 'Historical message 1', "depth": 3 },
    { "event": 'Historical message 2', "depth": 3 },
    { "event": 'Historical message 3', "depth": 3 },
    { "event": 'eventAfter1', "depth": 3 },
    { "event": 'eventAfter2', "depth": 4 }
]

pseudo_events = [
    { "event": 'eventAfter2', "depth": 4 },
    { "event": 'eventAfter1', "depth": 3 },
    { "event": 'Historical message 3', "depth": 3 },
    { "event": 'Historical message 2', "depth": 3 },
    { "event": 'Historical message 1', "depth": 3 },
    { "event": 'eventBefore2', "depth": 2 },
    { "event": 'eventBefore1', "depth": 1 },
]


sorted_events = [u[1] for u in sorted(
    enumerate(pseudo_events), key=lambda x: (-x[1].get("depth"), x[0])
)]

print(json.dumps(sorted_events, indent=4))

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Pull request includes a sign off
  • Code style is correct
    (run the linters)

@MadLittleMods MadLittleMods changed the title Optimize backfill receiving to have less missing prev_event thrashing (v2) Optimize backfill receiving to have less missing prev_event thrashing (v2) Sep 30, 2022
Comment on lines +664 to +669
# rather than id trackers.
assert (
self._instance_name in self._config.worker.writers.events
), "Can only write stream IDs on master"
assert isinstance(self._store._backfill_id_gen, AbstractStreamIdGenerator)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we rely on the worker instance that backfills events to be a writer instance? I don't think so. The event persister is different than the workers that ingest new events.

How do I do this correctly?

@MadLittleMods MadLittleMods force-pushed the madlittlemods/test-backfill-and-messages-still-works-with-many-batches branch from 12c15b1 to 68ae0fd Compare September 30, 2022 04:53
@MadLittleMods MadLittleMods mentioned this pull request Apr 5, 2023
27 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant