mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-06 09:13:19 +03:00
[PR #392] [MERGED] fix: use transactions when operations involve multiple database queries #832
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/pocket-id/pocket-id/pull/392
Author: @ItalyPaleAle
Created: 3/27/2025
Status: ✅ Merged
Merged: 4/6/2025
Merged by: @stonith404
Base:
main← Head:tx📝 Commits (9)
9c8d281use transactions when operations involve multiple database queriesae0daefUpdate more methods for transactions and contexts008c9acMerge branch 'main' into txdb96490Merge branch 'main' into txd8b9e73Merge branch 'main' of https://github.com/pocket-id/pocket-id into txe748c47Missing these from merge3d5a05fUpdated newly-added methods too3827b50Merge branch 'main' of https://github.com/pocket-id/pocket-id into tx3b89df0Re-add transaction needed to roll-back📊 Changes
33 files changed (+1398 additions, -498 deletions)
View changed files
📝
backend/internal/bootstrap/bootstrap.go(+6 -2)📝
backend/internal/bootstrap/router_bootstrap.go(+7 -6)📝
backend/internal/common/errors.go(+1 -1)📝
backend/internal/controller/api_key_controller.go(+3 -3)📝
backend/internal/controller/app_config_controller.go(+9 -10)📝
backend/internal/controller/audit_log_controller.go(+4 -2)📝
backend/internal/controller/custom_claim_controller.go(+3 -3)📝
backend/internal/controller/oidc_controller.go(+16 -15)📝
backend/internal/controller/user_controller.go(+13 -13)📝
backend/internal/controller/user_group_controller.go(+9 -7)📝
backend/internal/controller/webauthn_controller.go(+7 -7)📝
backend/internal/job/db_cleanup_job.go(+34 -17)📝
backend/internal/job/file_cleanup_job.go(+11 -5)📝
backend/internal/job/job.go(+3 -1)📝
backend/internal/job/ldap_job.go(+12 -9)📝
backend/internal/middleware/api_key_auth.go(+1 -1)📝
backend/internal/service/api_key_service.go(+36 -20)📝
backend/internal/service/app_config_service.go(+137 -57)📝
backend/internal/service/audit_log_service.go(+40 -16)📝
backend/internal/service/custom_claim_service.go(+86 -45)...and 13 more files
📄 Description
Currently, the backend does not use database transactions, even when there are operations performed in sequence. For example:
4d049bbe24/backend/internal/service/user_service.go (L166-L194)where the user is loaded from the DB and then updatesThis can cause a number of problems if multiple requests happen in parallel, and in some cases could also have security implications.
This PR updates the backend's to add transactions where they are needed.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.