-
Notifications
You must be signed in to change notification settings - Fork 522
Be able to shutdown homeserver that failed to start
#19232
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
Changes from 21 commits
0480911
a0e7698
df0a5d1
d046476
d55f86d
fa83d65
ea1757e
fce7ada
b99246b
b3aab27
72ca424
f51e1fe
c69397b
f2af1d7
cc26fd1
34b1878
270aaba
e121d66
e49fed1
d8f4a00
422f36d
5729c13
2551c24
ebf3c6e
591d920
235b684
25015f7
858c2ba
fe3a84a
df97f11
b430e81
238c936
382bbcd
d0d2802
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix `HomeServer.shutdown()` failing if the homeserver hasn't been setup yet. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix `HomeServer.shutdown()` failing if the homeserver failed to `start`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -815,6 +815,13 @@ def stopFactory(self) -> None: | |
| protocol.transport.loseConnection() | ||
| self.connections.clear() | ||
|
|
||
| # Replace the resource tree with an empty resource to break circular references | ||
| # to the resource tree which holds a bunch of homeserver references. This is | ||
| # important if we try to call `hs.shutdown()` after `start` fails. For some | ||
| # reason, this doesn't seem to be necessary in the normal case where `start` | ||
| # succeeds and we call `hs.shutdown()` later. | ||
| self.resource = Resource() | ||
|
Comment on lines
+818
to
+823
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've spent too long trying to figure out why this works exactly. Specifically, why the normal case works without this change but the error case requires it. The internal references to In the normal case, I've looked through the Twisted internals to try to spot the difference but was unsuccessful. Also tried throwing an LLM at the problem but they were also unable to spot anything. In any case, clearing circular references in these kinds of callbacks are pretty normal. For example, it's even called out in the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Happy to have this + the comment saying we don't understand why it's necessary only sometimes. Replacing your inners with empty values on shutdown/destruction is totally fine as a practice to me.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I'm assuming the current comment is sufficient) |
||
|
|
||
| def log(self, request: SynapseRequest) -> None: # type: ignore[override] | ||
| pass | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best to review this part with the "Hide whitespace" option when viewing the diff