[Bug]: Various fatal database errors after manually changing metadata in the web portal #1519

Closed
opened 2026-04-24 23:48:36 +02:00 by adam · 1 comment
Owner

Originally created by @zzyzx-dc on GitHub (Nov 12, 2023).

Describe the issue

Not really sure if it's a bug or not. I edited some items - titles, maybe an author, and one description. There was initially no problem, but about an hour later the container crashed and I got a 502 Bad Gateway.

Restarting the docker container restarted the service successfully.

audiobookshelf    | node:internal/process/promises:279
audiobookshelf    |             triggerUncaughtException(err, true /* fromPromise */);
audiobookshelf    |             ^
audiobookshelf    | 
audiobookshelf    | Error
audiobookshelf    |     at Database.<anonymous> (/node_modules/sequelize/lib/dialects/sqlite/query.js:185:27)
audiobookshelf    |     at Database.serialize (<anonymous>)
audiobookshelf    |     at /node_modules/sequelize/lib/dialects/sqlite/query.js:183:50
audiobookshelf    |     at new Promise (<anonymous>)
audiobookshelf    |     at Query.run (/node_modules/sequelize/lib/dialects/sqlite/query.js:183:12)
audiobookshelf    |     at /node_modules/sequelize/lib/sequelize.js:315:28
audiobookshelf    |     at async SQLiteQueryInterface.insert (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:308:21)
audiobookshelf    |     at async BookAuthor.save (/node_modules/sequelize/lib/model.js:2490:35)
audiobookshelf    |     at async Function.create (/node_modules/sequelize/lib/model.js:1362:12)
audiobookshelf    |     at async BookScanner.rescanExistingBookLibraryItem (/server/scanner/BookScanner.js:188:15) {
audiobookshelf    |   name: 'SequelizeUniqueConstraintError',
audiobookshelf    |   errors: [
audiobookshelf    |     ValidationErrorItem {
audiobookshelf    |       message: 'bookId must be unique',
audiobookshelf    |       type: 'unique violation',
audiobookshelf    |       path: 'bookId',
audiobookshelf    |       value: '4a9c90db-9253-42cc-a95e-9c35d6f1502f',
audiobookshelf    |       origin: 'DB',
audiobookshelf    |       instance: bookAuthor {
audiobookshelf    |         dataValues: {
audiobookshelf    |           id: 'd5973c9f-415d-492e-ae14-da8882875139',
audiobookshelf    |           bookId: '4a9c90db-9253-42cc-a95e-9c35d6f1502f',
audiobookshelf    |           authorId: 'ad2a587e-540d-420a-a5f4-3c84cf42ebc1',
audiobookshelf    |           createdAt: 2023-11-12T05:00:01.009Z
audiobookshelf    |         },
audiobookshelf    |         _previousDataValues: { bookId: undefined, authorId: undefined },
audiobookshelf    |         uniqno: 1,
audiobookshelf    |         _changed: Set(2) { 'bookId', 'authorId' },
audiobookshelf    |         _options: {
audiobookshelf    |           isNewRecord: true,
audiobookshelf    |           _schema: null,
audiobookshelf    |           _schemaDelimiter: '',
audiobookshelf    |           attributes: undefined,
audiobookshelf    |           include: undefined,
audiobookshelf    |           raw: undefined,
audiobookshelf    |           silent: undefined
audiobookshelf    |         },
audiobookshelf    |         isNewRecord: true
audiobookshelf    |       },
audiobookshelf    |       validatorKey: 'not_unique',
audiobookshelf    |       validatorName: null,
audiobookshelf    |       validatorArgs: []
audiobookshelf    |     },
audiobookshelf    |     ValidationErrorItem {
audiobookshelf    |       message: 'authorId must be unique',
audiobookshelf    |       type: 'unique violation',
audiobookshelf    |       path: 'authorId',
audiobookshelf    |       value: 'ad2a587e-540d-420a-a5f4-3c84cf42ebc1',
audiobookshelf    |       origin: 'DB',
audiobookshelf    |       instance: bookAuthor {
audiobookshelf    |         dataValues: {
audiobookshelf    |           id: 'd5973c9f-415d-492e-ae14-da8882875139',
audiobookshelf    |           bookId: '4a9c90db-9253-42cc-a95e-9c35d6f1502f',
audiobookshelf    |           authorId: 'ad2a587e-540d-420a-a5f4-3c84cf42ebc1',
audiobookshelf    |           createdAt: 2023-11-12T05:00:01.009Z
audiobookshelf    |         },
audiobookshelf    |         _previousDataValues: { bookId: undefined, authorId: undefined },
audiobookshelf    |         uniqno: 1,
audiobookshelf    |         _changed: Set(2) { 'bookId', 'authorId' },
audiobookshelf    |         _options: {
audiobookshelf    |           isNewRecord: true,
audiobookshelf    |           _schema: null,
audiobookshelf    |           _schemaDelimiter: '',
audiobookshelf    |           attributes: undefined,
audiobookshelf    |           include: undefined,
audiobookshelf    |           raw: undefined,
audiobookshelf    |           silent: undefined
audiobookshelf    |         },
audiobookshelf    |         isNewRecord: true
audiobookshelf    |       },
audiobookshelf    |       validatorKey: 'not_unique',
audiobookshelf    |       validatorName: null,
audiobookshelf    |       validatorArgs: []
audiobookshelf    |     }
audiobookshelf    |   ],
audiobookshelf    |   parent: [Error: SQLITE_CONSTRAINT: UNIQUE constraint failed: bookAuthors.bookId, bookAuthors.authorId] {
audiobookshelf    |     errno: 19,
audiobookshelf    |     code: 'SQLITE_CONSTRAINT',
audiobookshelf    |     sql: 'INSERT INTO `bookAuthors` (`id`,`createdAt`,`bookId`,`authorId`) VALUES ($1,$2,$3,$4);'
audiobookshelf    |   },
audiobookshelf    |   original: [Error: SQLITE_CONSTRAINT: UNIQUE constraint failed: bookAuthors.bookId, bookAuthors.authorId] {
audiobookshelf    |     errno: 19,
audiobookshelf    |     code: 'SQLITE_CONSTRAINT',
audiobookshelf    |     sql: 'INSERT INTO `bookAuthors` (`id`,`createdAt`,`bookId`,`authorId`) VALUES ($1,$2,$3,$4);'
audiobookshelf    |   },
audiobookshelf    |   fields: [ 'bookId', 'authorId' ],
audiobookshelf    |   sql: 'INSERT INTO `bookAuthors` (`id`,`createdAt`,`bookId`,`authorId`) VALUES ($1,$2,$3,$4);'
audiobookshelf    | }

