The sync target could not be upgraded due to an error

Operating system

macOS

Joplin version

2.14.22

Sync target

Joplin Server

Editor

Rich Text Editor

What issue do you have?

On all Joplin clients (Mac, Windows, Android) I see that the sync target needs to be upgraded. I tried on the Mac clients, but I receive the error in the title. Then I get the error in the screenshot. It sounds like it should be performing and UPDATE to the SQL server in the backend, but it is performing a INSERT.

I have tried to delete remote data and re-upload in the advanced sync settings. This did not fix the issue.

Screenshots

Forgot server logs.

05:41:40 0|app    | 2024-06-30 05:41:40: [error] App: 404: GET /api/items/root:/info.json:/content: 25S1ec6BXnf7wzEeowZBt6yvGfw4EdbX: Not found: root:/info.json:
05:41:40 0|app    | 2024-06-30 05:41:40: App: GET /api/items/root:/info.json:/content (404) (2ms)
05:41:40 0|app    | 2024-06-30 05:41:40: App: GET /api/items/root:/.sync/version.txt:/content (200) (3ms)
05:41:40 0|app    | 2024-06-30 05:41:40: App: POST /api/locks (200) (3ms)
05:41:40 0|app    | 2024-06-30 05:41:40: App: PUT /api/items/root:/.sync/version.txt:/content (200) (16ms)
05:41:40 0|app    | 2024-06-30 05:41:40: App: PUT /api/items/root:/.sync/readme.txt:/content (200) (12ms)
05:41:40 0|app    | 2024-06-30 05:41:40: [error] db: insert into "items" ("content_size", "content_storage_id", "created_time", "id", "mime_type", "name", "owner_id", "updated_time") values ($1, $2, $3, $4, $5, $6, $7, $8) - duplicate key value violates unique constraint "items_name_owner_id_unique" {
05:41:40 0|app    |   "$1": 13,
05:41:40 0|app    |   "$2": 1,
05:41:40 0|app    |   "$3": 1719751300404,
05:41:40 0|app    |   "$4": "5S8DJG6FYcrH9RpFZKonFv",
05:41:40 0|app    |   "$5": "application/json",
05:41:40 0|app    |   "$6": "info.json",
05:41:40 0|app    |   "$7": "25S1ec6BXnf7wzEeowZBt6yvGfw4EdbX",
05:41:40 0|app    |   "$8": 1719751300404
05:41:40 0|app    | }
05:41:40 0|app    | 2024-06-30 05:41:40: [error] ItemModel: Unique constraint error on item: {"name":"info.json","owner_id":"25S1ec6BXnf7wzEeowZBt6yvGfw4EdbX"} error: insert into "items" ("content_size", "content_storage_id", "created_time", "id", "mime_type", "name", "owner_id", "updated_time") values ($1, $2, $3, $4, $5, $6, $7, $8) - duplicate key value violates unique constraint "items_name_owner_id_unique"
05:41:40 0|app    |     at Parser.parseErrorMessage (/home/joplin/packages/server/node_modules/pg-protocol/src/parser.ts:369:69)
05:41:40 0|app    |     at Parser.handlePacket (/home/joplin/packages/server/node_modules/pg-protocol/src/parser.ts:188:21)
05:41:40 0|app    |     at Parser.parse (/home/joplin/packages/server/node_modules/pg-protocol/src/parser.ts:103:30)
05:41:40 0|app    |     at Socket.<anonymous> (/home/joplin/packages/server/node_modules/pg-protocol/src/index.ts:7:48)
05:41:40 0|app    |     at Socket.emit (node:events:517:28)
05:41:40 0|app    |     at addChunk (node:internal/streams/readable:368:12)
05:41:40 0|app    |     at readableAddChunk (node:internal/streams/readable:341:9)
05:41:40 0|app    |     at Socket.Readable.push (node:internal/streams/readable:278:10)
05:41:40 0|app    |     at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
05:41:40 0|app    |   length: 266,
05:41:40 0|app    |   severity: 'ERROR',
05:41:40 0|app    |   code: '23505',
05:41:40 0|app    |   detail: 'Key (name, owner_id)=(info.json, 25S1ec6BXnf7wzEeowZBt6yvGfw4EdbX) already exists.',
05:41:40 0|app    |   hint: undefined,
05:41:40 0|app    |   position: undefined,
05:41:40 0|app    |   internalPosition: undefined,
05:41:40 0|app    |   internalQuery: undefined,
05:41:40 0|app    |   where: undefined,
05:41:40 0|app    |   schema: 'public',
05:41:40 0|app    |   table: 'items',
05:41:40 0|app    |   column: undefined,
05:41:40 0|app    |   dataType: undefined,
05:41:40 0|app    |   constraint: 'items_name_owner_id_unique',
05:41:40 0|app    |   file: 'nbtinsert.c',
05:41:40 0|app    |   line: '563',
05:41:40 0|app    |   routine: '_bt_check_unique'
05:41:40 0|app    | }
05:41:40 0|app    | 2024-06-30 05:41:40: [error] App: 409: PUT /api/items/root:/info.json:/content: 25S1ec6BXnf7wzEeowZBt6yvGfw4EdbX: This item is already present and cannot be added again: info.json
05:41:40 0|app    | 2024-06-30 05:41:40: App: PUT /api/items/root:/info.json:/content (409) (9ms)
05:41:40 0|app    | 2024-06-30 05:41:40: App: DELETE /api/locks/2_1_0d3be438f1644098830b914e3ded1072 (200) (4ms)