Issue Summary
I was doing a ghost update batch job in one terminal window and for whatever reason I decided to do a ghost-cli and npm update in another terminal window on the same server… Little did I know… that it will blow up in my face.
Right now no cli command works anymore, it outputs the below error message. I tried to remove /usr/bin/ghost as well as /usr/lib/node_modules/ghost-cli and reinstall ghost-cli but it seems that some mysql connection is stuck somewhere and I don’t know how to unstuck it. Any ghost command (including ghost doctor) fails with the below error. Any help is highly appreciated. Thanks!
Steps to Reproduce
Run sudo npm install -g ghost-cli@latest while there’s a ghost update process runing…
Run also sudo npm install -g npm while there’s a ghost update process running…
Setup information
Ghost Version 4.41.1 to 4.41.2
Node.js Version 14.19.1
How did you install Ghost? Ghost was installed through ghost install cli command a long time ago.
Provide details of your host & operating system Ubuntu 20.04.4
Database type MariaDB 10.3.34
Browser & OS version N/A
Relevant log / error output
OS: Ubuntu, v20.04.4 LTS
Node Version: v14.19.1
Ghost-CLI Version: 1.19.0
Environment: production
Command: 'ghost ls'
An error occurred.
Message: 'Can't add new command when connection is in closed state'
Stack: Error: Can't add new command when connection is in closed state
at Connection._addCommandClosedState (/usr/lib/node_modules/ghost-cli/node_modules/mysql2/lib/connection.js:148:17)
at Connection.end (/usr/lib/node_modules/ghost-cli/node_modules/mysql2/lib/connection.js:855:26)
at MySQLExtension.isDeprecated (/usr/lib/node_modules/ghost-cli/extensions/mysql/index.js:64:25)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async /usr/lib/node_modules/ghost-cli/lib/utils/deprecation-checks.js:54:43
at async Promise.all (index 3)
at async deprecationChecks (/usr/lib/node_modules/ghost-cli/lib/utils/deprecation-checks.js:36:38)```
Hey @dsecareanu! Sorry about that! Would you be able to update to Ghost-CLI v1.19.1 with sudo npm install -g ghost-cli@latest - I think that should stop CLI erroring out
@dsecareanu I believe I’ve found the issue and I’ve published Ghost-CLI 1.19.2. Would you be able to give that a go? - sudo npm install -g ghost-cli@latest
The problem does not seem so easy to resolve when running ghost on a docker container …
Today the site has gone down, not only my site, others that are running on docker with the same configuration are with there sites down.
Can someone take a look?
Here is the log:
ERROR alter table `members_cancel_events` add constraint `members_cancel_events_member_id_foreign` foreign key (`member_id`) references `members` (`id`) on delete CASCADE - Referencing column 'member_id' and referenced column 'id' in foreign key constraint 'members_cancel_events_member_id_foreign' are incompatible.
alter table `members_cancel_events` add constraint `members_cancel_events_member_id_foreign` foreign key (`member_id`) references `members` (`id`) on delete CASCADE - Referencing column 'member_id' and referenced column 'id' in foreign key constraint 'members_cancel_events_member_id_foreign' are incompatible.
{"config":{"transaction":false},"name":"2022-03-07-14-37-add-members-cancel-events-table.js"}
"Error occurred while executing the following migration: 2022-03-07-14-37-add-members-cancel-events-table.js"
Error ID:
300
----------------------------------------
MigrationScriptError: alter table `members_cancel_events` add constraint `members_cancel_events_member_id_foreign` foreign key (`member_id`) references `members` (`id`) on delete CASCADE - Referencing column 'member_id' and referenced column 'id' in foreign key constraint 'members_cancel_events_member_id_foreign' are incompatible.
at DatabaseStateManager.makeReady (/var/lib/ghost/versions/4.40.0/core/server/data/db/state-manager.js:95:32)
at MigrationScriptError.KnexMigrateError (/var/lib/ghost/versions/4.40.0/node_modules/knex-migrator/lib/errors.js:7:26)
at new MigrationScriptError (/var/lib/ghost/versions/4.40.0/node_modules/knex-migrator/lib/errors.js:25:26)
at /var/lib/ghost/versions/4.40.0/node_modules/knex-migrator/lib/index.js:1032:19
at processTicksAndRejections (internal/process/task_queues.js:95:5)
Error: alter table `members_cancel_events` add constraint `members_cancel_events_member_id_foreign` foreign key (`member_id`) references `members` (`id`) on delete CASCADE - Referencing column 'member_id' and referenced column 'id' in foreign key constraint 'members_cancel_events_member_id_foreign' are incompatible.
at Packet.asError (/var/lib/ghost/versions/4.40.0/node_modules/mysql2/lib/packets/packet.js:728:17)
at Query.execute (/var/lib/ghost/versions/4.40.0/node_modules/mysql2/lib/commands/command.js:29:26)
at Connection.handlePacket (/var/lib/ghost/versions/4.40.0/node_modules/mysql2/lib/connection.js:456:32)
at PacketParser.onPacket (/var/lib/ghost/versions/4.40.0/node_modules/mysql2/lib/connection.js:85:12)
at PacketParser.executeStart (/var/lib/ghost/versions/4.40.0/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.<anonymous> (/var/lib/ghost/versions/4.40.0/node_modules/mysql2/lib/connection.js:92:25)
at Socket.emit (events.js:400:28)
at addChunk (internal/streams/readable.js:293:12)
at readableAddChunk (internal/streams/readable.js:267:9)
at Socket.Readable.push (internal/streams/readable.js:206:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
[2022-03-23 20:09:46] WARN Ghost is shutting down
[2022-03-23 20:09:46] WARN Ghost has shut down
[2022-03-23 20:09:46] WARN Your site is now offline
[2022-03-23 20:09:46] WARN Ghost was running for a few seconds
Using on the docker composer the command suggested doesn’t seems to resolver
Still errors after this change. I was already running with mysql version 8 before this error showed
by now the information regarding de default character set is showing as utf8mb4
ERROR create table `members_cancel_events` (`id` varchar(24) not null, `member_id` varchar(24) not null, `from_plan` varchar(255) not null, `created_at` datetime not null) default character set utf8mb4 - Tablespace '`db`.`members_cancel_events`' exists.
create table `members_cancel_events` (`id` varchar(24) not null, `member_id` varchar(24) not null, `from_plan` varchar(255) not null, `created_at` datetime not null) default character set utf8mb4 - Tablespace '`db`.`members_cancel_events`' exists.
{"config":{"transaction":false},"name":"2022-03-07-14-37-add-members-cancel-events-table.js"}
"Error occurred while executing the following migration: 2022-03-07-14-37-add-members-cancel-events-table.js"
Error ID:
300
Error Code:
ER_TABLESPACE_EXISTS
----------------------------------------
MigrationScriptError: create table `members_cancel_events` (`id` varchar(24) not null, `member_id` varchar(24) not null, `from_plan` varchar(255) not null, `created_at` datetime not null) default character set utf8mb4 - Tablespace '`db`.`members_cancel_events`' exists.
at DatabaseStateManager.makeReady (/var/lib/ghost/versions/4.40.0/core/server/data/db/state-manager.js:95:32)
at MigrationScriptError.KnexMigrateError (/var/lib/ghost/versions/4.40.0/node_modules/knex-migrator/lib/errors.js:7:26)
at new MigrationScriptError (/var/lib/ghost/versions/4.40.0/node_modules/knex-migrator/lib/errors.js:25:26)
at /var/lib/ghost/versions/4.40.0/node_modules/knex-migrator/lib/index.js:1032:19
at processTicksAndRejections (internal/process/task_queues.js:95:5)
Error: create table `members_cancel_events` (`id` varchar(24) not null, `member_id` varchar(24) not null, `from_plan` varchar(255) not null, `created_at` datetime not null) default character set utf8mb4 - Tablespace '`db`.`members_cancel_events`' exists.
at Packet.asError (/var/lib/ghost/versions/4.40.0/node_modules/mysql2/lib/packets/packet.js:728:17)
at Query.execute (/var/lib/ghost/versions/4.40.0/node_modules/mysql2/lib/commands/command.js:29:26)
at Connection.handlePacket (/var/lib/ghost/versions/4.40.0/node_modules/mysql2/lib/connection.js:456:32)
at PacketParser.onPacket (/var/lib/ghost/versions/4.40.0/node_modules/mysql2/lib/connection.js:85:12)
at PacketParser.executeStart (/var/lib/ghost/versions/4.40.0/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.<anonymous> (/var/lib/ghost/versions/4.40.0/node_modules/mysql2/lib/connection.js:92:25)
at Socket.emit (events.js:400:28)
at addChunk (internal/streams/readable.js:293:12)
at readableAddChunk (internal/streams/readable.js:267:9)
at Socket.Readable.push (internal/streams/readable.js:206:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)