Skip to content

Commit 17f51ef

Browse files
isacikgozcwarnermmnab-77
authored
[MM-55744] postgres-migration: add findings from mysql8 migration (#6820)
* postgres-migration: add findings from mysql8 migration * Update source/deploy/postgres-migration.rst * [MM-55998] incorporate more findings from community (#6822) * incorporate more findings from community * Update source/deploy/postgres-migration.rst * Update source/deploy/postgres-migration.rst * reflect review comments --------- Co-authored-by: Carrie Warner (Mattermost) <[email protected]> * Update source/deploy/postgres-migration.rst Co-authored-by: Neil B <[email protected]> --------- Co-authored-by: Carrie Warner (Mattermost) <[email protected]> Co-authored-by: Neil B <[email protected]>
1 parent a15fe5a commit 17f51ef

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

source/deploy/postgres-migration.rst

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ Required tools
2222

2323
- Install ``pgLoader``. See the official `installation
2424
guide <https://pgloader.readthedocs.io/en/latest/install.html>`__.
25+
26+
.. note::
27+
- If you are using MySQL v8: Due to a `known bug <https://github.com/dimitri/pgloader/issues/1183>`__ in pgLoader compiled binaries, you need to compile pgLoader from the source. Please follow the steps `here <https://pgloader.readthedocs.io/en/latest/install.html#build-from-sources>`__ to build from the source.
28+
- We have received reports that the pgloader Docker image can be limited in terms of memory resources. Please use pgloader directly instead of a Docker container.
29+
2530
- Install morph CLI by running the following command:
2631

2732
- ``go install github.com/mattermost/morph/cmd/morph@v1``
@@ -41,6 +46,7 @@ Before the migration
4146
- Determine the migration window needed. This process requires you to stop the Mattermost Server during the migration.
4247
- See the `schema-diffs <#schema-diffs>`__ section to ensure data compatibility between schemas.
4348
- Prepare your PostgreSQL environment by creating a database and user. See the `database </install/prepare-mattermost-database.html>`__ documentation for details.
49+
- If you are planning to run an iterative migration (running the pgloader several times), please see :ref:`iterative-migrations` section.
4450

4551
Prepare target database
4652
-----------------------
@@ -102,13 +108,23 @@ Full-text indexes
102108

103109
It's possible that some words in the ``Posts`` and ``FileInfo`` tables can exceed the `limits of the maximum token length <https://www.postgresql.org/docs/11/textsearch-limitations.html>`__ for full text search indexing. In these cases, we recommend dropping the ``idx_posts_message_txt`` and ``idx_fileinfo_content_txt`` indexes from the PostgreSQL schema, and creating these indexes after the migration by running the following queries:
104110

105-
To drop indexes, run the following commands before the migration (These are included in the script, so you may not need to run these manually):
111+
To drop indexes, run the following commands before the migration. Although these statements are included in the script, we recommend running these manually to prevent errors:
106112

107113
.. code:: sql
108114
109115
DROP INDEX IF EXISTS idx_posts_message_txt;
110116
DROP INDEX IF EXISTS idx_fileinfo_content_txt;
111117
118+
Also make sure these indexes are re-created after the migration is completed. You can simply run the following queries to re-create these indexes:
119+
120+
.. code:: sql
121+
122+
CREATE INDEX IF NOT EXISTS idx_posts_message_txt ON {{ .source_schema }}.posts USING gin(to_tsvector('english', message));
123+
CREATE INDEX IF NOT EXISTS idx_fileinfo_content_txt ON {{ .source_schema }}.fileinfo USING gin(to_tsvector('english', content));
124+
125+
.. note::
126+
If any of the entries in your ``Posts`` and ``FileInfo`` tables exceed the limit, ``pgloader`` will fail with ``ERROR: string is too long for tsvector`` error while trying to create these indexes. You should remove these statements from the ``pgloader`` configuration.
127+
112128
Artifacts may remain from previous configurations/versions
113129
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
114130

@@ -396,3 +412,24 @@ Compare the plugin data
396412
.. code:: sh
397413
398414
dbcmp --source "${MYSQL_DSN}" --target "${POSTGRES_DSN}" --exclude="db_migrations,systems"
415+
416+
Iterative migrations
417+
-------------------
418+
419+
There are several steps in the pgloader configuration file that assume migration will take place in one go. If you are planning to run the migration over and over again, please complete the changes defined below:
420+
421+
- Discard all of the statments defined in the ``BEFORE LOAD DO`` and ``AFTER LOAD DO`` sections.
422+
- Run the statments defined in ``BEFORE LOAD DO`` section only once before the migration.
423+
- Once the migration is completed, run the statments defined in the ``AFTER LOAD DO`` section manually.
424+
425+
Troubleshooting
426+
-----------------
427+
428+
Unsupported authentication for MySQL
429+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
430+
431+
If you are facing an error due to authentication with MySQL v8, it may be related to a `known issue <https://github.com/dimitri/pgloader/issues/782>`__ with the pgLoader. The fix is to set default authentication method to ``mysql_native_password`` in your MySQL configuration. To do so, add the ``default-authentication-plugin=mysql_native_password`` value to your ``mysql.cnf`` file. Also do not forget to update your user to use this authentication method.
432+
433+
.. code:: sql
434+
435+
ALTER USER '<mysql_user>'@'%' IDENTIFIED WITH mysql_native_password BY '<mysql_password>';

0 commit comments

Comments
 (0)