memories (beta) Android - Foreign Key contstraint failed #6514

Closed
opened 2026-02-20 04:13:13 -05:00 by deekerman · 3 comments
Owner

Originally created by @wjansenw on GitHub (Aug 26, 2025).

I have searched the existing issues, both open and closed, to make sure this is not a duplicate report.

  • Yes

The bug

I moved to the Beta timeline, and the memories fail to load.

Error in android app:

Error: updateMemoryAssetsV1

SqliteException(787): while executing statement, FOREIGN KEY constraint failed, constraint failed (code 787)
  Causing statement: INSERT INTO "memory_asset_entity" ("asset_id", "memory_id") VALUES (?, ?) ON CONFLICT("asset_id", "memory_id") DO NOTHING, parameters: af07f0d1-65a4-4407-b4a1-56c002945a32, b8a556d9-9749-4fd1-bf4b-7268fd7e2ce1

package:sqlite3/src/implementation/exception.dart 87                               throwException
package:sqlite3/src/implementation/statement.dart 109                              StatementImplementation._execute
package:sqlite3/src/implementation/statement.dart 289                              StatementImplementation.executeWith
package:sqlite3/src/statement.dart 81                                              CommonPreparedStatement.execute
package:drift/src/sqlite3/database.dart 131                                        Sqlite3Delegate.runBatchSync
package:drift/native.dart 373                                                      _NativeDelegate.runBatched.<fn>
dart:async/future.dart 315                                                         new Future.sync
package:drift/native.dart 373                                                      _NativeDelegate.runBatched
package:drift/src/runtime/executor/helpers/engines.dart 128                        _BaseExecutor.runBatched.<fn>
package:drift/src/runtime/executor/helpers/engines.dart 62                         _BaseExecutor._synchronized
package:drift/src/runtime/executor/helpers/engines.dart 122                        _BaseExecutor.runBatched
package:drift/src/remote/server_impl.dart 170                                      ServerImplementation._runBatched
package:drift/src/remote/communication.dart 165                                    DriftCommunication.setRequestHandler.<fn>
===== asynchronous gap ===========================
package:drift/src/remote/communication.dart 113                                    DriftCommunication.request
package:drift/src/remote/client_impl.dart 84                                       _BaseExecutor.runBatched
package:drift/src/runtime/api/batch.dart 215                                       Batch._runWith
package:drift/src/runtime/api/batch.dart 199                                       Batch._commit
package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart 328  SyncStreamRepository.updateMemoryAssetsV1
package:immich_mobile/domain/services/sync_stream.service.dart 98                  SyncStreamService._processBatch

package:immich_mobile/domain/services/sync_stream.service.dart 83 SyncStreamService._handleEvents
package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 99 SyncApiRepository.streamChanges
package:immich_mobile/utils/isolate.dart 53 runInIsolateGentle.
package:worker_manager/src/worker/worker_io.dart 106 WorkerImpl._anotherIsolate.

The OS that Immich Server is running on

Linux odroid 6.15.10-edge-meson64 #1 SMP PREEMPT Fri Aug 15 10:17:09 UTC 2025 aarch64 aarch64 aarch64 GNU/Linux

Version of Immich Server

v1.139.4

Version of Immich Mobile App

v1.139.2

Platform with the issue

  • Server
  • Web
  • Mobile

Device make and model

Samsing S23

Your docker-compose.yml content

name: immich

services:
  immich-server:
    cpus: 4
    mem_limit: 2g
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    # extends:
    #   file: hwaccel.transcoding.yml
    #   service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
    volumes:
      # Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file
      - ${UPLOAD_LOCATION}:/data
      - /etc/localtime:/etc/localtime:ro
      - /volume1/pictures:/media/
    env_file:
      - .env
    ports:
      - '2283:2283'
    depends_on:
      - redis
      - database
    restart: always
    healthcheck:
      disable: false
  redis:
    cpus: 1
    mem_limit: 1g
    container_name: immich_redis
    image: docker.io/valkey/valkey:8-bookworm@sha256:42cba146593a5ea9a622002c1b7cba5da7be248650cbb64ecb9c6c33d29794b1
    healthcheck:
      test: redis-cli ping || exit 1
    restart: always
    volumes:
      - redis-data:/data

  database:
    cpus: 2
    mem_limit: 2g
    container_name: immich_postgres
    #image: docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:739cdd626151ff1f796dc95a6591b55a714f341c737e27f045019ceabf8e8c52
    #image: ghcr.io/immich-app/postgres:14-vectorchord0.4.1-pgvectors0.2.0
    #image: ghcr.io/immich-app/postgres:14-vectorchord0.3.0-pgvectors0.2.0
    image: ghcr.io/immich-app/postgres:14-vectorchord0.4.2-pgvectors0.2.0
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      POSTGRES_INITDB_ARGS: '--data-checksums'
      DB_STORAGE_TYPE: 'HDD'
    restart: unless-stopped
    volumes:
      # Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file
      - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
