Skip to content

duplicated key value for face_search_pkey #26373

@herrwagner

Description

@herrwagner

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

  • Yes

The bug

Hi

i'm running immich with podman quadlet on an Ubuntu 25.10. Storage are two Samsung Enterprise SSD in a hardware RAID1 with xfs.
It's a new clean installation. I've uploaded the first 84 photos to play around and tried the face recognition (automatic and manually). Merged some Persons. Then the error occurred during a "Refresh" of the face recognition 10 times.

Feb 19 22:32:09 sol immich-postgres[1052021]: 2026-02-19 21:32:09.910 UTC [2922] ERROR: duplicate key value violates unique constraint "face_search_pkey"
See complete error below.

Details about the steps (as far as i remember) under reproducing steps.

The OS that Immich Server is running on

Ubuntu 25.10

Version of Immich Server

v.2.5.6

Version of Immich Mobile App

v2.5.6

Platform with the issue

  • Server
  • Web
  • Mobile

Device make and model

No response

Your docker-compose.yml content

# Immich Server
# Ansible managed
[Unit]
Description=Immich Server
After=immich-pod.service
Requires=immich-pod.service

[Container]
Image=ghcr.io/immich-app/immich-server:v2
ContainerName=immich-server
Pod=immich.pod
AutoUpdate=registry
Timezone=Europe/Berlin

# Volumes - :U adjusts ownership for rootless container user
Volume=/srv/containers/immich/library:/data:U
Volume=/etc/localtime:/etc/localtime:ro

# Environment - secrets loaded from file
EnvironmentFile=/srv/containers/immich/.env

# Database (pod-internal localhost)
Environment=DB_HOSTNAME=127.0.0.1
Environment=DB_USERNAME=postgres
Environment=DB_DATABASE_NAME=immich

# Redis (pod-internal localhost)
Environment=REDIS_HOSTNAME=127.0.0.1

# Trusted proxies (Caddy on host network)
Environment=IMMICH_TRUSTED_PROXIES=127.0.0.1


# Health check
HealthCmd=curl -sf http://127.0.0.1:2283/api/server/ping || exit 1
HealthInterval=30s
HealthTimeout=10s
HealthRetries=3
HealthStartPeriod=120s

[Service]
Restart=always
TimeoutStartSec=900

[Install]
WantedBy=default.target


# Immich Postgres
# Ansible managed
[Unit]
Description=Immich PostgreSQL
After=immich-pod.service
Requires=immich-pod.service

[Container]
Image=ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0@sha256:bcf63357191b76a916ae5eb93464d65c07511da41e3bf7a8416db519b40b1c23
ContainerName=immich-postgres
Pod=immich.pod
AutoUpdate=registry

# Volume for database data - :U adjusts ownership for rootless
Volume=/srv/containers/immich/postgres:/var/lib/postgresql/data:U

# Environment - POSTGRES_PASSWORD loaded from .env file
EnvironmentFile=/srv/containers/immich/.env
Environment=POSTGRES_USER=postgres
Environment=POSTGRES_DB=immich
Environment=POSTGRES_INITDB_ARGS=--data-checksums

# PostgreSQL needs shared memory
ShmSize=128m

[Service]
Restart=always
TimeoutStartSec=300

[Install]
WantedBy=default.target

Your .env content

# Ansible managed
# Immich secrets - mode 0600

DB_PASSWORD=...
POSTGRES_PASSWORD=...

Reproduction steps

  1. Uploaded 84 images
  2. Named all 4 found persons
  3. Some faces are not recognized so i marked some of them manually
  4. Lower the minimum detection score of facial recognition to 0.6
  5. "Refresh" Face Detection
  6. 2 "new" persons are found, merge them each with its "old" counterpart.
  7. "Refresh" Face Detection
  8. Error appears in the log

Relevant log output

