Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

database is locked #278

Closed
klapvogn opened this issue Jul 10, 2022 · 16 comments · Fixed by #341
Closed

database is locked #278

klapvogn opened this issue Jul 10, 2022 · 16 comments · Fixed by #341
Labels
bug Something isn't working

Comments

@klapvogn
Copy link

I have gotten this error a lot lately though I have made a config error in the conf. so I made a new one. But the error was back

(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 21)

(node:1) UnhandledPromiseRejectionWarning: SqliteError: select last_run from job_log where name = 'search' limit 1 - database is locked

at Statement.all (<anonymous>)

at Client_BetterSQLite3._query (/usr/src/app/node_modules/knex/lib/dialects/better-sqlite3/index.js:34:40)

at executeQuery (/usr/src/app/node_modules/knex/lib/execution/internal/query-executioner.js:37:17)

at Client_BetterSQLite3.query (/usr/src/app/node_modules/knex/lib/client.js:146:12)

at Runner.query (/usr/src/app/node_modules/knex/lib/execution/runner.js:130:36)

at ensureConnectionCallback (/usr/src/app/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:13:17)

at Runner.ensureConnection (/usr/src/app/node_modules/knex/lib/execution/runner.js:307:20)

at async Runner.run (/usr/src/app/node_modules/knex/lib/execution/runner.js:30:19)

