Skip to content

chore: fix concurrent CommitQuota transactions for unrelated users/orgs #15261

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

Merged
merged 19 commits into from
Nov 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix comment
  • Loading branch information
Emyrk committed Oct 28, 2024
commit ec8f799148fb7c0aa3c714c53e6fee87d5a79a09
2 changes: 1 addition & 1 deletion enterprise/coderd/workspacequota_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,14 @@
// +------------------------------+------------------+
// pq: could not serialize access due to concurrent update
ctx := testutil.Context(t, testutil.WaitLong)
ctx = dbauthz.AsSystemRestricted(ctx)

Check failure on line 374 in enterprise/coderd/workspacequota_test.go

View workflow job for this annotation

GitHub Actions / lint

ruleguard: Using 'AsSystemRestricted' is dangerous and should be accompanied by a comment explaining why it's ok and a nolint. (gocritic)

myWorkspace := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
OrganizationID: org.Org.ID,
OwnerID: user.ID,
}).Do()

bumpDeadline := func() {

Check failure on line 381 in enterprise/coderd/workspacequota_test.go

View workflow job for this annotation

GitHub Actions / lint

empty-lines: extra empty line at the end of a block (revive)
err := db.InTx(func(db database.Store) error {
err := db.UpdateWorkspaceBuildDeadlineByID(ctx, database.UpdateWorkspaceBuildDeadlineByIDParams{
Deadline: dbtime.Now(),
Expand Down Expand Up @@ -424,7 +424,7 @@
// +------------------------------+------------------+
// Works!
ctx := testutil.Context(t, testutil.WaitLong)
ctx = dbauthz.AsSystemRestricted(ctx)

Check failure on line 427 in enterprise/coderd/workspacequota_test.go

View workflow job for this annotation

GitHub Actions / lint

ruleguard: Using 'AsSystemRestricted' is dangerous and should be accompanied by a comment explaining why it's ok and a nolint. (gocritic)

myWorkspace := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
OrganizationID: org.Org.ID,
Expand Down Expand Up @@ -487,7 +487,7 @@
// +---------------------+----------------------------------+
// pq: could not serialize access due to concurrent update
ctx := testutil.Context(t, testutil.WaitShort)
ctx = dbauthz.AsSystemRestricted(ctx)

Check failure on line 490 in enterprise/coderd/workspacequota_test.go

View workflow job for this annotation

GitHub Actions / lint

ruleguard: Using 'AsSystemRestricted' is dangerous and should be accompanied by a comment explaining why it's ok and a nolint. (gocritic)

myWorkspace := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
OrganizationID: org.Org.ID,
Expand Down Expand Up @@ -536,7 +536,7 @@
// +---------------------+----------------------------------+
// pq: could not serialize access due to concurrent update
ctx := testutil.Context(t, testutil.WaitShort)
ctx = dbauthz.AsSystemRestricted(ctx)

Check failure on line 539 in enterprise/coderd/workspacequota_test.go

View workflow job for this annotation

GitHub Actions / lint

ruleguard: Using 'AsSystemRestricted' is dangerous and should be accompanied by a comment explaining why it's ok and a nolint. (gocritic)

myWorkspace := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
OrganizationID: org.Org.ID,
Expand Down Expand Up @@ -581,7 +581,7 @@
// +---------------------+----------------------------------+
// Works!
ctx := testutil.Context(t, testutil.WaitShort)
ctx = dbauthz.AsSystemRestricted(ctx)

Check failure on line 584 in enterprise/coderd/workspacequota_test.go

View workflow job for this annotation

GitHub Actions / lint

ruleguard: Using 'AsSystemRestricted' is dangerous and should be accompanied by a comment explaining why it's ok and a nolint. (gocritic)
var err error

myWorkspace := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
Expand Down Expand Up @@ -634,9 +634,9 @@
// +---------------------+---------------------+
// | | CommitTx() |
// +---------------------+---------------------+
// pq: could not serialize access due to read/write dependencies among tra
// pq: could not serialize access due to read/write dependencies among transactions
ctx := testutil.Context(t, testutil.WaitLong)
ctx = dbauthz.AsSystemRestricted(ctx)

Check failure on line 639 in enterprise/coderd/workspacequota_test.go

View workflow job for this annotation

GitHub Actions / lint

ruleguard: Using 'AsSystemRestricted' is dangerous and should be accompanied by a comment explaining why it's ok and a nolint. (gocritic)

myWorkspace := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
OrganizationID: org.Org.ID,
Expand Down
Loading