Skip to content

Android app sync broken after app update to 2.2.0 (and 2.2.1) #23414

@thoja21

Description

@thoja21

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

  • Yes

The bug

After upgrade to the latest Android app (2.2.0) backup syncs fail with a SQLite error.
Other devices (Pixel 4a) on a separate test server (same versions as prod issue) still seems to work although the library it syncs with is far smaller and there are no memories.
Unfortunately I don't have any other devices to test with.

The OS that Immich Server is running on

Ubuntu 22.04

Version of Immich Server

v2.1.0

Version of Immich Mobile App

v2.2.0

Platform with the issue

  • Server
  • Web
  • Mobile

Device make and model

Pixel 8 Pro

Your docker-compose.yml content

#
# WARNING: To install Immich, follow our guide: https://docs.immich.app/install/docker-compose
#
# Make sure to use the docker-compose.yml of the current release:
#
# https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
#
# The compose file on main may not be compatible with the latest release.

name: immich

services:
  immich-server:
    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
    env_file:
      - .env
    ports:
      - '2283:2283'
    depends_on:
      - redis
      - database
    restart: always
    healthcheck:
      disable: false

  immich-machine-learning:
    container_name: immich_machine_learning
    # For hardware acceleration, add one of -[armnn, cuda, rocm, openvino, rknn] to the image tag.
    # Example tag: ${IMMICH_VERSION:-release}-cuda
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    # extends: # uncomment this section for hardware acceleration - see https://docs.immich.app/features/ml-hardware-acceleration
    #   file: hwaccel.ml.yml
    #   service: cpu # set to one of [armnn, cuda, rocm, openvino, openvino-wsl, rknn] for accelerated inference - use the `-wsl` version for WSL2 where applicable
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: always
    healthcheck:
      disable: false

  redis:
    container_name: immich_redis
    image: docker.io/valkey/valkey:8-bookworm@sha256:fea8b3e67b15729d4bb70589eb03367bab9ad1ee89c876f54327fc7c6e618571
    healthcheck:
      test: redis-cli ping || exit 1
    restart: always

  database:
    container_name: immich_postgres
    image: ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0@sha256:41eacbe83eca995561fe43814fd4891e16e39632806253848efaf04d3c8a8b84
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      POSTGRES_INITDB_ARGS: '--data-checksums'
      # Uncomment the DB_STORAGE_TYPE: 'HDD' var if your database isn't stored on SSDs
      DB_STORAGE_TYPE: 'HDD'
    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
    shm_size: 128mb
    restart: always

volumes:
  model-cache:

Your .env content

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

# The location where your uploaded files are stored
UPLOAD_LOCATION=./library
# The location where your database files are stored
DB_DATA_LOCATION=./postgres

# The Immich version to use. You can pin this to a specific version like "v1.71.0". Was "latest"
IMMICH_VERSION=v2.1.0

# Connection secret for postgres. You should change it to a random password
DB_PASSWORD=postgres

# The values below this line do not need to be changed
###################################################################################
DB_USERNAME=REDACTED
DB_DATABASE_NAME=REDACTED

Reproduction steps

  1. Update to 2.2.0 from 2.1.0 with previously synchronised data
  2. Have backup sync already enabled.
  3. Backup sync will fail

Relevant log output

2025-10-31 09:26:32.612311 | info     | HashService          | Hashing took - 4ms |
2025-10-31 09:26:32.607262 | info     | HashService          | Starting hashing of assets |
2025-10-31 09:26:30.590187 | severe   | IsolateLogger        | Error in runInIsolateGentle  for remote-sync | 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: 95354764-a255-4ea8-84fa-c068e1771f3d, 38c1f3cd-3300-4030-b64a-e36125f6cbd9 |
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 408  SyncStreamRepository.updateMemoryAssetsV1
package:immich_mobile/domain/services/sync_stream.service.dart 67                  SyncStreamService._processBatch
package:immich_mobile/domain/services/sync_stream.service.dart 48                  SyncStreamService._handleEvents
package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 110     SyncApiRepository.streamChanges
package:immich_mobile/domain/services/sync_stream.service.dart 30                  SyncStreamService.sync
package:immich_mobile/utils/isolate.dart 58                                        runInIsolateGentle.<fn>.<fn>
package:immich_mobile/utils/isolate.dart 37                                        runInIsolateGentle.<fn>
package:worker_manager/src/worker/worker_io.dart 106                               WorkerImpl._anotherIsolate.<fn>

2025-10-31 09:26:30.584699 | severe   | DriftSyncStreamRepository | 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: 95354764-a255-4ea8-84fa-c068e1771f3d, 38c1f3cd-3300-4030-b64a-e36125f6cbd9 |
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 408  SyncStreamRepository.updateMemoryAssetsV1
package:immich_mobile/domain/services/sync_stream.service.dart 67                  SyncStreamService._processBatch
package:immich_mobile/domain/services/sync_stream.service.dart 48                  SyncStreamService._handleEvents
package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 110     SyncApiRepository.streamChanges
package:immich_mobile/domain/services/sync_stream.service.dart 30                  SyncStreamService.sync
package:immich_mobile/utils/isolate.dart 58                                        runInIsolateGentle.<fn>.<fn>
package:immich_mobile/utils/isolate.dart 37                                        runInIsolateGentle.<fn>
package:worker_manager/src/worker/worker_io.dart 106                               WorkerImpl._anotherIsolate.<fn>

2025-10-31 09:26:29.323899 | info     | DeviceSyncService    | Device sync took - 48ms |
2025-10-31 09:26:29.275338 | info     | SyncStreamService    | Remote sync request for user |

Additional information

No response

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions