Commit 715cc5e
authored
Split homeserver creation and setup (#19015)
### Background
As part of Element's plan to support a light form of vhosting (virtual
host) (multiple instances of Synapse in the same Python process), we're
currently diving into the details and implications of running multiple
instances of Synapse in the same Python process.
"Clean tenant provisioning" tracked internally by
element-hq/synapse-small-hosts#221
### Partial startup problem
In the context of Synapse Pro for Small Hosts, since the Twisted reactor
is already running (from the `multi_synapse` shard process itself), when
provisioning a homeserver tenant, the `reactor.callWhenRunning(...)`
callbacks will be invoked immediately. This includes the Synapse's
[`start`](https://github.com/element-hq/synapse/blob/0615b64bb49684b846110465052642a46fd27028/synapse/app/homeserver.py#L418-L429)
callback which sets up everything (including listeners, background
tasks, etc). If we encounter an error at this point, we are partially
setup but the exception will [bubble back to
us](https://github.com/element-hq/synapse-small-hosts/blob/8be122186bf1acb8c0426d84eb3abded25d682b7/multi_synapse/app/shard.py#L114-L121)
without us having a handle to the homeserver yet so we can't call
`hs.shutdown()` and clean everything up.
### What does this PR do?
Structures Synapse so we split creating the homeserver instance from
setting everything up. This way we have access to `hs` if anything goes
wrong during setup and can subsequently `hs.shutdown()` to clean
everything up.1 parent d440cfc commit 715cc5e
File tree
4 files changed
+73
-26
lines changed- changelog.d
- synapse/app
- tests
- app
- config
4 files changed
+73
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
86 | 90 | | |
87 | 91 | | |
88 | 92 | | |
| |||
345 | 349 | | |
346 | 350 | | |
347 | 351 | | |
348 | | - | |
| 352 | + | |
349 | 353 | | |
350 | 354 | | |
351 | | - | |
352 | 355 | | |
353 | 356 | | |
354 | | - | |
| 357 | + | |
355 | 358 | | |
356 | 359 | | |
357 | 360 | | |
358 | 361 | | |
359 | 362 | | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | 363 | | |
366 | 364 | | |
367 | 365 | | |
| |||
372 | 370 | | |
373 | 371 | | |
374 | 372 | | |
375 | | - | |
376 | 373 | | |
377 | 374 | | |
378 | 375 | | |
| |||
397 | 394 | | |
398 | 395 | | |
399 | 396 | | |
400 | | - | |
| 397 | + | |
401 | 398 | | |
402 | 399 | | |
403 | 400 | | |
404 | 401 | | |
405 | | - | |
| 402 | + | |
406 | 403 | | |
407 | | - | |
408 | | - | |
409 | 404 | | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
410 | 428 | | |
411 | 429 | | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
412 | 433 | | |
413 | 434 | | |
414 | 435 | | |
415 | 436 | | |
416 | 437 | | |
417 | | - | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
418 | 441 | | |
419 | 442 | | |
420 | 443 | | |
| |||
423 | 446 | | |
424 | 447 | | |
425 | 448 | | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
426 | 452 | | |
427 | 453 | | |
428 | | - | |
| 454 | + | |
| 455 | + | |
429 | 456 | | |
430 | | - | |
431 | 457 | | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
432 | 463 | | |
433 | | - | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
434 | 467 | | |
435 | 468 | | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
441 | 474 | | |
442 | 475 | | |
443 | 476 | | |
| |||
448 | 481 | | |
449 | 482 | | |
450 | 483 | | |
451 | | - | |
| 484 | + | |
| 485 | + | |
452 | 486 | | |
453 | 487 | | |
454 | 488 | | |
455 | 489 | | |
456 | 490 | | |
457 | | - | |
| 491 | + | |
458 | 492 | | |
459 | 493 | | |
460 | 494 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
43 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
0 commit comments