cross-seed icon indicating copy to clipboard operation
cross-seed copied to clipboard

database is locked

Open klapvogn opened this issue 3 years ago • 13 comments

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 avatar Jul 10 '22 16:07 klapvogn

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

klapvogn avatar Jul 10 '22 16:07 klapvogn

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

mmgoodnow avatar Jul 10 '22 17:07 mmgoodnow

No im only running one in docker

klapvogn avatar Jul 10 '22 17:07 klapvogn

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`

klapvogn avatar Jul 10 '22 17:07 klapvogn

looks like that might be the culprit. Try killing that

mmgoodnow avatar Jul 10 '22 17:07 mmgoodnow

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 avatar Jul 10 '22 17:07 klapvogn

so that line is tied to the docker it seems

klapvogn avatar Jul 10 '22 17:07 klapvogn

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}"}"

klapvogn avatar Jul 10 '22 17:07 klapvogn

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"

mmgoodnow avatar Jul 10 '22 17:07 mmgoodnow

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

klapvogn avatar Jul 11 '22 06:07 klapvogn

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

mmgoodnow avatar Jul 15 '22 21:07 mmgoodnow

https://pastebin.com/kDKmiLYc

klapvogn avatar Jul 16 '22 16:07 klapvogn

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

mmgoodnow avatar Aug 22 '22 04:08 mmgoodnow

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

KyleSanderson avatar Jan 12 '23 21:01 KyleSanderson

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

newadventure079 avatar Jan 18 '23 05:01 newadventure079

this is tentatively fixed in #341

  • database acquireConnectionTimeout increased
  • WAL mode enabled

mmgoodnow avatar Feb 22 '23 05:02 mmgoodnow