Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc73b70c

Browse files
committed
fix(coderd/database/dbfake): use transaction for workspace builder
While investigating a flake I noticed that the dbfake workspace builderexecutes all database inserts without a transaction. Since our realwsbuilder implementation utilizes one it makes sense to do here as well.For example, our normal workspace <-> build relationship is such that aworkspace cannot exist with at least one build. However, ourGetWorkspaces query left joins workspace builds but has types that arenon-nullable, leading to flakes likecoder/internal#1103.
1 parentd8b1ca7 commitc73b70c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎coderd/database/dbfake/dbfake.go‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,19 @@ func (b WorkspaceBuildBuilder) Canceled() WorkspaceBuildBuilder {
161161
// Workspace will be optionally populated if no ID is set on the provided
162162
// workspace.
163163
func (bWorkspaceBuildBuilder)Do()WorkspaceResponse {
164+
varrespWorkspaceResponse
165+
// Use transaction, like real wsbuilder.
166+
err:=b.db.InTx(func(tx database.Store)error {
167+
//nolint:revive // calls do on modified struct
168+
b.db=tx
169+
resp=b.do()
170+
returnnil
171+
},nil)
172+
require.NoError(b.t,err)
173+
returnresp
174+
}
175+
176+
func (bWorkspaceBuildBuilder)do()WorkspaceResponse {
164177
b.t.Helper()
165178
jobID:=uuid.New()
166179
b.seed.ID=uuid.New()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp