Skip to content

test(nlp): stop copying the atomic lookupNum in synonym tests - #21102

Merged
yuzhichang merged 1 commit into
infiniflow:mainfrom
12britz:fix-21098-synonym-vet
Oct 19, 2026
Merged

yuzhichang merged 1 commit into
infiniflow:mainfrom
12britz:fix-21098-synonym-vet

Conversation

@12britz

@12britz 12britz commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #21098.

What problem does this PR solve?

go vet ./internal/service/nlp fails:

internal/service/nlp/synonym_test.go:261:17: assignment copies lock value to originalNum: sync/atomic.Int64 contains sync/atomic.noCopy

Synonym.lookupNum is an atomic.Int64 value field. TestSynonymLoadNoRedis copies it by value, which violates the noCopy contract that atomic.Int64 exists to catch.

What is changed?

Read the value with Load() instead of copying the field:

originalNum := s.lookupNum.Load()
s.load()
if s.lookupNum.Load() != originalNum {

Verification

CGO_ENABLED=0 go vet ./internal/service/nlp/    # passes
CGO_ENABLED=0 go test ./internal/service/nlp/   # passes

Type of change

  • Bug Fix (non-breaking change which fixes an issue)

go vet flags the by-value copy of Synonym.lookupNum (an atomic.Int64)
in TestSynonymLoadNoRedis: copying an atomic value violates the noCopy
contract. Read it with Load() instead of assigning the field.

Closes infiniflow#21098
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5d56178d-039b-482b-a323-6554f28e5cd6
📥 Commits

Reviewing files that changed from the base of the PR and between 543e167 and 3b8a40d.

📒 Files selected for processing: 1
  • internal/service/nlp/synonym_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

TestSynonymLoadNoRedis now uses atomic Load calls to capture and compare the lookup count.

Changes: Synonym test

Layer / File(s) Summary
Atomic lookup counter check
internal/service/nlp/synonym_test.go
The test reads the lookup counter with Load before and after calling load.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Other · Severity of issue fixed: Low

Suggested reviewers: yuzhichang

Merge Risk: ⚪ Minimal · up to 3b8a4

This is a narrowly scoped test change with no identified merge-blocking risk.

Pre-merge checks: Passed 5
Check name Status Explanation
Description check Passed The description clearly explains the vet warning, the atomic Load() fix, verification steps, and change type. It does not use the required "### Summary" heading, but it provides the required summary i…
Title check Passed The title is concise, specific, and accurately describes the main test change: avoiding a by-value copy of the atomic lookup counter.
Linked Issues check Passed Issue #21098 requires replacing the by-value copy of Synonym.lookupNum with atomic Load() calls. The pull request changes TestSynonymLoadNoRedis to call s.lookupNum.Load() before and after `s.…
Out of Scope Changes check Passed The reviewed change is limited to the two test expressions required by issue #21098. The change adds no unrelated implementation, test, or documentation scope.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
Full details: Description check

Explanation

The description clearly explains the vet warning, the atomic Load() fix, verification steps, and change type. It does not use the required "### Summary" heading, but it provides the required summary information in other sections.

Full details: Linked Issues check

Explanation

Issue #21098 requires replacing the by-value copy of Synonym.lookupNum with atomic Load() calls. The pull request changes TestSynonymLoadNoRedis to call s.lookupNum.Load() before and after s.load(). This removes the atomic.Int64 copy that triggers go vet.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the count with care,
One atomic load, then another there.
No copied lock can trip the gate,
The test now reads its value straight.
I hop away; the checks are clear.

Comment @coderabbitai help to get the list of available commands.

@jay77721
jay77721 self-requested a review October 19, 2026 05:54
@jay77721 jay77721 added the ci Continue Integration label Oct 19, 2026
@yuzhichang
yuzhichang merged commit 2488925 into infiniflow:main Oct 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug](test): go vet flags assignment copies lock value — atomic.Int64 copied by value in synonym_test.go

3 participants