Search code examples
mysqldockerperconaxtradb

Recover Percona Xtradb in container


I have Percona Xtradb Cluster running on container.

I stopped the container and then started it.

I have error:

2017-02-11T13:12:00.423566Z 0 [ERROR] Found 1 prepared transactions! It means that mysqld was not shut down properly last time and critical recovery information (last binlog or tc.log file) was manually deleted after a crash. You have to start mysqld with --tc-heuristic-recover switch to commit or rollback pending transactions.

2017-02-11T13:12:00.423739Z 0 [ERROR] Aborting

The message says that I need mysqld --tc-heuristic-recover but container stops after mysql fails to start.

My questions are:

  • How can I fix this problem not to run new container but start existing one?

  • Is there any way to make Docker container still running after main process (mysqld) is stopped?


Solution

  • That container uses volumes (see here), so your data is not inside the container.

    To find where it is stored, use docker container inspect YOUR_CONTAINER_NAME, and search for Mounts in the output. If you have jqinstalled you can use something like

    $ docker container inspect YOUR_CONTAINER_NAME | jq ".[0].Mounts"
    

    Once you found the directory where the data is stored, you should create a backup.

    You can then create a new container, with a bind to that directory. Something like

    $ docker run -it -v VOLUME_PATH:/var/lib/mysql OTHER_OPTIONS_HERE image_name /bin/sh
    

    This should give you a shell where you can execute any commands you may need.

    Once you finished, you can delete this container, and hopefully the percona one should now work.