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

Allow profile updates to happen on workers #3659

Merged
merged 14 commits into from
Aug 22, 2018
Merged

Conversation

erikjohnston
Copy link
Member

Based on #3632

@erikjohnston erikjohnston self-assigned this Aug 7, 2018
@erikjohnston erikjohnston removed their assignment Aug 9, 2018
@erikjohnston erikjohnston requested a review from a team August 9, 2018 09:54
@@ -71,8 +71,6 @@ def get_from_remote_profile_cache(self, user_id):
desc="get_from_remote_profile_cache",
)


class ProfileStore(ProfileWorkerStore):
Copy link
Member

Choose a reason for hiding this comment

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

Is there not a danger of races if the *_remote_profile_cache methods are called from a worker?

Copy link
Member

Choose a reason for hiding this comment

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

on closer inspection, it looks like efforts are made to not call those methods from a worker, in which case I think they should probably stay in ProfileStore rather than moving.

Copy link
Member Author

Choose a reason for hiding this comment

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

Woops, fixed

@@ -166,10 +171,16 @@ def set_displayname(self, target_user, requester, new_displayname, by_admin=Fals
)

if self.hs.config.user_directory_search_all_users:
profile = yield self.store.get_profileinfo(target_user.localpart)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not entirely sure I'm happy that we end up with a UserDirectoryHandler which we then carefully don't use. Could we have some sort of stub handler which just provides a notify_profile_changed and is implemented by different classes on the workers than on the master?

@@ -51,6 +52,10 @@ def __init__(self, hs):
self._start_update_remote_profile_cache, self.PROFILE_UPDATE_MS,
Copy link
Member

Choose a reason for hiding this comment

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

it might be a good time to shift this (and the things it calls) to a MasterProfileHandler

Turns out that the user directory handling is fairly racey as a bunch
of stuff assumes that the processing happens on master, which it doesn't
when there is a synapse.app.user_dir worker. So lets just call the
function directly until we actually get round to fixing it, since it
doesn't make the situation any worse.
@erikjohnston erikjohnston assigned richvdh and unassigned erikjohnston Aug 17, 2018
@@ -32,12 +32,12 @@
logger = logging.getLogger(__name__)


class ProfileHandler(BaseHandler):
class WorkerProfileHandler(BaseHandler):
PROFILE_UPDATE_MS = 60 * 1000
Copy link
Member

Choose a reason for hiding this comment

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

these are redundant now

@@ -32,12 +32,12 @@
logger = logging.getLogger(__name__)


class ProfileHandler(BaseHandler):
class WorkerProfileHandler(BaseHandler):
Copy link
Member

Choose a reason for hiding this comment

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

given that this is also used as a base class on the master instance, can you either give it a different name (BaseProfileHandler?) or a docstring that explains the situation?

@@ -308,7 +308,10 @@ def build_initial_sync_handler(self):
return InitialSyncHandler(self)

def build_profile_handler(self):
return ProfileHandler(self)
if self.config.worker_app:
Copy link
Member

Choose a reason for hiding this comment

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

could we have this return WorkerProfileHandler and then override it in synapse.server.HomeServer? possibly with a comment here to say that's what's going on?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could, but this is how we do it for other handlers. I'm not sure I really think it'll be clearer moving it into the actual app

Copy link
Member

Choose a reason for hiding this comment

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

hrm, ok, let's punt it for now, though I'm not sure I agree.

Copy link
Member Author

Choose a reason for hiding this comment

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

Certainly something we can revisit if/when we try and clean up the worker split out

def __init__(self, hs):
super(MasterProfileHandler, self).__init__(hs)

self.clock.looping_call(
Copy link
Member

Choose a reason for hiding this comment

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

can we assert that hs.config.worker_app is None here?

@richvdh richvdh assigned erikjohnston and unassigned richvdh Aug 21, 2018
@erikjohnston erikjohnston assigned richvdh and unassigned erikjohnston Aug 22, 2018
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.

lgtm

@richvdh richvdh assigned erikjohnston and unassigned richvdh Aug 22, 2018
@erikjohnston
Copy link
Member Author

woo, ta

@erikjohnston erikjohnston merged commit 764030c into develop Aug 22, 2018
@erikjohnston erikjohnston deleted the erikj/split_profiles branch September 20, 2018 13:58
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.

2 participants