volumes:
  model-cache:
  redis-data:

Your .env content

# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables

#IMMICH_LOG_LEVEL=verbose
TZ=Europe/Brussels
# The location where your uploaded files are stored
UPLOAD_LOCATION=/volume1/documents/immich/library

# The location where your database files are stored. Network shares are not supported for the database
DB_DATA_LOCATION=./postgres

# To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
# TZ=Etc/UTC

# The Immich version to use. You can pin this to a specific version like "v1.71.0"
IMMICH_VERSION=release

# Connection secret for postgres. You should change it to a random password
# Please use only the characters `A-Za-z0-9`, without special characters or spaces
DB_PASSWORD=postgres

# The values below this line do not need to be changed
###################################################################################
DB_HOST=immich_postgres
DB_PORT=5432
DB_USERNAME=postgres
DB_DATABASE_NAME=immich

Reproduction steps

Open the android app and notice that no memories are present in the beta timeline.
Switch the the non-beta, and timelines are back.

Relevant log output


Additional information

No response

Originally created by @wjansenw on GitHub (Aug 26, 2025). ### I have searched the existing issues, both open and closed, to make sure this is not a duplicate report. - [x] Yes ### The bug I moved to the Beta timeline, and the memories fail to load. Error in android app: ``` Error: updateMemoryAssetsV1 SqliteException(787): while executing statement, FOREIGN KEY constraint failed, constraint failed (code 787) Causing statement: INSERT INTO "memory_asset_entity" ("asset_id", "memory_id") VALUES (?, ?) ON CONFLICT("asset_id", "memory_id") DO NOTHING, parameters: af07f0d1-65a4-4407-b4a1-56c002945a32, b8a556d9-9749-4fd1-bf4b-7268fd7e2ce1 package:sqlite3/src/implementation/exception.dart 87 throwException package:sqlite3/src/implementation/statement.dart 109 StatementImplementation._execute package:sqlite3/src/implementation/statement.dart 289 StatementImplementation.executeWith package:sqlite3/src/statement.dart 81 CommonPreparedStatement.execute package:drift/src/sqlite3/database.dart 131 Sqlite3Delegate.runBatchSync package:drift/native.dart 373 _NativeDelegate.runBatched.<fn> dart:async/future.dart 315 new Future.sync package:drift/native.dart 373 _NativeDelegate.runBatched package:drift/src/runtime/executor/helpers/engines.dart 128 _BaseExecutor.runBatched.<fn> package:drift/src/runtime/executor/helpers/engines.dart 62 _BaseExecutor._synchronized package:drift/src/runtime/executor/helpers/engines.dart 122 _BaseExecutor.runBatched package:drift/src/remote/server_impl.dart 170 ServerImplementation._runBatched package:drift/src/remote/communication.dart 165 DriftCommunication.setRequestHandler.<fn> ===== asynchronous gap =========================== package:drift/src/remote/communication.dart 113 DriftCommunication.request package:drift/src/remote/client_impl.dart 84 _BaseExecutor.runBatched package:drift/src/runtime/api/batch.dart 215 Batch._runWith package:drift/src/runtime/api/batch.dart 199 Batch._commit package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart 328 SyncStreamRepository.updateMemoryAssetsV1 package:immich_mobile/domain/services/sync_stream.service.dart 98 SyncStreamService._processBatch ``` package:immich_mobile/domain/services/sync_stream.service.dart 83 SyncStreamService._handleEvents package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 99 SyncApiRepository.streamChanges package:immich_mobile/utils/isolate.dart 53 runInIsolateGentle.<fn> package:worker_manager/src/worker/worker_io.dart 106 WorkerImpl._anotherIsolate.<fn> ### The OS that Immich Server is running on Linux odroid 6.15.10-edge-meson64 #1 SMP PREEMPT Fri Aug 15 10:17:09 UTC 2025 aarch64 aarch64 aarch64 GNU/Linux ### Version of Immich Server v1.139.4 ### Version of Immich Mobile App v1.139.2 ### Platform with the issue - [ ] Server - [ ] Web - [x] Mobile ### Device make and model Samsing S23 ### Your docker-compose.yml content ```YAML name: immich services: immich-server: cpus: 4 mem_limit: 2g container_name: immich_server image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release} # extends: # file: hwaccel.transcoding.yml # service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding volumes: # Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file - ${UPLOAD_LOCATION}:/data - /etc/localtime:/etc/localtime:ro - /volume1/pictures:/media/ env_file: - .env ports: - '2283:2283' depends_on: - redis - database restart: always healthcheck: disable: false redis: cpus: 1 mem_limit: 1g container_name: immich_redis image: docker.io/valkey/valkey:8-bookworm@sha256:42cba146593a5ea9a622002c1b7cba5da7be248650cbb64ecb9c6c33d29794b1 healthcheck: test: redis-cli ping || exit 1 restart: always volumes: - redis-data:/data database: cpus: 2 mem_limit: 2g container_name: immich_postgres #image: docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:739cdd626151ff1f796dc95a6591b55a714f341c737e27f045019ceabf8e8c52 #image: ghcr.io/immich-app/postgres:14-vectorchord0.4.1-pgvectors0.2.0 #image: ghcr.io/immich-app/postgres:14-vectorchord0.3.0-pgvectors0.2.0 image: ghcr.io/immich-app/postgres:14-vectorchord0.4.2-pgvectors0.2.0 environment: POSTGRES_PASSWORD: ${DB_PASSWORD} POSTGRES_USER: ${DB_USERNAME} POSTGRES_DB: ${DB_DATABASE_NAME} POSTGRES_INITDB_ARGS: '--data-checksums' DB_STORAGE_TYPE: 'HDD' restart: unless-stopped volumes: # Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file - ${DB_DATA_LOCATION}:/var/lib/postgresql/data volumes: model-cache: redis-data: ``` ### Your .env content ```Shell # You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables #IMMICH_LOG_LEVEL=verbose TZ=Europe/Brussels # The location where your uploaded files are stored UPLOAD_LOCATION=/volume1/documents/immich/library # The location where your database files are stored. Network shares are not supported for the database DB_DATA_LOCATION=./postgres # To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List # TZ=Etc/UTC # The Immich version to use. You can pin this to a specific version like "v1.71.0" IMMICH_VERSION=release # Connection secret for postgres. You should change it to a random password # Please use only the characters `A-Za-z0-9`, without special characters or spaces DB_PASSWORD=postgres # The values below this line do not need to be changed ################################################################################### DB_HOST=immich_postgres DB_PORT=5432 DB_USERNAME=postgres DB_DATABASE_NAME=immich ``` ### Reproduction steps Open the android app and notice that no memories are present in the beta timeline. Switch the the non-beta, and timelines are back. ### Relevant log output ```shell ``` ### Additional information _No response_
Author
Owner

