[Bug]: SQLite FOREIGN KEY constraint failed #1573

Closed
opened 2026-04-24 23:50:24 +02:00 by adam · 6 comments
Owner

Originally created by @JBlond on GitHub (Dec 4, 2023).

Describe the issue

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 /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.bulkUpdate (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:366:12)
audiobookshelf  |     at async Function.update (/node_modules/sequelize/lib/model.js:2010:28)
audiobookshelf  |     at async PlaybackSessionManager.closeSession (/server/managers/PlaybackSessionManager.js:304:7)
audiobookshelf  |     at async PlaybackSessionManager.startSession (/server/managers/PlaybackSessionManager.js:210:7)
audiobookshelf  |     at async PlaybackSessionManager.startSessionRequest (/server/managers/PlaybackSessionManager.js:66:21) {
audiobookshelf  |   name: 'SequelizeForeignKeyConstraintError',
audiobookshelf  |   parent: [Error: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed] {
audiobookshelf  |     errno: 19,
audiobookshelf  |     code: 'SQLITE_CONSTRAINT',
audiobookshelf  |     sql: 'UPDATE `playbackSessions` SET `id`=$1,`mediaItemId`=$2,`mediaItemType`=$3,`libraryId`=$4,`displayTitle`=$5,`displayAut
hor`=$6,`duration`=$7,`playMethod`=$8,`mediaPlayer`=$9,`startTime`=$10,`currentTime`=$11,`serverVersion`=$12,`createdAt`=$13,`updatedAt`=$14,`user
Id`=$15,`deviceId`=$16,`timeListening`=$17,`coverPath`=$18,`mediaMetadata`=$19,`date`=$20,`dayOfWeek`=$21,`extraData`=$22 WHERE `id` = $23'
audiobookshelf  |   },
audiobookshelf  |   original: [Error: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed] {
audiobookshelf  |     errno: 19,
audiobookshelf  |     code: 'SQLITE_CONSTRAINT',
audiobookshelf  |     sql: 'UPDATE `playbackSessions` SET `id`=$1,`mediaItemId`=$2,`mediaItemType`=$3,`libraryId`=$4,`displayTitle`=$5,`displayAut
hor`=$6,`duration`=$7,`playMethod`=$8,`mediaPlayer`=$9,`startTime`=$10,`currentTime`=$11,`serverVersion`=$12,`createdAt`=$13,`updatedAt`=$14,`user
Id`=$15,`deviceId`=$16,`timeListening`=$17,`coverPath`=$18,`mediaMetadata`=$19,`date`=$20,`dayOfWeek`=$21,`extraData`=$22 WHERE `id` = $23'
audiobookshelf  |   },
audiobookshelf  |   sql: 'UPDATE `playbackSessions` SET `id`=$1,`mediaItemId`=$2,`mediaItemType`=$3,`libraryId`=$4,`displayTitle`=$5,`displayAutho
r`=$6,`duration`=$7,`playMethod`=$8,`mediaPlayer`=$9,`startTime`=$10,`currentTime`=$11,`serverVersion`=$12,`createdAt`=$13,`updatedAt`=$14,`userId
`=$15,`deviceId`=$16,`timeListening`=$17,`coverPath`=$18,`mediaMetadata`=$19,`date`=$20,`dayOfWeek`=$21,`extraData`=$22 WHERE `id` = $23',
audiobookshelf  |   parameters: {},
audiobookshelf  |   table: undefined,
audiobookshelf  |   fields: undefined,
audiobookshelf  |   value: undefined,
audiobookshelf  |   index: undefined,
audiobookshelf  |   reltype: undefined
audiobookshelf  | }
audiobookshelf  | Config /config /metadata

Steps to reproduce the issue

  1. Listen

Audiobookshelf version

v2.6.0

How are you running audiobookshelf?

Docker

Originally created by @JBlond on GitHub (Dec 4, 2023). ### Describe the issue ``` 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 /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.bulkUpdate (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:366:12) audiobookshelf | at async Function.update (/node_modules/sequelize/lib/model.js:2010:28) audiobookshelf | at async PlaybackSessionManager.closeSession (/server/managers/PlaybackSessionManager.js:304:7) audiobookshelf | at async PlaybackSessionManager.startSession (/server/managers/PlaybackSessionManager.js:210:7) audiobookshelf | at async PlaybackSessionManager.startSessionRequest (/server/managers/PlaybackSessionManager.js:66:21) { audiobookshelf | name: 'SequelizeForeignKeyConstraintError', audiobookshelf | parent: [Error: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed] { audiobookshelf | errno: 19, audiobookshelf | code: 'SQLITE_CONSTRAINT', audiobookshelf | sql: 'UPDATE `playbackSessions` SET `id`=$1,`mediaItemId`=$2,`mediaItemType`=$3,`libraryId`=$4,`displayTitle`=$5,`displayAut hor`=$6,`duration`=$7,`playMethod`=$8,`mediaPlayer`=$9,`startTime`=$10,`currentTime`=$11,`serverVersion`=$12,`createdAt`=$13,`updatedAt`=$14,`user Id`=$15,`deviceId`=$16,`timeListening`=$17,`coverPath`=$18,`mediaMetadata`=$19,`date`=$20,`dayOfWeek`=$21,`extraData`=$22 WHERE `id` = $23' audiobookshelf | }, audiobookshelf | original: [Error: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed] { audiobookshelf | errno: 19, audiobookshelf | code: 'SQLITE_CONSTRAINT', audiobookshelf | sql: 'UPDATE `playbackSessions` SET `id`=$1,`mediaItemId`=$2,`mediaItemType`=$3,`libraryId`=$4,`displayTitle`=$5,`displayAut hor`=$6,`duration`=$7,`playMethod`=$8,`mediaPlayer`=$9,`startTime`=$10,`currentTime`=$11,`serverVersion`=$12,`createdAt`=$13,`updatedAt`=$14,`user Id`=$15,`deviceId`=$16,`timeListening`=$17,`coverPath`=$18,`mediaMetadata`=$19,`date`=$20,`dayOfWeek`=$21,`extraData`=$22 WHERE `id` = $23' audiobookshelf | }, audiobookshelf | sql: 'UPDATE `playbackSessions` SET `id`=$1,`mediaItemId`=$2,`mediaItemType`=$3,`libraryId`=$4,`displayTitle`=$5,`displayAutho r`=$6,`duration`=$7,`playMethod`=$8,`mediaPlayer`=$9,`startTime`=$10,`currentTime`=$11,`serverVersion`=$12,`createdAt`=$13,`updatedAt`=$14,`userId `=$15,`deviceId`=$16,`timeListening`=$17,`coverPath`=$18,`mediaMetadata`=$19,`date`=$20,`dayOfWeek`=$21,`extraData`=$22 WHERE `id` = $23', audiobookshelf | parameters: {}, audiobookshelf | table: undefined, audiobookshelf | fields: undefined, audiobookshelf | value: undefined, audiobookshelf | index: undefined, audiobookshelf | reltype: undefined audiobookshelf | } audiobookshelf | Config /config /metadata ``` ### Steps to reproduce the issue 1. Listen ### Audiobookshelf version v2.6.0 ### How are you running audiobookshelf? Docker
adam added the bug label 2026-04-24 23:50:24 +02:00
adam closed this issue 2026-04-24 23:50:26 +02:00
Author
Owner

@advplyr commented on GitHub (Dec 4, 2023):

Can you provide more context? There is nothing to go off of here

@advplyr commented on GitHub (Dec 4, 2023): Can you provide more context? There is nothing to go off of here
Author
Owner

@JBlond commented on GitHub (Dec 4, 2023):

I was just listing over the Android app and it stopped. So I looked into the logs.

@JBlond commented on GitHub (Dec 4, 2023): I was just listing over the Android app and it stopped. So I looked into the logs.
Author
Owner

@advplyr commented on GitHub (Dec 4, 2023):

What version is the android app? Is this a recurring issue or has only happened once?

@advplyr commented on GitHub (Dec 4, 2023): What version is the android app? Is this a recurring issue or has only happened once?
Author
Owner

@JBlond commented on GitHub (Dec 4, 2023):

version: 0.9.68-beta

Happend the first time.

@JBlond commented on GitHub (Dec 4, 2023): version: 0.9.68-beta Happend the first time.
Author
Owner

@JBlond commented on GitHub (Dec 4, 2023):

If you like, you can close this issue. But we still have it as a reference, it happens again.

@JBlond commented on GitHub (Dec 4, 2023): If you like, you can close this issue. But we still have it as a reference, it happens again.
Author
Owner

@advplyr commented on GitHub (Dec 4, 2023):

Sounds good, let me know if you get more info

@advplyr commented on GitHub (Dec 4, 2023): Sounds good, let me know if you get more info
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#1573