Skip to content

tests/realtikvtest: tolerate next-gen lazy uniqueness conflict reasons#67506

Closed
zanmato1984 wants to merge 1 commit into
pingcap:masterfrom
zanmato1984:fix-67503-nextgen-lazy-uniqueness
Closed

tests/realtikvtest: tolerate next-gen lazy uniqueness conflict reasons#67506
zanmato1984 wants to merge 1 commit into
pingcap:masterfrom
zanmato1984:fix-67503-nextgen-lazy-uniqueness

Conversation

@zanmato1984

@zanmato1984 zanmato1984 commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #67503

Problem Summary:

pull-integration-realcluster-test-next-gen started failing in TestLazyUniquenessCheck and TestLazyUniquenessCheckWithInconsistentReadResult after the next-gen job switched to a different TiKV/TiKV-worker artifact family. The current TiDB tests assume every non-classic environment reports reason=NotLockedKeyConflict, but the affected next-gen environment can report reason=LazyUniquenessCheck for the same lazy uniqueness conflict.

What changed and how does it work?

Keep the classic assertion unchanged and relax the next-gen assertion in the two affected tests to accept either reason=LazyUniquenessCheck or reason=NotLockedKeyConflict.

This matches the current engine-family divergence without changing production behavior.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    • make bazel_prepare
    • go test -run '^$' -tags=intest,deadlock ./tests/realtikvtest/pessimistictest/...
    • Attempted scoped RealTiKV run:
      • go test -run '^(TestLazyUniquenessCheck|TestLazyUniquenessCheckWithInconsistentReadResult)$' -tags=intest,deadlock ./tests/realtikvtest/pessimistictest/... -args -tikv-path 'tikv://127.0.0.1:12379?disableGC=true'
      • Local tiup playground resolved to v8.5.5, whose PD API is too old for current master on this machine (GetGCState / QueryRegion unimplemented), so the full RealTiKV verification needs CI.
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

Summary by CodeRabbit

  • Tests
    • Updated assertions for lazy uniqueness conflict detection in pessimistic transaction tests to provide more flexible validation of error conditions.

@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. labels Apr 2, 2026
@pantheon-ai

pantheon-ai Bot commented Apr 2, 2026

Copy link
Copy Markdown

@zanmato1984 I've received your pull request and will start the review. I'll conduct a thorough review covering code quality, potential issues, and implementation details.

⏳ This process typically takes 10-30 minutes depending on the complexity of the changes.

ℹ️ Learn more details on Pantheon AI.

@ti-chi-bot

ti-chi-bot Bot commented Apr 2, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign bb7133 for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 2, 2026
@tiprow

tiprow Bot commented Apr 2, 2026

Copy link
Copy Markdown

Hi @zanmato1984. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@zanmato1984 zanmato1984 requested a review from ekexium April 2, 2026 03:39
@coderabbitai

coderabbitai Bot commented Apr 2, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This change modifies test assertions for lazy uniqueness conflict detection in pessimistic transaction tests. It replaces a hardcoded assertion with a new helper function that accepts multiple valid error reason values, enabling more flexible error validation across different execution paths.

Changes

Cohort / File(s) Summary
Test Assertion Refactoring
tests/realtikvtest/pessimistictest/pessimistic_test.go
Added requireNextGenLazyUniquenessConflictReason() helper function to validate lazy uniqueness write-conflict errors. Updated TestLazyUniquenessCheck and TestLazyUniquenessCheckWithInconsistentReadResult to use this helper, which accepts either LazyUniquenessCheck or NotLockedKeyConflict as valid error reasons.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A little helper hops along,
Making test assertions strong,
Multiple reasons now pass through,
Flexible checks, both old and new!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly summarizes the main change: updating tests to tolerate multiple next-gen lazy uniqueness conflict reason values.
Description check ✅ Passed The description includes all required sections: issue reference (ref #67503), clear problem statement, explanation of changes, and completed checklist with manual test steps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

Comment on lines +3104 to +3105
strings.Contains(errMsg, "reason=LazyUniquenessCheck") || strings.Contains(errMsg, "reason=NotLockedKeyConflict"),
"expected next-gen lazy uniqueness conflict reason, got %s",

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.

we should use different msg depends on kernel type to be exact

if kerneltype.IsNextGen() {...}
else ...

or better, let's wait tikv side fix this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can't guess if tikv changes the behavior intentionally. If not, tikv should fix it, I agree.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's a mistake by AI in CSE PR#4440. I will fix it in tikv side.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I think I can close this PR now.

@ti-chi-bot

ti-chi-bot Bot commented Apr 2, 2026

Copy link
Copy Markdown

@zanmato1984: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-integration-e2e-test 04ee4bf link true /test pull-integration-e2e-test

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/realtikvtest/pessimistictest/pessimistic_test.go (1)

3099-3108: Guard against nil err before reading error text.

Please assert err first in the helper so unexpected success fails with a clear test assertion instead of a nil-pointer panic.

💡 Suggested patch
 func requireNextGenLazyUniquenessConflictReason(t *testing.T, err error) {
 	t.Helper()
+	require.Error(t, err)
 	errMsg := err.Error()
 	require.Truef(
 		t,
 		strings.Contains(errMsg, "reason=LazyUniquenessCheck") || strings.Contains(errMsg, "reason=NotLockedKeyConflict"),
 		"expected next-gen lazy uniqueness conflict reason, got %s",
 		errMsg,
 	)
 }

As per coding guidelines: Keep error handling actionable and contextual; avoid silently swallowing errors.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/realtikvtest/pessimistictest/pessimistic_test.go` around lines 3099 -
3108, The helper requireNextGenLazyUniquenessConflictReason should guard against
a nil error before calling err.Error(); update the function to assert the error
is non-nil (e.g., using require.Error or require.NotNil on the incoming err) and
only then read err.Error() and check for the "reason=LazyUniquenessCheck" or
"reason=NotLockedKeyConflict" substrings; this prevents a nil-pointer panic and
yields a clear test failure when the operation unexpectedly succeeded.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/realtikvtest/pessimistictest/pessimistic_test.go`:
- Around line 3099-3108: The helper requireNextGenLazyUniquenessConflictReason
should guard against a nil error before calling err.Error(); update the function
to assert the error is non-nil (e.g., using require.Error or require.NotNil on
the incoming err) and only then read err.Error() and check for the
"reason=LazyUniquenessCheck" or "reason=NotLockedKeyConflict" substrings; this
prevents a nil-pointer panic and yields a clear test failure when the operation
unexpectedly succeeded.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f525cd60-320d-4266-9fb5-4ab50915be9f

📥 Commits

Reviewing files that changed from the base of the PR and between 8412422 and 04ee4bf.

📒 Files selected for processing (1)
  • tests/realtikvtest/pessimistictest/pessimistic_test.go

@codecov

codecov Bot commented Apr 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.2054%. Comparing base (8412422) to head (04ee4bf).

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #67506        +/-   ##
================================================
- Coverage   77.7160%   77.2054%   -0.5106%     
================================================
  Files          1959       1942        -17     
  Lines        543377     543384         +7     
================================================
- Hits         422291     419522      -2769     
- Misses       120245     123860      +3615     
+ Partials        841          2       -839     
Flag Coverage Δ
integration 40.9284% <ø> (+4.7537%) ⬆️

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

Components Coverage Δ
dumpling 61.5065% <ø> (ø)
parser ∅ <ø> (∅)
br 48.8241% <ø> (-12.1560%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zanmato1984

Copy link
Copy Markdown
Contributor Author

Closing as #67506 (comment)

@zanmato1984 zanmato1984 closed this Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants