UPGRADE.rst 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. Upgrading Synapse
  2. =================
  3. Before upgrading check if any special steps are required to upgrade from the
  4. what you currently have installed to current version of Synapse. The extra
  5. instructions that may be required are listed later in this document.
  6. * If Synapse was installed using `prebuilt packages
  7. <INSTALL.md#prebuilt-packages>`_, you will need to follow the normal process
  8. for upgrading those packages.
  9. * If Synapse was installed from source, then:
  10. 1. Activate the virtualenv before upgrading. For example, if Synapse is
  11. installed in a virtualenv in ``~/synapse/env`` then run:
  12. .. code:: bash
  13. source ~/synapse/env/bin/activate
  14. 2. If Synapse was installed using pip then upgrade to the latest version by
  15. running:
  16. .. code:: bash
  17. pip install --upgrade matrix-synapse
  18. If Synapse was installed using git then upgrade to the latest version by
  19. running:
  20. .. code:: bash
  21. git pull
  22. pip install --upgrade .
  23. 3. Restart Synapse:
  24. .. code:: bash
  25. ./synctl restart
  26. To check whether your update was successful, you can check the running server
  27. version with:
  28. .. code:: bash
  29. # you may need to replace 'localhost:8008' if synapse is not configured
  30. # to listen on port 8008.
  31. curl http://localhost:8008/_synapse/admin/v1/server_version
  32. Rolling back to older versions
  33. ------------------------------
  34. Rolling back to previous releases can be difficult, due to database schema
  35. changes between releases. Where we have been able to test the rollback process,
  36. this will be noted below.
  37. In general, you will need to undo any changes made during the upgrade process,
  38. for example:
  39. * pip:
  40. .. code:: bash
  41. source env/bin/activate
  42. # replace `1.3.0` accordingly:
  43. pip install matrix-synapse==1.3.0
  44. * Debian:
  45. .. code:: bash
  46. # replace `1.3.0` and `stretch` accordingly:
  47. wget https://packages.matrix.org/debian/pool/main/m/matrix-synapse-py3/matrix-synapse-py3_1.3.0+stretch1_amd64.deb
  48. dpkg -i matrix-synapse-py3_1.3.0+stretch1_amd64.deb
  49. Upgrading to v1.4.0
  50. ===================
  51. Config options
  52. --------------
  53. **Note: Registration by email address or phone number will not work in this release unless
  54. some config options are changed from their defaults.**
  55. This is due to Synapse v1.4.0 now defaulting to sending registration and password reset tokens
  56. itself. This is for security reasons as well as putting less reliance on identity servers.
  57. However, currently Synapse only supports sending emails, and does not have support for
  58. phone-based password reset or account registration. If Synapse is configured to handle these on
  59. its own, phone-based password resets and registration will be disabled. For Synapse to send
  60. emails, the ``email`` block of the config must be filled out. If not, then password resets and
  61. registration via email will be disabled entirely.
  62. This release also deprecates the ``email.trust_identity_server_for_password_resets`` option and
  63. replaces it with the ``account_threepid_delegates`` dictionary. This option defines whether the
  64. homeserver should delegate an external server (typically an `identity server
  65. <https://matrix.org/docs/spec/identity_service/r0.2.1>`_) to handle sending password reset or
  66. registration messages via email and SMS.
  67. If ``email.trust_identity_server_for_password_resets`` is set to ``true``, and
  68. ``account_threepid_delegates.email`` is not set, then the first entry in
  69. ``trusted_third_party_id_servers`` will be used as the account threepid delegate for email.
  70. This is to ensure compatibility with existing Synapse installs that set up external server
  71. handling for these tasks before v1.4.0. If ``email.trust_identity_server_for_password_resets``
  72. is ``true`` and no trusted identity server domains are configured, Synapse will throw an error.
  73. If ``email.trust_identity_server_for_password_resets`` is ``false`` or absent and a threepid
  74. type in ``account_threepid_delegates`` is not set to a domain, then Synapse will attempt to
  75. send password reset and registration messages for that type.
  76. Email templates
  77. ---------------
  78. If you have configured a custom template directory with the ``email.template_dir`` option, be
  79. aware that there are new templates regarding registration. ``registration.html`` and
  80. ``registration.txt`` have been added and contain the content that is sent to a client upon
  81. registering via an email address.
  82. ``registration_success.html`` and ``registration_failure.html`` are also new HTML templates
  83. that will be shown to the user when they click the link in their registration emai , either
  84. showing them a success or failure page (assuming a redirect URL is not configured).
  85. Synapse will expect these files to exist inside the configured template directory. To view the
  86. default templates, see `synapse/res/templates
  87. <https://github.com/matrix-org/synapse/tree/master/synapse/res/templates>`_.
  88. Rolling back to v1.3.1
  89. ----------------------
  90. If you encounter problems with v1.4.0, it should be possible to roll back to
  91. v1.3.1, subject to the following:
  92. * The 'room statistics' engine was heavily reworked in this release (see
  93. `#5971 <https://github.com/matrix-org/synapse/pull/5971>`_), including
  94. significant changes to the database schema, which are not easily
  95. reverted. This will cause the room statistics engine to stop updating when
  96. you downgrade.
  97. The room statistics are essentially unused in v1.3.1 (in future versions of
  98. Synapse, they will be used to populate the room directory), so there should
  99. be no loss of functionality. However, the statistics engine will write errors
  100. to the logs, which can be avoided by setting the following in `homeserver.yaml`:
  101. .. code:: yaml
  102. stats:
  103. enabled: false
  104. Don't forget to re-enable it when you upgrade again, in preparation for its
  105. use in the room directory!
  106. Upgrading to v1.2.0
  107. ===================
  108. Some counter metrics have been renamed, with the old names deprecated. See
  109. `the metrics documentation <docs/metrics-howto.md#renaming-of-metrics--deprecation-of-old-names-in-12>`_
  110. for details.
  111. Upgrading to v1.1.0
  112. ===================
  113. Synapse v1.1.0 removes support for older Python and PostgreSQL versions, as
  114. outlined in `our deprecation notice <https://matrix.org/blog/2019/04/08/synapse-deprecating-postgres-9-4-and-python-2-x>`_.
  115. Minimum Python Version
  116. ----------------------
  117. Synapse v1.1.0 has a minimum Python requirement of Python 3.5. Python 3.6 or
  118. Python 3.7 are recommended as they have improved internal string handling,
  119. significantly reducing memory usage.
  120. If you use current versions of the Matrix.org-distributed Debian packages or
  121. Docker images, action is not required.
  122. If you install Synapse in a Python virtual environment, please see "Upgrading to
  123. v0.34.0" for notes on setting up a new virtualenv under Python 3.
  124. Minimum PostgreSQL Version
  125. --------------------------
  126. If using PostgreSQL under Synapse, you will need to use PostgreSQL 9.5 or above.
  127. Please see the
  128. `PostgreSQL documentation <https://www.postgresql.org/docs/11/upgrading.html>`_
  129. for more details on upgrading your database.
  130. Upgrading to v1.0
  131. =================
  132. Validation of TLS certificates
  133. ------------------------------
  134. Synapse v1.0 is the first release to enforce
  135. validation of TLS certificates for the federation API. It is therefore
  136. essential that your certificates are correctly configured. See the `FAQ
  137. <docs/MSC1711_certificates_FAQ.md>`_ for more information.
  138. Note, v1.0 installations will also no longer be able to federate with servers
  139. that have not correctly configured their certificates.
  140. In rare cases, it may be desirable to disable certificate checking: for
  141. example, it might be essential to be able to federate with a given legacy
  142. server in a closed federation. This can be done in one of two ways:-
  143. * Configure the global switch ``federation_verify_certificates`` to ``false``.
  144. * Configure a whitelist of server domains to trust via ``federation_certificate_verification_whitelist``.
  145. See the `sample configuration file <docs/sample_config.yaml>`_
  146. for more details on these settings.
  147. Email
  148. -----
  149. When a user requests a password reset, Synapse will send an email to the
  150. user to confirm the request.
  151. Previous versions of Synapse delegated the job of sending this email to an
  152. identity server. If the identity server was somehow malicious or became
  153. compromised, it would be theoretically possible to hijack an account through
  154. this means.
  155. Therefore, by default, Synapse v1.0 will send the confirmation email itself. If
  156. Synapse is not configured with an SMTP server, password reset via email will be
  157. disabled.
  158. To configure an SMTP server for Synapse, modify the configuration section
  159. headed ``email``, and be sure to have at least the ``smtp_host``, ``smtp_port``
  160. and ``notif_from`` fields filled out. You may also need to set ``smtp_user``,
  161. ``smtp_pass``, and ``require_transport_security``.
  162. If you are absolutely certain that you wish to continue using an identity
  163. server for password resets, set ``trust_identity_server_for_password_resets`` to ``true``.
  164. See the `sample configuration file <docs/sample_config.yaml>`_
  165. for more details on these settings.
  166. New email templates
  167. ---------------
  168. Some new templates have been added to the default template directory for the purpose of the
  169. homeserver sending its own password reset emails. If you have configured a custom
  170. ``template_dir`` in your Synapse config, these files will need to be added.
  171. ``password_reset.html`` and ``password_reset.txt`` are HTML and plain text templates
  172. respectively that contain the contents of what will be emailed to the user upon attempting to
  173. reset their password via email. ``password_reset_success.html`` and
  174. ``password_reset_failure.html`` are HTML files that the content of which (assuming no redirect
  175. URL is set) will be shown to the user after they attempt to click the link in the email sent
  176. to them.
  177. Upgrading to v0.99.0
  178. ====================
  179. Please be aware that, before Synapse v1.0 is released around March 2019, you
  180. will need to replace any self-signed certificates with those verified by a
  181. root CA. Information on how to do so can be found at `the ACME docs
  182. <docs/ACME.md>`_.
  183. For more information on configuring TLS certificates see the `FAQ <docs/MSC1711_certificates_FAQ.md>`_.
  184. Upgrading to v0.34.0
  185. ====================
  186. 1. This release is the first to fully support Python 3. Synapse will now run on
  187. Python versions 3.5, or 3.6 (as well as 2.7). We recommend switching to
  188. Python 3, as it has been shown to give performance improvements.
  189. For users who have installed Synapse into a virtualenv, we recommend doing
  190. this by creating a new virtualenv. For example::
  191. virtualenv -p python3 ~/synapse/env3
  192. source ~/synapse/env3/bin/activate
  193. pip install matrix-synapse
  194. You can then start synapse as normal, having activated the new virtualenv::
  195. cd ~/synapse
  196. source env3/bin/activate
  197. synctl start
  198. Users who have installed from distribution packages should see the relevant
  199. package documentation. See below for notes on Debian packages.
  200. * When upgrading to Python 3, you **must** make sure that your log files are
  201. configured as UTF-8, by adding ``encoding: utf8`` to the
  202. ``RotatingFileHandler`` configuration (if you have one) in your
  203. ``<server>.log.config`` file. For example, if your ``log.config`` file
  204. contains::
  205. handlers:
  206. file:
  207. class: logging.handlers.RotatingFileHandler
  208. formatter: precise
  209. filename: homeserver.log
  210. maxBytes: 104857600
  211. backupCount: 10
  212. filters: [context]
  213. console:
  214. class: logging.StreamHandler
  215. formatter: precise
  216. filters: [context]
  217. Then you should update this to be::
  218. handlers:
  219. file:
  220. class: logging.handlers.RotatingFileHandler
  221. formatter: precise
  222. filename: homeserver.log
  223. maxBytes: 104857600
  224. backupCount: 10
  225. filters: [context]
  226. encoding: utf8
  227. console:
  228. class: logging.StreamHandler
  229. formatter: precise
  230. filters: [context]
  231. There is no need to revert this change if downgrading to Python 2.
  232. We are also making available Debian packages which will run Synapse on
  233. Python 3. You can switch to these packages with ``apt-get install
  234. matrix-synapse-py3``, however, please read `debian/NEWS
  235. <https://github.com/matrix-org/synapse/blob/release-v0.34.0/debian/NEWS>`_
  236. before doing so. The existing ``matrix-synapse`` packages will continue to
  237. use Python 2 for the time being.
  238. 2. This release removes the ``riot.im`` from the default list of trusted
  239. identity servers.
  240. If ``riot.im`` is in your homeserver's list of
  241. ``trusted_third_party_id_servers``, you should remove it. It was added in
  242. case a hypothetical future identity server was put there. If you don't
  243. remove it, users may be unable to deactivate their accounts.
  244. 3. This release no longer installs the (unmaintained) Matrix Console web client
  245. as part of the default installation. It is possible to re-enable it by
  246. installing it separately and setting the ``web_client_location`` config
  247. option, but please consider switching to another client.
  248. Upgrading to v0.33.7
  249. ====================
  250. This release removes the example email notification templates from
  251. ``res/templates`` (they are now internal to the python package). This should
  252. only affect you if you (a) deploy your Synapse instance from a git checkout or
  253. a github snapshot URL, and (b) have email notifications enabled.
  254. If you have email notifications enabled, you should ensure that
  255. ``email.template_dir`` is either configured to point at a directory where you
  256. have installed customised templates, or leave it unset to use the default
  257. templates.
  258. Upgrading to v0.27.3
  259. ====================
  260. This release expands the anonymous usage stats sent if the opt-in
  261. ``report_stats`` configuration is set to ``true``. We now capture RSS memory
  262. and cpu use at a very coarse level. This requires administrators to install
  263. the optional ``psutil`` python module.
  264. We would appreciate it if you could assist by ensuring this module is available
  265. and ``report_stats`` is enabled. This will let us see if performance changes to
  266. synapse are having an impact to the general community.
  267. Upgrading to v0.15.0
  268. ====================
  269. If you want to use the new URL previewing API (/_matrix/media/r0/preview_url)
  270. then you have to explicitly enable it in the config and update your dependencies
  271. dependencies. See README.rst for details.
  272. Upgrading to v0.11.0
  273. ====================
  274. This release includes the option to send anonymous usage stats to matrix.org,
  275. and requires that administrators explictly opt in or out by setting the
  276. ``report_stats`` option to either ``true`` or ``false``.
  277. We would really appreciate it if you could help our project out by reporting
  278. anonymized usage statistics from your homeserver. Only very basic aggregate
  279. data (e.g. number of users) will be reported, but it helps us to track the
  280. growth of the Matrix community, and helps us to make Matrix a success, as well
  281. as to convince other networks that they should peer with us.
  282. Upgrading to v0.9.0
  283. ===================
  284. Application services have had a breaking API change in this version.
  285. They can no longer register themselves with a home server using the AS HTTP API. This
  286. decision was made because a compromised application service with free reign to register
  287. any regex in effect grants full read/write access to the home server if a regex of ``.*``
  288. is used. An attack where a compromised AS re-registers itself with ``.*`` was deemed too
  289. big of a security risk to ignore, and so the ability to register with the HS remotely has
  290. been removed.
  291. It has been replaced by specifying a list of application service registrations in
  292. ``homeserver.yaml``::
  293. app_service_config_files: ["registration-01.yaml", "registration-02.yaml"]
  294. Where ``registration-01.yaml`` looks like::
  295. url: <String> # e.g. "https://my.application.service.com"
  296. as_token: <String>
  297. hs_token: <String>
  298. sender_localpart: <String> # This is a new field which denotes the user_id localpart when using the AS token
  299. namespaces:
  300. users:
  301. - exclusive: <Boolean>
  302. regex: <String> # e.g. "@prefix_.*"
  303. aliases:
  304. - exclusive: <Boolean>
  305. regex: <String>
  306. rooms:
  307. - exclusive: <Boolean>
  308. regex: <String>
  309. Upgrading to v0.8.0
  310. ===================
  311. Servers which use captchas will need to add their public key to::
  312. static/client/register/register_config.js
  313. window.matrixRegistrationConfig = {
  314. recaptcha_public_key: "YOUR_PUBLIC_KEY"
  315. };
  316. This is required in order to support registration fallback (typically used on
  317. mobile devices).
  318. Upgrading to v0.7.0
  319. ===================
  320. New dependencies are:
  321. - pydenticon
  322. - simplejson
  323. - syutil
  324. - matrix-angular-sdk
  325. To pull in these dependencies in a virtual env, run::
  326. python synapse/python_dependencies.py | xargs -n 1 pip install
  327. Upgrading to v0.6.0
  328. ===================
  329. To pull in new dependencies, run::
  330. python setup.py develop --user
  331. This update includes a change to the database schema. To upgrade you first need
  332. to upgrade the database by running::
  333. python scripts/upgrade_db_to_v0.6.0.py <db> <server_name> <signing_key>
  334. Where `<db>` is the location of the database, `<server_name>` is the
  335. server name as specified in the synapse configuration, and `<signing_key>` is
  336. the location of the signing key as specified in the synapse configuration.
  337. This may take some time to complete. Failures of signatures and content hashes
  338. can safely be ignored.
  339. Upgrading to v0.5.1
  340. ===================
  341. Depending on precisely when you installed v0.5.0 you may have ended up with
  342. a stale release of the reference matrix webclient installed as a python module.
  343. To uninstall it and ensure you are depending on the latest module, please run::
  344. $ pip uninstall syweb
  345. Upgrading to v0.5.0
  346. ===================
  347. The webclient has been split out into a seperate repository/pacakage in this
  348. release. Before you restart your homeserver you will need to pull in the
  349. webclient package by running::
  350. python setup.py develop --user
  351. This release completely changes the database schema and so requires upgrading
  352. it before starting the new version of the homeserver.
  353. The script "database-prepare-for-0.5.0.sh" should be used to upgrade the
  354. database. This will save all user information, such as logins and profiles,
  355. but will otherwise purge the database. This includes messages, which
  356. rooms the home server was a member of and room alias mappings.
  357. If you would like to keep your history, please take a copy of your database
  358. file and ask for help in #matrix:matrix.org. The upgrade process is,
  359. unfortunately, non trivial and requires human intervention to resolve any
  360. resulting conflicts during the upgrade process.
  361. Before running the command the homeserver should be first completely
  362. shutdown. To run it, simply specify the location of the database, e.g.:
  363. ./scripts/database-prepare-for-0.5.0.sh "homeserver.db"
  364. Once this has successfully completed it will be safe to restart the
  365. homeserver. You may notice that the homeserver takes a few seconds longer to
  366. restart than usual as it reinitializes the database.
  367. On startup of the new version, users can either rejoin remote rooms using room
  368. aliases or by being reinvited. Alternatively, if any other homeserver sends a
  369. message to a room that the homeserver was previously in the local HS will
  370. automatically rejoin the room.
  371. Upgrading to v0.4.0
  372. ===================
  373. This release needs an updated syutil version. Run::
  374. python setup.py develop
  375. You will also need to upgrade your configuration as the signing key format has
  376. changed. Run::
  377. python -m synapse.app.homeserver --config-path <CONFIG> --generate-config
  378. Upgrading to v0.3.0
  379. ===================
  380. This registration API now closely matches the login API. This introduces a bit
  381. more backwards and forwards between the HS and the client, but this improves
  382. the overall flexibility of the API. You can now GET on /register to retrieve a list
  383. of valid registration flows. Upon choosing one, they are submitted in the same
  384. way as login, e.g::
  385. {
  386. type: m.login.password,
  387. user: foo,
  388. password: bar
  389. }
  390. The default HS supports 2 flows, with and without Identity Server email
  391. authentication. Enabling captcha on the HS will add in an extra step to all
  392. flows: ``m.login.recaptcha`` which must be completed before you can transition
  393. to the next stage. There is a new login type: ``m.login.email.identity`` which
  394. contains the ``threepidCreds`` key which were previously sent in the original
  395. register request. For more information on this, see the specification.
  396. Web Client
  397. ----------
  398. The VoIP specification has changed between v0.2.0 and v0.3.0. Users should
  399. refresh any browser tabs to get the latest web client code. Users on
  400. v0.2.0 of the web client will not be able to call those on v0.3.0 and
  401. vice versa.
  402. Upgrading to v0.2.0
  403. ===================
  404. The home server now requires setting up of SSL config before it can run. To
  405. automatically generate default config use::
  406. $ python synapse/app/homeserver.py \
  407. --server-name machine.my.domain.name \
  408. --bind-port 8448 \
  409. --config-path homeserver.config \
  410. --generate-config
  411. This config can be edited if desired, for example to specify a different SSL
  412. certificate to use. Once done you can run the home server using::
  413. $ python synapse/app/homeserver.py --config-path homeserver.config
  414. See the README.rst for more information.
  415. Also note that some config options have been renamed, including:
  416. - "host" to "server-name"
  417. - "database" to "database-path"
  418. - "port" to "bind-port" and "unsecure-port"
  419. Upgrading to v0.0.1
  420. ===================
  421. This release completely changes the database schema and so requires upgrading
  422. it before starting the new version of the homeserver.
  423. The script "database-prepare-for-0.0.1.sh" should be used to upgrade the
  424. database. This will save all user information, such as logins and profiles,
  425. but will otherwise purge the database. This includes messages, which
  426. rooms the home server was a member of and room alias mappings.
  427. Before running the command the homeserver should be first completely
  428. shutdown. To run it, simply specify the location of the database, e.g.:
  429. ./scripts/database-prepare-for-0.0.1.sh "homeserver.db"
  430. Once this has successfully completed it will be safe to restart the
  431. homeserver. You may notice that the homeserver takes a few seconds longer to
  432. restart than usual as it reinitializes the database.
  433. On startup of the new version, users can either rejoin remote rooms using room
  434. aliases or by being reinvited. Alternatively, if any other homeserver sends a
  435. message to a room that the homeserver was previously in the local HS will
  436. automatically rejoin the room.