mailtrain icon indicating copy to clipboard operation
mailtrain copied to clipboard

Mailtrain systemd service failed to due database error (Ubuntu 20.04)

Open linuxbabe opened this issue 3 years ago • 6 comments

I was trying to install a new instance of Mailtrain (without Docker). When starting the mailtrain systemd service (systemctl start mailtrain), it failed.

Here is the log (sudo journalctl -eu mailtrain)

Apr 06 10:16:58 ubuntu systemd[1]: Started Mailtrain server.
Apr 06 10:17:01 ubuntu node[850334]: info Using local auth 
Apr 06 10:17:02 ubuntu node[850334]: info sql Database check completed
Apr 06 10:17:02 ubuntu node[850334]: migration file "20200617172500_add_channels.js" failed
Apr 06 10:17:02 ubuntu node[850334]: migration failed with error: create table `channels` (`id` int unsigned not null auto_increment primary key, `cid` varchar(255) collate 'utf8_general_ci', >
Apr 06 10:17:02 ubuntu node[850334]: ERR! Error: ER_TABLE_EXISTS_ERROR: Table 'channels' already exists
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Query.Sequence._packetToError (/var/www/mailtrainv2/server/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Query.ErrorPacket (/var/www/mailtrainv2/server/node_modules/mysql/lib/protocol/sequences/Query.js:77:18)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Protocol._parsePacket (/var/www/mailtrainv2/server/node_modules/mysql/lib/protocol/Protocol.js:291:23)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Parser._parsePacket (/var/www/mailtrainv2/server/node_modules/mysql/lib/protocol/Parser.js:433:10)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Parser.write (/var/www/mailtrainv2/server/node_modules/mysql/lib/protocol/Parser.js:43:10)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Protocol.write (/var/www/mailtrainv2/server/node_modules/mysql/lib/protocol/Protocol.js:38:16)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Socket. (/var/www/mailtrainv2/server/node_modules/mysql/lib/Connection.js:91:28)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Socket. (/var/www/mailtrainv2/server/node_modules/mysql/lib/Connection.js:525:10)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Socket.emit (events.js:400:28)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Socket.emit (domain.js:475:12)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at addChunk (internal/streams/readable.js:293:12)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at readableAddChunk (internal/streams/readable.js:267:9)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Socket.Readable.push (internal/streams/readable.js:206:10)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     --------------------
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Protocol._enqueue (/var/www/mailtrainv2/server/node_modules/mysql/lib/protocol/Protocol.js:144:48)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Connection.query (/var/www/mailtrainv2/server/node_modules/mysql/lib/Connection.js:201:25)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at /var/www/mailtrainv2/server/node_modules/knex/lib/dialects/mysql/index.js:144:18
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Promise._execute (/var/www/mailtrainv2/server/node_modules/bluebird/js/release/debuggability.js:384:9)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Promise._resolveFromExecutor (/var/www/mailtrainv2/server/node_modules/bluebird/js/release/promise.js:518:18)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at new Promise (/var/www/mailtrainv2/server/node_modules/bluebird/js/release/promise.js:103:10)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Client_MySQL._query (/var/www/mailtrainv2/server/node_modules/knex/lib/dialects/mysql/index.js:135:12)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Client_MySQL.query (/var/www/mailtrainv2/server/node_modules/knex/lib/client.js:192:17)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at /var/www/mailtrainv2/server/node_modules/knex/lib/transaction.js:232:21
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at tryCatcher (/var/www/mailtrainv2/server/node_modules/bluebird/js/release/util.js:16:23)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Function.Promise.attempt.Promise.try (/var/www/mailtrainv2/server/node_modules/bluebird/js/release/method.js:39:29)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Client_MySQL.trxClient.query (/var/www/mailtrainv2/server/node_modules/knex/lib/transaction.js:229:33)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Runner. (/var/www/mailtrainv2/server/node_modules/knex/lib/runner.js:138:36)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Runner.tryCatcher (/var/www/mailtrainv2/server/node_modules/bluebird/js/release/util.js:16:23)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Runner.query (/var/www/mailtrainv2/server/node_modules/bluebird/js/release/method.js:15:34)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Runner. (/var/www/mailtrainv2/server/node_modules/knex/lib/runner.js:208:19)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Runner.tryCatcher (/var/www/mailtrainv2/server/node_modules/bluebird/js/release/util.js:16:23)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Object.gotValue (/var/www/mailtrainv2/server/node_modules/bluebird/js/release/reduce.js:168:18)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Object.gotAccum (/var/www/mailtrainv2/server/node_modules/bluebird/js/release/reduce.js:155:25)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Object.tryCatcher (/var/www/mailtrainv2/server/node_modules/bluebird/js/release/util.js:16:23)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Promise._settlePromiseFromHandler (/var/www/mailtrainv2/server/node_modules/bluebird/js/release/promise.js:547:31)
Apr 06 10:17:02 ubuntu node[850334]: ERR!     at Promise._settlePromise (/var/www/mailtrainv2/server/node_modules/bluebird/js/release/promise.js:604:18)

It looks like when the mailtrain systemd service starts the first time, it will populate the database by using the server/setup/sql/mailtrain.sql file. However, the migration file 20200617172500_add_channels.js then tries to re-create the channels table, so it failed.

Any idea how to fix this? Thanks.

linuxbabe avatar Apr 06 '22 02:04 linuxbabe

@linuxbabe how did you install it? Can you give me the process steps? :)

Then I can test in on one my systems.

forgeOneHQ avatar Apr 06 '22 14:04 forgeOneHQ

@talheim-it I wrote a tutorial about a year ago here: https://www.linuxbabe.com/ubuntu/install-mailtrain-v2-ubuntu-20-04 It worked like a charm, but now I install a new Mailtrain instance with the same steps, the above error occurred.

linuxbabe avatar Apr 06 '22 15:04 linuxbabe

@linuxbabe okay, I ran one of the installer script for ubuntu for this but I will check it on a local testserver with vagrant.

I will be able to do it around the weekend if you can wait a bit fot his.

forgeOneHQ avatar Apr 06 '22 16:04 forgeOneHQ

Thanks. I can wait.

linuxbabe avatar Apr 07 '22 01:04 linuxbabe

@linuxbabe okay, I ran one of the installer script for ubuntu for this but I will check it on a local testserver with vagrant.

I will be able to do it around the weekend if you can wait a bit fot his.

So uh… a few weekends have passed..

mawesome4ever avatar Nov 30 '23 07:11 mawesome4ever

@mawesome4ever @linuxbabe I talked to @bures and we are in communication about to update mailtrain initially, the packages to get back to a functional version with latest packages.

I will also make a security check.

I will keep you updated here.

forgeOneHQ avatar Jan 24 '24 18:01 forgeOneHQ

We are going to start with the development and testing of mailtrain v3 in the next weeks.

You are welcome to help us with the testing as soon as the first release candidate is available.

forgeOneHQ avatar Mar 16 '24 09:03 forgeOneHQ