Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): remove shared links during user delete #7696

Merged

Conversation

samholton
Copy link
Contributor

Fixes issues during user deletion when the user has shared links.

immich_postgres          | 2024-03-07 03:47:24.007 UTC [360] ERROR:  update or delete on table "users" violates foreign key constraint "FK_66fe3837414c5a9f1c33ca49340" on table "shared_links"
immich_postgres          | 2024-03-07 03:47:24.007 UTC [360] DETAIL:  Key (id)=(1c54b3e7-4323-4801-a46d-2107af0ee001) is still referenced from table "shared_links".
immich_postgres          | 2024-03-07 03:47:24.007 UTC [360] STATEMENT:  DELETE FROM "users" WHERE "id" = $1
immich_microservices     | [Nest] 110  - 03/07/2024, 3:47:24 AM   ERROR [JobService] Unable to run job handler (backgroundTask/user-deletion): QueryFailedError: update or delete on table "users" violates foreign key constraint "FK_66fe3837414c5a9f1c33ca49340" on table "shared_links"
immich_microservices     | [Nest] 110  - 03/07/2024, 3:47:24 AM   ERROR [JobService] QueryFailedError: update or delete on table "users" violates foreign key constraint "FK_66fe3837414c5a9f1c33ca49340" on table "shared_links"
immich_microservices     |     at PostgresQueryRunner.query (/usr/src/app/src/driver/postgres/PostgresQueryRunner.ts:331:19)
immich_microservices     |     at processTicksAndRejections (node:internal/process/task_queues:95:5)
immich_microservices     |     at DeleteQueryBuilder.execute (/usr/src/app/src/query-builder/DeleteQueryBuilder.ts:77:33)
immich_microservices     |     at SubjectExecutor.executeRemoveOperations (/usr/src/app/src/persistence/SubjectExecutor.ts:720:17)
immich_microservices     |     at SubjectExecutor.execute (/usr/src/app/src/persistence/SubjectExecutor.ts:156:9)
immich_microservices     |     at EntityPersistExecutor.execute (/usr/src/app/src/persistence/EntityPersistExecutor.ts:182:21)
immich_microservices     |     at UserService.handleUserDelete (/usr/src/app/src/domain/user/user.service.ts:198:5)
immich_microservices     |     at /usr/src/app/src/domain/job/job.service.ts:158:27
immich_microservices     |     at Worker.processJob (/usr/src/app/node_modules/bullmq/src/classes/worker.ts:741:22)
immich_microservices     |     at Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/src/classes/worker.ts:944:16)

Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use cascades instead?

Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Maybe after your force user PR is merged we can add an e2e test for this.

@samholton
Copy link
Contributor Author

Looks good! Maybe after your force user PR is merged we can add an e2e test for this.

Will take a look at that tonight to add the state field

@jrasm91 jrasm91 merged commit dbb6a8d into immich-app:main Mar 7, 2024
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants