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

The failure condition being fixed is `w1` and `w2` could belong
to different users, organizations, and templates and still cause a
serializable failure if run concurrently. This is because the old query 
did a `seq scan` on the `workspace_builds` table. Since that is the 
table being updated, we really want to prevent that.

So before this would fail for any 2 workspaces. Now it only fails if
`w1` and `w2` are owned by the same user and organization.
This commit is contained in:
Steven Masley
2024-11-01 11:05:49 -04:00
committed by GitHub
parent 47f9a8aeb8
commit 854044e811
15 changed files with 982 additions and 23 deletions
+15
View File
@@ -4329,6 +4329,21 @@ func (mr *MockStoreMockRecorder) OrganizationMembers(arg0, arg1 any) *gomock.Cal
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OrganizationMembers", reflect.TypeOf((*MockStore)(nil).OrganizationMembers), arg0, arg1)
}
// PGLocks mocks base method.
func (m *MockStore) PGLocks(arg0 context.Context) (database.PGLocks, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "PGLocks", arg0)
ret0, _ := ret[0].(database.PGLocks)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// PGLocks indicates an expected call of PGLocks.
func (mr *MockStoreMockRecorder) PGLocks(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PGLocks", reflect.TypeOf((*MockStore)(nil).PGLocks), arg0)
}
// Ping mocks base method.
func (m *MockStore) Ping(arg0 context.Context) (time.Duration, error) {
m.ctrl.T.Helper()