@wjansenw commented on GitHub (Aug 26, 2025):

I checked the asset that is giving the error (af07f0d1-65a4-4407-b4a1-56c002945a32) - and that seems to be a memory from a few days ago: August 22nd (2024) while today we are August 26th (I know - holiday period here in BE is almost over!!)
When I open the memory in the web client, I do not get the referenced asset (with incorrect date) - only pictures with correct dates in the memory.

Note: it could very well be that August 22nd was the date I reinstalled immich app (to see if this would fix the issue).

@wjansenw commented on GitHub (Aug 26, 2025): I checked the asset that is giving the error (af07f0d1-65a4-4407-b4a1-56c002945a32) - and that seems to be a memory from a few days ago: August 22nd (2024) while today we are August 26th (I know - holiday period here in BE is almost over!!) When I open the memory in the web client, I do not get the referenced asset (with incorrect date) - only pictures with correct dates in the memory. Note: it could very well be that August 22nd was the date I reinstalled immich app (to see if this would fix the issue).
Author
Owner

@wjansenw commented on GitHub (Aug 26, 2025):

After resetting SQLite database, and logging back in - it seems to show memories for today correct. Let's wait for tomorrow.

@wjansenw commented on GitHub (Aug 26, 2025): After resetting SQLite database, and logging back in - it seems to show memories for today correct. Let's wait for tomorrow.
Author
Owner

@wjansenw commented on GitHub (Aug 27, 2025):

Ignore - there must have been something wrong with the internal database, and it is no longer possible to test / simulate. After resetting the DB, all seems to be working OK now.
I will close the issue,

@wjansenw commented on GitHub (Aug 27, 2025): Ignore - there must have been something wrong with the internal database, and it is no longer possible to test / simulate. After resetting the DB, all seems to be working OK now. I will close the issue,
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/immich#6514
No description provided.