Feb 19 22:32:09 sol immich-postgres[1052021]: 2026-02-19 21:32:09.910 UTC [2922] ERROR:  duplicate key value violates unique constraint "face_search_pkey"                                                                                                                                                                          Feb 19 22:32:09 sol immich-postgres[1052021]: 2026-02-19 21:32:09.910 UTC [2922] DETAIL:  Key ("faceId")=(8fda0071-db93-416b-99e4-98c0b4e21f68) already exists.
Feb 19 22:32:09 sol immich-postgres[1052021]: 2026-02-19 21:32:09.910 UTC [2922] STATEMENT:  with "added_embeddings" as (insert into "face_search" ("faceId", "embedding") values ($1, $2)) select from (select 1) as "dummy"
Feb 19 22:32:09 sol immich-server[1051197]: Query failed : {
Feb 19 22:32:09 sol immich-server[1051197]:   durationMs: 2.265097990632057,                                                                                                                                                                                                                                                        Feb 19 22:32:09 sol immich-server[1051197]:   error: PostgresError: duplicate key value violates unique constraint "face_search_pkey"                                                                                                                                                                                               Feb 19 22:32:09 sol immich-server[1051197]:       at ErrorResponse (/usr/src/app/server/node_modules/.pnpm/postgres@3.4.8/node_modules/postgres/cjs/src/connection.js:815:30)                                                                                                                                                       Feb 19 22:32:09 sol immich-server[1051197]:       at handle (/usr/src/app/server/node_modules/.pnpm/postgres@3.4.8/node_modules/postgres/cjs/src/connection.js:489:6)                                                                                                                                                               Feb 19 22:32:09 sol immich-server[1051197]:       at Socket.data (/usr/src/app/server/node_modules/.pnpm/postgres@3.4.8/node_modules/postgres/cjs/src/connection.js:324:9)
Feb 19 22:32:09 sol immich-server[1051197]:       at Socket.emit (node:events:508:28)
Feb 19 22:32:09 sol immich-server[1051197]:       at addChunk (node:internal/streams/readable:559:12)
Feb 19 22:32:09 sol immich-server[1051197]:       at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
Feb 19 22:32:09 sol immich-server[1051197]:       at Readable.push (node:internal/streams/readable:390:5)
Feb 19 22:32:09 sol immich-server[1051197]:       at TCP.onStreamRead (node:internal/stream_base_commons:189:23) {
Feb 19 22:32:09 sol immich-server[1051197]:     severity_local: 'ERROR',
Feb 19 22:32:09 sol immich-server[1051197]:     severity: 'ERROR',
Feb 19 22:32:09 sol immich-server[1051197]:     code: '23505',
Feb 19 22:32:09 sol immich-server[1051197]:     detail: 'Key ("faceId")=(8fda0071-db93-416b-99e4-98c0b4e21f68) already exists.',
Feb 19 22:32:09 sol immich-server[1051197]:     schema_name: 'public',
Feb 19 22:32:09 sol immich-server[1051197]:     table_name: 'face_search',
Feb 19 22:32:09 sol immich-server[1051197]:     constraint_name: 'face_search_pkey',
Feb 19 22:32:09 sol immich-server[1051197]:     file: 'nbtinsert.c',
Feb 19 22:32:09 sol immich-server[1051197]:     line: '663',
Feb 19 22:32:09 sol immich-server[1051197]:     routine: '_bt_check_unique'
Feb 19 22:32:09 sol immich-server[1051197]:   },
Feb 19 22:32:09 sol immich-server[1051197]:   sql: 'with "added_embeddings" as (insert into "face_search" ("faceId", "embedding") values ($1, $2)) select from (select 1) as "dummy"',
Feb 19 22:32:09 sol immich-server[1051197]:   params: [
Feb 19 22:32:09 sol immich-server[1051197]:     '8fda0071-db93-416b-99e4-98c0b4e21f68',
Feb 19 22:32:09 sol immich-server[1051197]:     '[-0.57399154,0.3225054,0.83362824,-0.57307327,1.8923904,0.5674116,1.6485034,-1.2034565,0.6515938,0.4586673,1.9856162,-0.26765233,-0.2787935,0.94168186,-1.6424094,0.65640056,-0.24821538,1.488033,0.15078144,-0.98415613,-0.3981787,-0.8207693,1.6022807,-0.96119785,-0.19202487,1.
5350732,-1.3888688,-0.048891358,-0.74648345,-2.3496742,-0.6258432,-0.18855312,0.8439933,-0.392901,-2.0666254,0.58718634,0.22949177,-0.8696243,-0.06345688,1.4893534,-1.3439318,-0.18948185,-0.3351259,1.2307497,-0.28781348,1.6409488,-0.19217592,-0.040160403,-1.2495455,-0.79353434,0.0897291,-1.0072155,0.710024,0.0087743625,-0.
6623944,0.81890434,0.047632314,-1.0683899,-0.92522335,-0.47513276,-0.015343539,-0.6294986,-0.087219134,-0.7473418,-0.10130125,0.32038715,-0.84861714,-1.1200238,0.98489106,-0.96401197,1.2406387,0.550124,0.15979329,0.27420345,0.22140944,0.47096312,0.53173524,0.7949892,-0.61875683,0.377585,1.0622563,0.5006883,-1.6870648,1.078
1026,-0.83679813,0.11122566,-0.12569964,-0.4544682,0.037977166,1.2258936,-1.1337754,0.63929975,1.169356,0.45393616,0.08465384,0.5012061,-0.49980778,0.40308383,-0.8286698,0.37403655,-1.300616,1.2509619,-1.4532592,-0.35904032,-0.6624825,-1.6585492,-0.06107377,2.1272461,0.8137893,0.40437463,-0.82771426,-1.7959766,-0.34300283,
-1.8750148,1.7641492,0.8389914,-0.9931898,-0.118798666,0.7944126,0.6559267,-1.5169412,-1.0970255,0.16457528,-1.3381826,-0.24432787,-0.56764245,0.30859837,1.7957871,0.24969408,1.2589133,-0.02014637,1.5166873,-1.1032529,0.060788915,1.0380023,-0.4322624,-1.3106008,-2.620692,-0.29830018,-0.32864818,-0.0577766,1.203077,-0.02263
3314,0.4265864,0.35697302,1.2155639,0.5998836,0.5129899,-1.5936493,-0.6769576,0.12624131,-0.9248098,-0.98756415,-0.69458115,0.53606355,-0.6176353,0.2634437,1.3000727,-1.1445252,1.0293466,-0.2255072,0.60120314,-0.82454056,-0.27370033,0.038839266,-0.3315014,0.05543253,-0.40813237,-0.5061185,0.15036821,0.58673465,0.3558789,-0
.110330425,2.099685,0.42906773,-0.96592367,0.5274176,-0.12951797,0.9204537,0.044606656,-0.85504013,1.3720906,1.4984303,0.4310723,-0.7574428,1.4318157,-0.8871834,0.97188556,-0.29833567,-0.12126842,-0.69537467,-0.07976196,-1.6965438,-0.8437898,-0.7887466,-0.6232871,0.12332085,2.1694107,0.4116413,0.76948315,0.008735962,-0.678
03526,1.3714213,-1.7274212,0.17823556,0.62862384,-0.43160638,0.78186107,-1.3350407,-0.85398847,1.8264014,-0.91419184,-1.165122,1.9748323,-1.0251974,1.1777215,1.6348068,-0.41248846,0.56573284,-0.28101626,-1.8850484,-0.32845408,0.5666447,1.2498873,-2.1685104,0.9969972,0.53178257,-0.98333716,-0.7395232,-0.022708252,-1.2691327
,1.264078,0.2102158,0.046962038,0.44528237,1.2601712,-1.0742176,0.8497858,1.2970556,-0.65716594,-0.23158589,0.5050014,0.902054,1.2720432,0.42316434,-0.87070924,0.31254968,0.56416684,-1.3891838,0.4641551,0.419734,1.0411412,1.5052916,1.1344291,0.2242203,0.19651699,0.20561124,-0.45608824,1.9116155,-0.39889148,-1.5971285,-0.68
59491,-0.787773,0.15512107,1.001346,0.855088,-0.26812008,1.1974046,0.13142613,-0.9478023,0.9512829,-0.2704708,-0.016892657,-0.3670753,-0.9159567,-1.2320302,0.4133771,-0.8681803,1.4251661,0.57776046,-0.41674992,0.6869668,0.21821564,-1.360913,-1.4105066,0.16086662,-0.07131349,-0.04933752,-0.8234745,1.507961,0.011043764,2.317
7288,0.5570995,-1.8301374,0.51244676,0.8547697,-1.6455457,1.092367,0.3473053,0.24100137,1.5002866,0.6320008,1.6323055,1.0846812,0.88156337,1.8633757,-0.27837777,0.7851393,2.8194044,-0.39034802,-0.7024909,0.0628206,-0.7563112,0.09788756,0.5792079,-0.5977477,-0.81693566,2.6513054,-0.45637763,-1.3154873,1.0423906,-1.936639,0.
7457389,-0.08859518,0.03380087,0.5049745,0.011929229,-1.622314,1.4616587,-1.3219377,0.29343045,0.6901181,0.3743369,0.2878334,1.4319487,0.5594059,-0.9282073,-0.48565295,0.5674298,-0.17472267,2.6710472,-0.110397175,0.2482945,0.5699501,-1.1379341,-0.54587644,0.34772202,0.17640287,0.47253966,-1.7235391,0.50947917,-0.10452123,-
0.4650715,-1.7899498,1.4170616,1.2587667,-0.32519194,-0.50637627,-0.09973012,0.40752777,1.1211467,0.5550873,-1.5230548,0.16425239,0.6114096,1.4936831,0.73687965,0.31477886,-0.41603214,0.93154186,-0.9691839,-1.39088,-1.0824782,-0.29597214,1.0750867,0.18936971,-1.8706441,-1.5932168,-0.12911442,-0.45460972,-0.9710786,0.272755
06,1.9453589,0.096132934,1.0296719,0.5026763,1.0666534,2.937318,-1.8642614,0.8494043,-0.4513197,-0.070865944,-0.8156342,-0.494829,-2.2630415,-0.04521261,-0.8198614,0.6784637,-0.26335776,0.50929445,-0.480595,-0.738435,-0.07734607,0.69793415,-2.013504,-1.5306449,0.023005374,1.6693491,0.09050509,0.8106611,-0.63408685,-1.35005
08,0.9758173,0.93798584,0.32654053,-0.16428535,-0.15051918,-0.23394097,-0.18614581,1.2231066,0.13426754,-0.06625563,-1.2626891,0.9684353,-0.8356042,-0.4947293,-1.4964509,0.7782229,1.5097488,-0.00047343224,-0.21312803,-0.6538822,-0.16427866,0.27057403,-0.039979406,-0.4478521,0.17071804,-0.40885985,0.14234143,-0.5869274,-1.1
352326,0.6223447,-0.48805603,-1.3599315,1.7058398,-0.7298723,0.932437,-0.20832923,-0.85343635,-2.0496023,1.1579838,-0.14965242,-0.53624,-0.73202527,-0.554747,-0.657742,-0.51424706,-1.4359083,2.2077253,-1.7856925,1.3506997,-0.274692,0.27462155,-0.22170462,0.8842869,-1.6328788,1.2321444,0.29115736,-0.6685146,-0.21041444,0.31
806752,-1.3123707,-1.4234347,-0.24965434,-1.0191402,0.10539922,-2.4055085,-0.6674118,-1.1760979,-0.35926247,2.2650666,-0.8573348,-1.4796362,-1.0247847,-1.1063806,1.0939171,1.1457555,-1.4504764,0.6838246,-0.42846993,-2.91854,1.3558744,-2.2733457,-0.32632965,-0.3569683,-0.5832101,0.684401,0.045376863,1.1792623,-1.4583936,0.4
1077682,-0.5847836,1.8374054,-0.48925608,1.2985682,1.062664,0.5439538,-0.15848544,-0.3527093,-1.2929813,2.026558,0.20410264]'
Feb 19 22:32:09 sol immich-server[1051197]:   ]
Feb 19 22:32:09 sol immich-server[1051197]: }
Feb 19 22:32:09 sol immich-server[1051197]: [Nest] 2  - 02/19/2026, 10:32:09 PM   ERROR [Microservices:{"id":"35d5a763-9bbd-4853-9663-eacfb63af83a"}] Unable to run job handler (AssetDetectFaces): PostgresError: duplicate key value violates unique constraint "face_search_pkey"

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions