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

Allow profile updates to happen on workers#3659

Merged
erikjohnston merged 14 commits into
developfrom
erikj/split_profiles
Aug 22, 2018
Merged

Allow profile updates to happen on workers#3659
erikjohnston merged 14 commits into
developfrom
erikj/split_profiles

Conversation

@erikjohnston
Copy link
Copy Markdown
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
)


class ProfileStore(ProfileWorkerStore):
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Woops, fixed

)

if self.hs.config.user_directory_search_all_users:
profile = yield self.store.get_profileinfo(target_user.localpart)
Copy link
Copy Markdown
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?

Comment thread synapse/handlers/profile.py Outdated
@@ -51,6 +52,10 @@ def __init__(self, hs):
self._start_update_remote_profile_cache, self.PROFILE_UPDATE_MS,
Copy link
Copy Markdown
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
Comment thread synapse/handlers/profile.py Outdated

class ProfileHandler(BaseHandler):
class WorkerProfileHandler(BaseHandler):
PROFILE_UPDATE_MS = 60 * 1000
Copy link
Copy Markdown
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

Comment thread synapse/handlers/profile.py Outdated


class ProfileHandler(BaseHandler):
class WorkerProfileHandler(BaseHandler):
Copy link
Copy Markdown
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?

Comment thread synapse/server.py

def build_profile_handler(self):
return ProfileHandler(self)
if self.config.worker_app:
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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