at async Timeout.loop [as _onTimeout] (file:///usr/src/app/dist/jobs.js:43:36)

(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 24)

(node:1) UnhandledPromiseRejectionWarning: SqliteError: select last_run from job_log where name = 'search' limit 1 - database is locked

at Statement.all (<anonymous>)

at Client_BetterSQLite3._query (/usr/src/app/node_modules/knex/lib/dialects/better-sqlite3/index.js:34:40)

at executeQuery (/usr/src/app/node_modules/knex/lib/execution/internal/query-executioner.js:37:17)

at Client_BetterSQLite3.query (/usr/src/app/node_modules/knex/lib/client.js:146:12)

at Runner.query (/usr/src/app/node_modules/knex/lib/execution/runner.js:130:36)

at ensureConnectionCallback (/usr/src/app/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:13:17)

at Runner.ensureConnection (/usr/src/app/node_modules/knex/lib/execution/runner.js:307:20)

at async Runner.run (/usr/src/app/node_modules/knex/lib/execution/runner.js:30:19)

at async Timeout.loop [as _onTimeout] (file:///usr/src/app/dist/jobs.js:43:36)

(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 27)

(node:1) UnhandledPromiseRejectionWarning: SqliteError: select last_run from job_log where name = 'search' limit 1 - database is locked

at Statement.all (<anonymous>)

at Client_BetterSQLite3._query (/usr/src/app/node_modules/knex/lib/dialects/better-sqlite3/index.js:34:40)

at executeQuery (/usr/src/app/node_modules/knex/lib/execution/internal/query-executioner.js:37:17)

at Client_BetterSQLite3.query (/usr/src/app/node_modules/knex/lib/client.js:146:12)

at Runner.query (/usr/src/app/node_modules/knex/lib/execution/runner.js:130:36)

at ensureConnectionCallback (/usr/src/app/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:13:17)

at Runner.ensureConnection (/usr/src/app/node_modules/knex/lib/execution/runner.js:307:20)

at async Runner.run (/usr/src/app/node_modules/knex/lib/execution/runner.js:30:19)

at async Timeout.loop [as _onTimeout] (file:///usr/src/app/dist/jobs.js:43:36)

(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 30)

(node:1) UnhandledPromiseRejectionWarning: SqliteError: select last_run from job_log where name = 'search' limit 1 - database is locked

at Statement.all (<anonymous>)

at Client_BetterSQLite3._query (/usr/src/app/node_modules/knex/lib/dialects/better-sqlite3/index.js:34:40)

at executeQuery (/usr/src/app/node_modules/knex/lib/execution/internal/query-executioner.js:37:17)

at Client_BetterSQLite3.query (/usr/src/app/node_modules/knex/lib/client.js:146:12)

at Runner.query (/usr/src/app/node_modules/knex/lib/execution/runner.js:130:36)

at ensureConnectionCallback (/usr/src/app/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:13:17)

at Runner.ensureConnection (/usr/src/app/node_modules/knex/lib/execution/runner.js:307:20)

at async Runner.run (/usr/src/app/node_modules/knex/lib/execution/runner.js:30:19)

at async Timeout.loop [as _onTimeout] (file:///usr/src/app/dist/jobs.js:43:36)

(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 33)

(node:1) UnhandledPromiseRejectionWarning: SqliteError: select last_run from job_log where name = 'search' limit 1 - database is locked

at Statement.all (<anonymous>)

at Client_BetterSQLite3._query (/usr/src/app/node_modules/knex/lib/dialects/better-sqlite3/index.js:34:40)

at executeQuery (/usr/src/app/node_modules/knex/lib/execution/internal/query-executioner.js:37:17)

at Client_BetterSQLite3.query (/usr/src/app/node_modules/knex/lib/client.js:146:12)

at Runner.query (/usr/src/app/node_modules/knex/lib/execution/runner.js:130:36)

at ensureConnectionCallback (/usr/src/app/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:13:17)

at Runner.ensureConnection (/usr/src/app/node_modules/knex/lib/execution/runner.js:307:20)

at async Runner.run (/usr/src/app/node_modules/knex/lib/execution/runner.js:30:19)

at async Timeout.loop [as _onTimeout] (file:///usr/src/app/dist/jobs.js:43:36)

(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 36)

(node:1) UnhandledPromiseRejectionWarning: SqliteError: select last_run from job_log where name = 'search' limit 1 - database is locked

at Statement.all (<anonymous>)

at Client_BetterSQLite3._query (/usr/src/app/node_modules/knex/lib/dialects/better-sqlite3/index.js:34:40)

at executeQuery (/usr/src/app/node_modules/knex/lib/execution/internal/query-executioner.js:37:17)

at Client_BetterSQLite3.query (/usr/src/app/node_modules/knex/lib/client.js:146:12)

at Runner.query (/usr/src/app/node_modules/knex/lib/execution/runner.js:130:36)

at ensureConnectionCallback (/usr/src/app/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:13:17)

at Runner.ensureConnection (/usr/src/app/node_modules/knex/lib/execution/runner.js:307:20)

at async Runner.run (/usr/src/app/node_modules/knex/lib/execution/runner.js:30:19)

at async Timeout.loop [as _onTimeout] (file:///usr/src/app/dist/jobs.js:43:36)

(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 39)

(node:1) UnhandledPromiseRejectionWarning: SqliteError: select last_run from job_log where name = 'search' limit 1 - database is locked

at Statement.all (<anonymous>)

at Client_BetterSQLite3._query (/usr/src/app/node_modules/knex/lib/dialects/better-sqlite3/index.js:34:40)

at executeQuery (/usr/src/app/node_modules/knex/lib/execution/internal/query-executioner.js:37:17)

at Client_BetterSQLite3.query (/usr/src/app/node_modules/knex/lib/client.js:146:12)

at Runner.query (/usr/src/app/node_modules/knex/lib/execution/runner.js:130:36)

at ensureConnectionCallback (/usr/src/app/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:13:17)

at Runner.ensureConnection (/usr/src/app/node_modules/knex/lib/execution/runner.js:307:20)

at async Runner.run (/usr/src/app/node_modules/knex/lib/execution/runner.js:30:19)

at async Timeout.loop [as _onTimeout] (file:///usr/src/app/dist/jobs.js:43:36)

(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 42)

(node:1) UnhandledPromiseRejectionWarning: SqliteError: select last_run from job_log where name = 'search' limit 1 - database is locked

at Statement.all (<anonymous>)

at Client_BetterSQLite3._query (/usr/src/app/node_modules/knex/lib/dialects/better-sqlite3/index.js:34:40)

at executeQuery (/usr/src/app/node_modules/knex/lib/execution/internal/query-executioner.js:37:17)

at Client_BetterSQLite3.query (/usr/src/app/node_modules/knex/lib/client.js:146:12)

at Runner.query (/usr/src/app/node_modules/knex/lib/execution/runner.js:130:36)

at ensureConnectionCallback (/usr/src/app/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:13:17)

at Runner.ensureConnection (/usr/src/app/node_modules/knex/lib/execution/runner.js:307:20)

at async Runner.run (/usr/src/app/node_modules/knex/lib/execution/runner.js:30:19)

at async Timeout.loop [as _onTimeout] (file:///usr/src/app/dist/jobs.js:43:36)

(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 45)

(node:1) UnhandledPromiseRejectionWarning: SqliteError: select last_run from job_log where name = 'search' limit 1 - database is locked

at Statement.all (<anonymous>)

at Client_BetterSQLite3._query (/usr/src/app/node_modules/knex/lib/dialects/better-sqlite3/index.js:34:40)

at executeQuery (/usr/src/app/node_modules/knex/lib/execution/internal/query-executioner.js:37:17)

at Client_BetterSQLite3.query (/usr/src/app/node_modules/knex/lib/client.js:146:12)

at Runner.query (/usr/src/app/node_modules/knex/lib/execution/runner.js:130:36)

at ensureConnectionCallback (/usr/src/app/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:13:17)

at Runner.ensureConnection (/usr/src/app/node_modules/knex/lib/execution/runner.js:307:20)

at async Runner.run (/usr/src/app/node_modules/knex/lib/execution/runner.js:30:19)

at async Timeout.loop [as _onTimeout] (file:///usr/src/app/dist/jobs.js:43:36)

(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 48)`

@klapvogn
Copy link
Author

and fyi, i don't get a config.js when starting the container first time, it comes and disapear :-/

@mmgoodnow
Copy link
Collaborator

Are you running multiple instances of cross-seed at the same time?

@klapvogn
Copy link
Author

No im only running one in docker

@klapvogn
Copy link
Author

I have this although
$ ps aux |grep cross
root 2479157 0.0 0.0 11435328 18844 ? Ssl Jul09 0:45 node /usr/local/bin/cross-seed daemon`

@mmgoodnow
Copy link
Collaborator

looks like that might be the culprit. Try killing that

@klapvogn
Copy link
Author

It came back after killing it

and got this in cross-seed log
today at 19:27:59Configuration file already exists. today at 19:27:59info: Validating your configuration... today at 19:27:59info: Your configuration is valid! today at 19:27:59info: [server] Server is running on port 2468, ^C to stop.

@klapvogn
Copy link
Author

klapvogn commented Jul 10, 2022

so that line is tied to the docker it seems

@klapvogn
Copy link
Author

cross-seed - https://hub.docker.com/r/mmgoodnow/cross-seed

cross-seed:
container_name: cross-seed
image: mmgoodnow/cross-seed:latest
restart: unless-stopped
logging:
driver: json-file
options:
max-file: ${DOCKERLOGGING_MAXFILE}
max-size: ${DOCKERLOGGING_MAXSIZE}
ports:
- 2468:2468
depends_on:
- prowlarr
- qbittorrent
environment:
- PUID=${PUID}
- PGID=${GUID}
- UMASK=${UMASK}
- TZ=${TZ}
volumes:
- ${BASE_DOCKER_DATA_PATH}/cross-seed/config:/config
- ${BASE_DOCKER_DATA_PATH}/qbittorrent/config/data/BT_backup:/input:ro
- ${BASE_DATA_LOCAL_PATH}:/downloads
command: daemon
labels:
- org.hotio.pullio.notify=${PULLIO_NOTIFY}
- org.hotio.pullio.update=${PULLIO_UPDATE}
- org.hotio.pullio.generic.webhook=${PULLIO_GENERIC_WEBHOOK}
- org.hotio.pullio.author.avatar=${CROSS_AUTHOR_AVATAR}
- "org.hotio.pullio.author.url={"link": "${CROSS_AUTHOR_URL}", "label": "${AUTHOR_LABEL}"}"

@mmgoodnow
Copy link
Collaborator

can you try these steps?

first, stop the docker container. Then, cd into cross-seed's config dir. After that, here are some things to check:

  • That you don't have a hung process sitting on the file (unix: $ fuser cross-seed.db should say nothing)
  • There isn't a cross-seed.db-journal file in the directory with cross-seed.db; this would indicate a crashed session that hasn't been cleaned up properly.
  • Ask the database shell to check itself: $ sqlite3 cross-seed.db "pragma integrity_check;"
  • Backup the database $ sqlite3 cross-seed.db ".backup cross-seed.db.bak"
  • See if the backup works $ sqlite3 cross-seed.db.bak ".schema"

@klapvogn
Copy link
Author

fuser cross-seed.db = output empty

sqlite3 cross-seed.db "pragma integrity_check;" = ok

sqlite3 cross-seed.db ".backup cross-seed.db.bak" = Error: cannot open "cross-seed.db.bak"

sqlite3 cross-seed.db.bak ".schema" = Error: unable to open database "cross-seed.db.bak": unable to open database file

@mmgoodnow
Copy link
Collaborator

Can you post your config (redacting relevant parts)? I'm somewhat out of ideas

@mmgoodnow mmgoodnow added the bug Something isn't working label Jul 15, 2022
@klapvogn
Copy link
Author

@mmgoodnow
Copy link
Collaborator

is there anything else that's weird about your setup? network file shares, maybe?

@KyleSanderson
Copy link

Can't take lock to run migrations: update knex_migrations_lock set is_locked = 1 where is_locked = 0 - unable to open database file
11
If you are sure migrations are not running you can release the lock manually by running 'knex migrate:unlock'
10
/usr/src/cross-seed/node_modules/knex/lib/migrations/migrate/Migrator.js:342
9
throw new LockError(err.message);
8
^
7
6
MigrationLocked: update knex_migrations_lock set is_locked = 1 where is_locked = 0 - unable to open database file
5
at /usr/src/cross-seed/node_modules/knex/lib/migrations/migrate/Migrator.js:342:13
4
at async Migrator._runBatch (/usr/src/cross-seed/node_modules/knex/lib/migrations/migrate/Migrator.js:358:7)
3
at async Command. (file:///usr/src/cross-seed/dist/cmd.js:128:9)
2
at async Command.parseAsync (/usr/src/cross-seed/node_modules/commander/lib/command.js:923:5)
1
at async file:///usr/src/cross-seed/dist/cmd.js:182:1

@newadventure079
Copy link

I'm seeing this too. Mostly when I Ctrl-C to stop the program. One time I had a .journal file in my config dir, and another time I didn't

/usr/local/lib/node_modules/cross-seed/node_modules/better-sqlite3/lib/methods/wrappers.js:5
	return this[cppdb].prepare(sql, this, false);
	                   ^
SqliteError: select * from sqlite_master where type = 'table' and name = 'knex_migrations' - database is locked
    at Database.prepare (/usr/local/lib/node_modules/cross-seed/node_modules/better-sqlite3/lib/methods/wrappers.js:5:21)
    at Client_BetterSQLite3._query (/usr/local/lib/node_modules/cross-seed/node_modules/knex/lib/dialects/better-sqlite3/index.js:30:34)
    at executeQuery (/usr/local/lib/node_modules/cross-seed/node_modules/knex/lib/execution/internal/query-executioner.js:37:17)
    at Client_BetterSQLite3.query (/usr/local/lib/node_modules/cross-seed/node_modules/knex/lib/client.js:146:12)
    at Runner.query (/usr/local/lib/node_modules/cross-seed/node_modules/knex/lib/execution/runner.js:130:36)
    at Runner.queryArray (/usr/local/lib/node_modules/cross-seed/node_modules/knex/lib/execution/runner.js:224:21)
    at ensureConnectionCallback (/usr/local/lib/node_modules/cross-seed/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:11:19)
    at Runner.ensureConnection (/usr/local/lib/node_modules/cross-seed/node_modules/knex/lib/execution/runner.js:307:20)
    at async Runner.run (/usr/local/lib/node_modules/cross-seed/node_modules/knex/lib/execution/runner.js:30:19)
    at async listCompleted (/usr/local/lib/node_modules/cross-seed/node_modules/knex/lib/migrations/migrate/migration-list-resolver.js:12:3) {
  code: 'SQLITE_BUSY'
}
Can't take lock to run migrations: Migration table is already locked
If you are sure migrations are not running you can release the lock manually by running 'knex migrate:unlock'
/usr/local/lib/node_modules/cross-seed/node_modules/knex/lib/migrations/migrate/Migrator.js:342
      throw new LockError(err.message);
            ^

MigrationLocked: Migration table is already locked
    at /usr/local/lib/node_modules/cross-seed/node_modules/knex/lib/migrations/migrate/Migrator.js:342:13
    at async Migrator._runBatch (/usr/local/lib/node_modules/cross-seed/node_modules/knex/lib/migrations/migrate/Migrator.js:358:7)
    at async Command.<anonymous> (file:///usr/local/lib/node_modules/cross-seed/dist/cmd.js:166:9)
    at async Command.parseAsync (/usr/local/lib/node_modules/cross-seed/node_modules/commander/lib/command.js:923:5)
    at async file:///usr/local/lib/node_modules/cross-seed/dist/cmd.js:177:1

@mmgoodnow mmgoodnow mentioned this issue Feb 22, 2023
@mmgoodnow
Copy link
Collaborator

this is tentatively fixed in #341

  • database acquireConnectionTimeout increased
  • WAL mode enabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants