Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent message search in upgraded rooms we're not in #6385

Merged
merged 11 commits into from Dec 11, 2019

Conversation

@anoadragon453
Copy link
Member

anoadragon453 commented Nov 19, 2019

Fixes #6356

I assume this is preferred instead of attempting to join the predecessor room before searching it, as that could be slow and we may not be able to join.

@anoadragon453 anoadragon453 requested a review from matrix-org/synapse-core Nov 19, 2019
@anoadragon453 anoadragon453 self-assigned this Nov 19, 2019
@anoadragon453 anoadragon453 added this to In progress in Homeserver Task Board via automation Nov 19, 2019
@anoadragon453 anoadragon453 moved this from In progress to Review in Homeserver Task Board Nov 19, 2019
synapse/handlers/search.py Outdated Show resolved Hide resolved
synapse/handlers/search.py Outdated Show resolved Hide resolved
synapse/handlers/search.py Outdated Show resolved Hide resolved
synapse/handlers/search.py Outdated Show resolved Hide resolved
synapse/handlers/search.py Outdated Show resolved Hide resolved
@anoadragon453 anoadragon453 requested a review from richvdh Dec 4, 2019
Copy link
Member

richvdh left a comment

I don't think this fixes the bug...

synapse/handlers/search.py Outdated Show resolved Hide resolved
synapse/handlers/search.py Show resolved Hide resolved
synapse/handlers/search.py Show resolved Hide resolved
@anoadragon453 anoadragon453 requested a review from richvdh Dec 4, 2019
Copy link
Member

richvdh left a comment

sorry anoa, but this feels like a very complicated way of solving the problem. How about this:

        # the initial room must have been known for us to get this far.
        predecessor_room = yield self.store.get_room_predecessor(room_id)

        while True:
            if not predecessor_room:
                # We have reached the end of the chain of predecessors
                break

            predecessor_room_id = predecessor["room_id"]

            # don't add it to the list until we have checked that we are in the room.
            try:
                next_predecessor_room = yield self.store.get_room_predecessor(
                    predecessor_room_id
                )
            except NotFoundError:
                # The predecessor is not a known room, so we are done here
                break
            
            historical_room_ids.append(predecessor_room_id)

             # and repeat
            predecessor_room = next_predecessor_room

        return historical_room_ids
@anoadragon453 anoadragon453 removed this from Review in Homeserver Task Board Dec 5, 2019
@anoadragon453

This comment has been minimized.

Copy link
Member Author

anoadragon453 commented Dec 5, 2019

predecessor_room_id = predecessor["room_id"]

We would still need to check that predecessor actually contained a room_id first, right?

@anoadragon453 anoadragon453 requested a review from richvdh Dec 5, 2019
@anoadragon453

This comment has been minimized.

Copy link
Member Author

anoadragon453 commented Dec 5, 2019

I've implemented a very similar version, thanks :)

Copy link
Member

richvdh left a comment

lgmt!

synapse/handlers/federation.py Outdated Show resolved Hide resolved
synapse/handlers/search.py Outdated Show resolved Hide resolved
Copy link
Member

richvdh left a comment

lgtm

synapse/handlers/federation.py Outdated Show resolved Hide resolved
@anoadragon453 anoadragon453 merged commit ea0f0ad into develop Dec 11, 2019
22 checks passed
22 checks passed
buildkite/synapse Build #6078 passed (26 minutes, 56 seconds)
Details
buildkite/synapse/check-sample-config Passed (1 minute, 36 seconds)
Details
buildkite/synapse/check-style Passed (2 minutes, 11 seconds)
Details
buildkite/synapse/isort Passed (17 seconds)
Details
buildkite/synapse/mypy Passed (50 seconds)
Details
buildkite/synapse/newspaper-newsfile Passed (17 seconds)
Details
buildkite/synapse/packaging Passed (17 seconds)
Details
buildkite/synapse/pipeline Passed (3 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-postgres-9-dot-5 Passed (17 minutes, 21 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite Passed (6 minutes, 45 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite-slash-old-deps Passed (8 minutes, 55 seconds)
Details
buildkite/synapse/python-3-dot-6-slash-sqlite Passed (6 minutes, 31 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-11 Passed (18 minutes, 11 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-9-dot-5 Passed (17 minutes, 40 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-sqlite Passed (6 minutes, 42 seconds)
Details
buildkite/synapse/synapse-port-db-slash-python-3-dot-5-slash-postgres-9-dot-5 Passed (1 minute, 3 seconds)
Details
buildkite/synapse/synapse-port-db-slash-python-3-dot-7-slash-postgres-11 Passed (1 minute, 3 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-monolith Passed (12 minutes, 20 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-workers Passed (15 minutes, 55 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-sqlite-slash-monolith Passed (11 minutes, 51 seconds)
Details
buildkite/synapse/sytest-python-3-dot-7-slash-postgres-11-slash-monolith Passed (11 minutes, 49 seconds)
Details
buildkite/synapse/sytest-python-3-dot-7-slash-postgres-11-slash-workers Passed (13 minutes, 41 seconds)
Details
@anoadragon453 anoadragon453 deleted the anoa/fix_search_predecessor_room branch Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.