Skip to content

golangci-lint: enable contextcheck linter, part 1 - #20863

Open
timvaillancourt wants to merge 5 commits into
vitessio:mainfrom
timvaillancourt:contextcheck-linter
Open

golangci-lint: enable contextcheck linter, part 1#20863
timvaillancourt wants to merge 5 commits into
vitessio:mainfrom
timvaillancourt:contextcheck-linter

Conversation

@timvaillancourt

@timvaillancourt timvaillancourt commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Description

contextcheck detects functions that replace an inherited context.Context, potentially dropping cancellation, deadlines and request-scoped values. Context handling is a recurring theme in Vitess reviews; enabling this linter should move more of that checking into CI/pre-commit

This is the first of a planned 4 PR rollout, addressing 53 of 230 findings (23%) across 13 of the 76 affected non-test source files. Another benefit of the incremental rollout is that each round requires us to fix existing context/cancellation bugs before enforcing the linter

.golangci.yml enables contextcheck for migrated paths, permanently excludes test code and temporarily excludes deferred packages for the next 3 rounds

10 examples of high-impact fixes:

  1. Prevent concurrent VTAdmin.StartWorkflow requests from running restart safety checks against the wrong cluster
  2. Cancel VTAdmin backend operations when their HTTP request disconnects or times out
  3. Keep the active VTAdmin dynamic cluster when cancellation occurs during its comparison with a request-provided cluster
  4. Propagate cancellation into Consul discovery, avoiding stalled discovery calls while VTAdmin holds its cluster mutex
  5. Terminate running custom hooks on cancellation without misclassifying them as missing; genuinely missing hooks still return HOOK_DOES_NOT_EXIST
  6. Propagate cancellation through MySQL start, configuration and replication hooks
  7. Bound S3 credential loading and bucket validation by the caller context, let cancelled initialization waiters exit promptly and avoid caching failed clients
  8. Interrupt binlog streamer connection and checksum setup when the caller cancels
  9. Honour vitessdriver.BeginTx cancellation, including the distributed-transaction session-token path
  10. Stop copy-progress queries when their vtctl command is cancelled, without panicking if cancellation occurs during a topo lookup

Existing contextless public APIs remain as compatibility wrappers. Intentional component-lifecycle contexts are documented with targeted exclusions, and cancellation/failure-path tests are included. The user-visible cancellation changes are documented in the v25 release notes

Related Issue(s)

N/A

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

AI Disclosure

OpenAI Codex assisted with development, testing and this PR summary

Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Copilot AI balanced review requested due to automatic review settings August 18, 2026 22:40
@vitess-bot vitess-bot Bot added NeedsWebsiteDocsUpdate What it says NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Aug 18, 2026
@github-actions github-actions Bot added this to the v25.0.0 milestone Aug 18, 2026
@vitess-bot

vitess-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@timvaillancourt timvaillancourt added Type: Internal Cleanup Component: General Changes throughout the code base Needs Triage This issue needs to be correctly labelled and triaged and removed Component: VTAdmin VTadmin interface Component: Documentation docs related issues/PRs Component: vtexplain changes made to vtexplain code NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request Component: vtctldclient NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Aug 18, 2026
@timvaillancourt timvaillancourt self-assigned this Aug 18, 2026
@timvaillancourt timvaillancourt removed the Needs Triage This issue needs to be correctly labelled and triaged label Aug 18, 2026

This comment was marked as outdated.

@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.58333% with 68 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.81%. Comparing base (70c7a72) to head (784c8c4).
⚠️ Report is 530 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/mysqlctl/mysqld.go 30.55% 25 Missing ⚠️
go/vt/mysqlctl/cmd.go 0.00% 10 Missing ⚠️
go/vt/mysqlctl/s3backupstorage/s3.go 89.23% 7 Missing ⚠️
go/vt/binlog/binlog_connection.go 58.33% 5 Missing ⚠️
go/vt/mysqlctl/replication.go 20.00% 4 Missing ⚠️
go/vt/vtadmin/api.go 86.36% 3 Missing ⚠️
go/vt/vtadmin/cluster/dynamic/api.go 0.00% 3 Missing ⚠️
go/cmd/vtcombo/cli/main.go 0.00% 2 Missing ⚠️
go/vt/vtadmin/cluster/dynamic/interceptors.go 0.00% 2 Missing ⚠️
go/vt/vtctl/vtctl.go 33.33% 2 Missing ⚠️
... and 5 more

❗ There is a different number of reports uploaded between BASE (70c7a72) and HEAD (784c8c4). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (70c7a72) HEAD (784c8c4)
1 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #20863       +/-   ##
===========================================
- Coverage   69.67%   61.81%    -7.86%     
===========================================
  Files        1614      268     -1346     
  Lines      216793    40559   -176234     
===========================================
- Hits       151044    25073   -125971     
+ Misses      65749    15486    -50263     
Flag Coverage Δ
partial 61.81% <64.58%> (?)

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@timvaillancourt
timvaillancourt requested a balanced review from Copilot August 18, 2026 23:00

This comment was marked as resolved.

Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Copilot AI review requested due to automatic review settings August 19, 2026 01:32

This comment was marked as outdated.

@timvaillancourt
timvaillancourt marked this pull request as ready for review August 27, 2026 09:54

@devin-ai-integration devin-ai-integration Bot 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.

Note

This report is out of date. Scroll down for Devin Review's latest report on this PR.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Copilot AI review requested due to automatic review settings September 1, 2026 23:45
devin-ai-integration[bot]

This comment was marked as resolved.

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.

🔵 Needs a closer look

The changes span several concurrency-sensitive and operational context lifecycles requiring final human validation.

Review details
  • Files reviewed: 31/31 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Copilot AI review requested due to automatic review settings September 2, 2026 00:08

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.

🔵 Needs a closer look

It changes cancellation and synchronization behavior across several operationally sensitive subsystems.

Review details
  • Files reviewed: 31/31 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Copilot AI review requested due to automatic review settings September 3, 2026 22:38

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 3 new potential issues.

Devin Review

Comment thread go/vt/mysqlctl/mysqld.go
Comment thread go/vt/binlog/binlog_streamer.go
Comment thread changelog/25.0/25.0.0/summary.md

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.

🟡 Changes recommended

Cancellation during restore can leave MySQL running in its temporary skip-grants state.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 37/37 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread go/vt/mysqlctl/backup.go

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 784c8c4e98

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread changelog/25.0/25.0.0/summary.md
Comment thread go/vt/vtadmin/cluster/cluster_internal_test.go
Comment thread go/vt/mysqlctl/mysqld.go
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.

2 participants