Skip to content

fix(devops): synchronize canvas cache updates - #963

Open
dajiaohuang wants to merge 1 commit into
cloudwego:mainfrom
dajiaohuang:fix/devops-canvas-race
Open

fix(devops): synchronize canvas cache updates#963
dajiaohuang wants to merge 1 commit into
cloudwego:mainfrom
dajiaohuang:fix/devops-canvas-race

Conversation

@dajiaohuang

Copy link
Copy Markdown

What type of PR is this?

fix

Check the PR title.

  • This PR title matches the format: <type>(optional scope): <description>
  • The description is user-oriented and clear.
  • No user documentation update is required; this only synchronizes internal cache access.

(Optional) Translate the PR title into Chinese.

fix(devops): 同步 canvas 缓存更新

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:

CreateCanvas assigned GraphContainer.CanvasInfo after releasing the container service mutex, while GetCanvas read the pointer under the corresponding read lock. Concurrent canvas creation and lookup therefore produced read/write and write/write race reports.

This change protects the cache assignment with the service mutex and adds a concurrent regression test. The test reproduces the race before this change and passes under the race detector afterward.

Validation:

  • go test -gcflags='all=-N -l' ./internal/service -run '^Test_containerServiceImpl_CreateCanvas$' -count=10 (Windows, Go 1.26.3)
  • go test -race -gcflags='all=-N -l' ./internal/service -run '^Test_containerServiceImpl_CreateCanvas$' -count=10 (Linux, Go 1.25.6)
  • go vet ./internal/service
  • git diff --check

(Optional) Which issue(s) this PR fixes:

Fixes #961

(optional) The PR that updates user documentation:

Not required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

devops: concurrent canvas creation and lookup race on CanvasInfo

1 participant