Steps to reproduce the issue

  1. Edit item title, author, description within the app (up to this point I normally change the file/folder structure)
  2. Service crashes
  3. Restarting the docker container successfully restarts the service.

Audiobookshelf version

v.2.5.0

How are you running audiobookshelf?

Docker

Originally created by @zzyzx-dc on GitHub (Nov 12, 2023). ### Describe the issue Not really sure if it's a bug or not. I edited some items - titles, maybe an author, and one description. There was initially no problem, but about an hour later the container crashed and I got a 502 Bad Gateway. Restarting the docker container restarted the service successfully. ``` audiobookshelf | node:internal/process/promises:279 audiobookshelf | triggerUncaughtException(err, true /* fromPromise */); audiobookshelf | ^ audiobookshelf | audiobookshelf | Error audiobookshelf | at Database.<anonymous> (/node_modules/sequelize/lib/dialects/sqlite/query.js:185:27) audiobookshelf | at Database.serialize (<anonymous>) audiobookshelf | at /node_modules/sequelize/lib/dialects/sqlite/query.js:183:50 audiobookshelf | at new Promise (<anonymous>) audiobookshelf | at Query.run (/node_modules/sequelize/lib/dialects/sqlite/query.js:183:12) audiobookshelf | at /node_modules/sequelize/lib/sequelize.js:315:28 audiobookshelf | at async SQLiteQueryInterface.insert (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:308:21) audiobookshelf | at async BookAuthor.save (/node_modules/sequelize/lib/model.js:2490:35) audiobookshelf | at async Function.create (/node_modules/sequelize/lib/model.js:1362:12) audiobookshelf | at async BookScanner.rescanExistingBookLibraryItem (/server/scanner/BookScanner.js:188:15) { audiobookshelf | name: 'SequelizeUniqueConstraintError', audiobookshelf | errors: [ audiobookshelf | ValidationErrorItem { audiobookshelf | message: 'bookId must be unique', audiobookshelf | type: 'unique violation', audiobookshelf | path: 'bookId', audiobookshelf | value: '4a9c90db-9253-42cc-a95e-9c35d6f1502f', audiobookshelf | origin: 'DB', audiobookshelf | instance: bookAuthor { audiobookshelf | dataValues: { audiobookshelf | id: 'd5973c9f-415d-492e-ae14-da8882875139', audiobookshelf | bookId: '4a9c90db-9253-42cc-a95e-9c35d6f1502f', audiobookshelf | authorId: 'ad2a587e-540d-420a-a5f4-3c84cf42ebc1', audiobookshelf | createdAt: 2023-11-12T05:00:01.009Z audiobookshelf | }, audiobookshelf | _previousDataValues: { bookId: undefined, authorId: undefined }, audiobookshelf | uniqno: 1, audiobookshelf | _changed: Set(2) { 'bookId', 'authorId' }, audiobookshelf | _options: { audiobookshelf | isNewRecord: true, audiobookshelf | _schema: null, audiobookshelf | _schemaDelimiter: '', audiobookshelf | attributes: undefined, audiobookshelf | include: undefined, audiobookshelf | raw: undefined, audiobookshelf | silent: undefined audiobookshelf | }, audiobookshelf | isNewRecord: true audiobookshelf | }, audiobookshelf | validatorKey: 'not_unique', audiobookshelf | validatorName: null, audiobookshelf | validatorArgs: [] audiobookshelf | }, audiobookshelf | ValidationErrorItem { audiobookshelf | message: 'authorId must be unique', audiobookshelf | type: 'unique violation', audiobookshelf | path: 'authorId', audiobookshelf | value: 'ad2a587e-540d-420a-a5f4-3c84cf42ebc1', audiobookshelf | origin: 'DB', audiobookshelf | instance: bookAuthor { audiobookshelf | dataValues: { audiobookshelf | id: 'd5973c9f-415d-492e-ae14-da8882875139', audiobookshelf | bookId: '4a9c90db-9253-42cc-a95e-9c35d6f1502f', audiobookshelf | authorId: 'ad2a587e-540d-420a-a5f4-3c84cf42ebc1', audiobookshelf | createdAt: 2023-11-12T05:00:01.009Z audiobookshelf | }, audiobookshelf | _previousDataValues: { bookId: undefined, authorId: undefined }, audiobookshelf | uniqno: 1, audiobookshelf | _changed: Set(2) { 'bookId', 'authorId' }, audiobookshelf | _options: { audiobookshelf | isNewRecord: true, audiobookshelf | _schema: null, audiobookshelf | _schemaDelimiter: '', audiobookshelf | attributes: undefined, audiobookshelf | include: undefined, audiobookshelf | raw: undefined, audiobookshelf | silent: undefined audiobookshelf | }, audiobookshelf | isNewRecord: true audiobookshelf | }, audiobookshelf | validatorKey: 'not_unique', audiobookshelf | validatorName: null, audiobookshelf | validatorArgs: [] audiobookshelf | } audiobookshelf | ], audiobookshelf | parent: [Error: SQLITE_CONSTRAINT: UNIQUE constraint failed: bookAuthors.bookId, bookAuthors.authorId] { audiobookshelf | errno: 19, audiobookshelf | code: 'SQLITE_CONSTRAINT', audiobookshelf | sql: 'INSERT INTO `bookAuthors` (`id`,`createdAt`,`bookId`,`authorId`) VALUES ($1,$2,$3,$4);' audiobookshelf | }, audiobookshelf | original: [Error: SQLITE_CONSTRAINT: UNIQUE constraint failed: bookAuthors.bookId, bookAuthors.authorId] { audiobookshelf | errno: 19, audiobookshelf | code: 'SQLITE_CONSTRAINT', audiobookshelf | sql: 'INSERT INTO `bookAuthors` (`id`,`createdAt`,`bookId`,`authorId`) VALUES ($1,$2,$3,$4);' audiobookshelf | }, audiobookshelf | fields: [ 'bookId', 'authorId' ], audiobookshelf | sql: 'INSERT INTO `bookAuthors` (`id`,`createdAt`,`bookId`,`authorId`) VALUES ($1,$2,$3,$4);' audiobookshelf | } ``` ### Steps to reproduce the issue 1. Edit item title, author, description within the app (up to this point I normally change the file/folder structure) 2. Service crashes 3. Restarting the docker container successfully restarts the service. ### Audiobookshelf version v.2.5.0 ### How are you running audiobookshelf? Docker
adam added the bug label 2026-04-24 23:48:36 +02:00
adam closed this issue 2026-04-24 23:48:36 +02:00
Author
Owner

@advplyr commented on GitHub (Nov 12, 2023):

Is this a reproducible issue for you? Or it just happened once?

@advplyr commented on GitHub (Nov 12, 2023): Is this a reproducible issue for you? Or it just happened once?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#1519