How did you install Ghost?
Installed using the guide on the Ghost site on Ubuntu
Provide details of your host & operating system
I’ve tested this by running the same snapshot on servers with 4gb or 8gb of memory.
Database type
MySQL 8
Ver 8.0.37-0ubuntu0.22.04.3 for Linux on x86_64 ((Ubuntu))
Relevant log / error output
[2024-06-13 19:45:57] INFO Ghost is running in production…
[2024-06-13 19:45:57] INFO Your site is now available on ------
[2024-06-13 19:45:57] INFO Ctrl+C to shut down
[2024-06-13 19:45:57] INFO Ghost server started in 0.812s
[2024-06-13 19:45:57] INFO Database is in a ready state.
[2024-06-13 19:45:57] INFO Ghost database ready in 1.091s
You are likely running out of some resource. Try again, but this time prepare in advance by making several more terminal windows open to the server to create a dashboard of what’s happening. In different windows:
Logs. journalctl -fu ‘ghost*’
htop. Watch memory and CPU
df -h. Run it repeatedly to see if you are running out of disk space
After this experiment you should have a clearer idea of the resources and logging
during the failed backup.
export NODE_OPTIONS=--max_old_space_size=4096
ghost run
and now can see this error:
[2024-06-19 19:30:08] ERROR "GET /blog/ghost/api/admin/db/" 500 17483ms
An unexpected error occurred, please try again.
"Invalid string length"
Error ID:
569046a0-2e72-11ef-80d8-ff9031b6d30c
Error Code:
UNEXPECTED_ERROR
----------------------------------------
RangeError: Invalid string length
at module.exports.prepareError (/var/www/blog/versions/5.52.1/node_modules/@tryghost/mw-error-handler/lib/mw-error-handler.js:92:19)
at JSON.stringify (<anonymous>)
at stringify (/var/www/blog/versions/5.52.1/node_modules/express/lib/response.js:1150:12)
at ServerResponse.json (/var/www/blog/versions/5.52.1/node_modules/express/lib/response.js:271:14)
at send (/var/www/blog/versions/5.52.1/node_modules/@tryghost/api-framework/lib/http.js:94:21)
at /var/www/blog/versions/5.52.1/node_modules/@tryghost/api-framework/lib/http.js:115:13
To try to resolve this, I’ve attempted to update my ghost instance to the latest version. However, when trying to start, I get another issue:
Message: Ghost was able to start, but errored during boot with: Migration lock was never released or currently a migration is running.
Help: If you are sure no migration is running, check your data and if your database is in a broken state, you could run `yarn knex-migrator rollback`.
Suggestion: journalctl -u ghost_test-blog-nominis-es -n 50
checking the logs, I see:
MigrationsAreLockedError: Migration lock was never released or currently a migration is running.
at /var/www/blog/versions/5.85.1/node_modules/knex-migrator/lib/locking.js:62:23
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async DatabaseStateManager.getState (/var/www/blog/versions/5.85.1/core/server/data/db/DatabaseStateManager.js:40:13)
at async DatabaseStateManager.makeReady (/var/www/blog/versions/5.85.1/core/server/data/db/DatabaseStateManager.js:73:25)
at async initDatabase (/var/www/blog/versions/5.85.1/core/boot.js:69:5)
at async bootGhost (/var/www/blog/versions/5.85.1/core/boot.js:537:9)
I tried to change the lock flag in the database, but every time I start Ghost, the lock enables and I get this error.
I was unable to get the migrations to work. After digging a bit more, I found that the stringified JSON response exceeds the maximum string size for Nodejs and I’m unable to increase it.
I’m focused on doing a mysql dump and importing that into a new database.
Maybe the Ghost team can figure out a way of doing an export/import with 12,000 posts in the future.
Thanks for the update. This sounds like a bug with Ghost, so I’m moving this to the bugs category.
There should be another way to generate the JSON that doesn’t trigger this. For example, streaming the write of the JSON would only ever hold a limited amount of the JSON in memory.