This is an automated email from the ASF dual-hosted git repository. yasithdev pushed a commit to branch project-no-key-lock in repository https://gitbox.apache.org/repos/asf/airavata-custos.git
commit ca266c98865df7f39b76e5a553eefe0e6888b1bf Author: Yasith Jayawardana <[email protected]> AuthorDate: Thu Nov 5 23:24:59 2026 -0500 Lock project rows FOR NO KEY UPDATE A create or renewal packet for an inactive project with no allocation hung: the packet tx locked the project FOR UPDATE, and the allocation insert in a second tx waited on its foreign-key KEY SHARE lock forever. FOR NO KEY UPDATE still serializes status changes but lets foreign-key inserts through. --- internal/store/project_store.go | 2 +- internal/store/store.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/store/project_store.go b/internal/store/project_store.go index efc6f455c..381303eb4 100644 --- a/internal/store/project_store.go +++ b/internal/store/project_store.go @@ -89,7 +89,7 @@ func (s *pgProjectStore) FindByID(ctx context.Context, id string) (*models.Proje func (s *pgProjectStore) FindByIDTx(ctx context.Context, tx *sql.Tx, id string) (*models.Project, error) { var r models.Project err := (&sqlx.Tx{Tx: tx, Mapper: s.db.Mapper}).GetContext(ctx, &r, - `SELECT `+projectColumns+` FROM projects WHERE id = $1 FOR UPDATE`, id) + `SELECT `+projectColumns+` FROM projects WHERE id = $1 FOR NO KEY UPDATE`, id) if errors.Is(err, sql.ErrNoRows) { return nil, nil } diff --git a/internal/store/store.go b/internal/store/store.go index 8e0030d71..a077d42f8 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -144,7 +144,7 @@ type UserIdentityStore interface { type ProjectStore interface { // FindByID returns the project with the given ID, or nil if not found. FindByID(ctx context.Context, id string) (*models.Project, error) - // FindByIDTx returns the project locked FOR UPDATE in tx, or nil if not found. + // FindByIDTx returns the project locked FOR NO KEY UPDATE in tx, or nil if not found. FindByIDTx(ctx context.Context, tx *sql.Tx, id string) (*models.Project, error) // FindByOriginatedID returns the project matching the external originated ID, or nil if not found. FindByOriginatedID(ctx context.Context, originatedID string) (*models.Project, error)
