advplyr / audiobookshelf

Self-hosted audiobook and podcast server
https://audiobookshelf.org
GNU General Public License v3.0
5.83k stars 404 forks source link

[Bug]: SQLite FOREIGN KEY constraint failed #2384

Closed JBlond closed 7 months ago

JBlond commented 7 months ago

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

advplyr commented 7 months ago

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

JBlond commented 7 months ago

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

advplyr commented 7 months ago

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

JBlond commented 7 months ago

version: 0.9.68-beta

Happend the first time.

JBlond commented 7 months ago

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

advplyr commented 7 months ago

Sounds good, let me know if you get more info