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

Introduce update_user_directory_on #11450

Closed

Conversation

ShadowJonathan
Copy link
Contributor

@ShadowJonathan ShadowJonathan commented Nov 29, 2021

Fixes #10339

This changes the update_user_directory config variable to a update_user_directory_on variable, which more explicitly points or denotes which process is supposed to be working user directory updates. This defaults to the main process.

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.
  • Pull request includes a sign off
  • Code style is correct
    (run the linters)

Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>

@ShadowJonathan ShadowJonathan requested a review from a team as a code owner November 29, 2021 18:06
@ShadowJonathan
Copy link
Contributor Author

ShadowJonathan commented Nov 29, 2021

Blocked on matrix-org/sytest#1173 to let sytest worker tests proceed correctly.

@ShadowJonathan
Copy link
Contributor Author

I added backwards compatibility to this, this is unblocked now.

@DMRobertson DMRobertson removed the z-blocked (Deprecated Label) label Dec 6, 2021
@turt2live
Copy link
Member

I have not looked at the patch, but it'd be quite nice to keep the disabling side effect of the flag. In my use case, t2bot.io doesn't update the user directory at all and there is no worker for it, so the original intent of the setting was to save CPU/DB cycles.

I will admit that it's a use case with sample size 1 though.

@ShadowJonathan
Copy link
Contributor Author

Technically it would still work, as no string can match False, so consider that a feature :)

@turt2live
Copy link
Member

can it get documented as a feature please? 😇

Relying on magic behaviour isn't great.

synapse/rest/client/shared_rooms.py Show resolved Hide resolved
synapse/app/admin_cmd.py Outdated Show resolved Hide resolved
synapse/config/server.py Outdated Show resolved Hide resolved
synapse/config/server.py Outdated Show resolved Hide resolved
@squahtx squahtx self-assigned this Dec 8, 2021
auto-merge was automatically disabled December 9, 2021 14:55

Head branch was pushed to by a user without write access

@anoadragon453 anoadragon453 self-requested a review December 9, 2021 15:06
@ShadowJonathan ShadowJonathan changed the title Introduce worker_to_update_user_directory Introduce update_user_directory_on Dec 9, 2021
@squahtx squahtx removed their assignment Dec 10, 2021
docs/sample_config.yaml Outdated Show resolved Hide resolved
synapse/config/workers.py Outdated Show resolved Hide resolved
synapse/config/workers.py Outdated Show resolved Hide resolved
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

this is definitely much clearer and easier to follow now, thanks! A few notes though.

synapse/config/workers.py Outdated Show resolved Hide resolved
synapse/config/workers.py Outdated Show resolved Hide resolved
synapse/config/workers.py Outdated Show resolved Hide resolved
synapse/config/workers.py Outdated Show resolved Hide resolved
tests/utils.py Outdated Show resolved Hide resolved
tests/handlers/test_user_directory.py Show resolved Hide resolved
synapse/config/workers.py Outdated Show resolved Hide resolved
@anoadragon453 anoadragon453 removed their request for review January 27, 2022 15:10
ShadowJonathan and others added 2 commits January 30, 2022 12:32
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
@@ -126,6 +126,11 @@

logger = logging.getLogger("synapse.app.generic_worker")

DIRECTORY_UPDATE_WARNING = """
The user directory worker is not allowed to perform user directory updates per the config.
Copy link
Member

@richvdh richvdh Jan 31, 2022

Choose a reason for hiding this comment

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

right, I see the confusion here now. "not allowed to" sounds like I've tried to enable something invalid. Maybe s/not allowed to/not configured to/.

But I don't really understand why this is a thing we need to warn about. Why is it a problem if the updates are done on the main process?

Note that the current wording sounds very much like an error, indicating something that definitely won't work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe s/not allowed to/not configured to/.

👍

Why is it a problem if the updates are done on the main process?

That's not the problem, the problem is is that the configuration does not appoint the local worker to do the updates.

The config can now appoint any worker to do this job by its name, so the job of the user directory worker isn't that unique anymore, but it's uniqueness is still supported by synapse.

Note that the current wording sounds very much like an error

That's because it is, the local worker has a "type" of being a designated user update worker, while the configuration does not allow it to do just that. This is more or less a warning that "your config, as-is, is contradictory"

The previous version exited the process with 1 when hitting this point, should that be re-introduced?

synapse/app/generic_worker.py Outdated Show resolved Hide resolved
synapse/config/workers.py Show resolved Hide resolved
synapse/config/workers.py Outdated Show resolved Hide resolved
tests/handlers/test_user_directory.py Outdated Show resolved Hide resolved
tests/handlers/test_user_directory.py Show resolved Hide resolved
@richvdh richvdh self-requested a review January 31, 2022 17:20
@richvdh
Copy link
Member

richvdh commented Feb 8, 2022

Ugh, I remain hopelessly confused about what is going on here, and how it fixes the original issue (#10339). I have commented there.

@ShadowJonathan
Copy link
Contributor Author

I'll be closing this PR in light of the retrospective at #10339 (comment), where it became clear this PR is the wrong solution to this problem.

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.

Shared rooms API doesn't work if the worker handling the request doesn't update the user directory
7 participants