Skip to content

fix data race on lazy tx id#2152

Open
asmyasnikov wants to merge 4 commits into
masterfrom
data-race-tx-id
Open

fix data race on lazy tx id#2152
asmyasnikov wants to merge 4 commits into
masterfrom
data-race-tx-id

Conversation

@asmyasnikov

Copy link
Copy Markdown
Member

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: #2151

What is the new behavior?

Other information

@asmyasnikov
asmyasnikov requested review from Copilot and rekby May 12, 2026 10:06
@github-actions

github-actions Bot commented May 12, 2026

Copy link
Copy Markdown

summary

Inferred base version: v3.136.2
Suggested version: v3.136.3

@codecov-commenter

codecov-commenter commented May 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 16.77019% with 134 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.65%. Comparing base (f70288e) to head (956f82a).
⚠️ Report is 45 commits behind head on master.

Files with missing lines Patch % Lines
internal/mock/server.go 0.00% 134 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2152      +/-   ##
==========================================
- Coverage   74.89%   71.65%   -3.24%     
==========================================
  Files         428      428              
  Lines       37432    37572     +140     
==========================================
- Hits        28035    26923    -1112     
- Misses       8193     9434    +1241     
- Partials     1204     1215      +11     
Flag Coverage Δ
experiment ?
go-1.21.x 71.59% <16.77%> (-0.39%) ⬇️
go-1.26.x 71.60% <16.77%> (-3.29%) ⬇️
integration 57.04% <100.00%> (-0.24%) ⬇️
macOS 45.77% <6.21%> (-0.20%) ⬇️
ubuntu 71.65% <16.77%> (-3.24%) ⬇️
unit 45.80% <6.21%> (-0.18%) ⬇️
windows 45.79% <6.21%> (-0.17%) ⬇️
ydb-24.4 56.47% <100.00%> (-0.29%) ⬇️
ydb-edge 56.75% <100.00%> (-0.31%) ⬇️
ydb-latest 56.69% <100.00%> (-0.26%) ⬇️
ydb-nightly ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to eliminate a reported data race around lazy transaction ID materialization in topic-table transactional workflows (Issue #2151) by making LazyID’s underlying storage concurrency-safe.

Changes:

  • Switched internal/tx.LazyID from a plain *string field to atomic.Pointer[string] with atomic load/store in ID() / SetTxID().
  • Added a CHANGELOG entry describing the data race fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/tx/id.go Uses atomic load/store for the lazy transaction ID storage.
CHANGELOG.md Documents the fix at the top of the changelog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/tx/id.go
@rekby
rekby force-pushed the data-race-tx-id branch from 43a476f to 075629d Compare May 13, 2026 11:26
}
txID, err := begin(ctx, tx.s.client, tx.s.ID(), tx.txSettings)
err = xerrors.WithStackTrace(err)
tx.SetTxID(txID)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут же все равно возможна гонка между вызовами SetTxID() и ID() из разных горутин

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants