Skip to content

Fix CDC URI parsing for Cloud account usernames and special characters#25002

Merged
mergify[bot] merged 7 commits into
matrixorigin:mainfrom
jiangxinmeng1:fix-24833
Jul 1, 2026
Merged

Fix CDC URI parsing for Cloud account usernames and special characters#25002
mergify[bot] merged 7 commits into
matrixorigin:mainfrom
jiangxinmeng1:fix-24833

Conversation

@jiangxinmeng1

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #24833

What this PR does / why we need it:

What Changed

This PR fixes CDC connection handling for MatrixOne Cloud-style credentials, where the username may contain multiple colons such as account:user:role, and the password may contain special characters
such as @.

Changes include:

  • Parse CDC URIs using the last @ as the user-info/host separator.
  • Split user and password using the last : in user-info, preserving usernames like account:user:role.
  • Decode percent-encoded username/password values.
  • Build MySQL connections with mysql.Config and mysql.NewConnector instead of manually formatting a DSN string, avoiding DSN parsing issues with : in usernames.
  • Add tests for Cloud-style usernames, encoded credentials, passwords containing @, and connection config generation.

Testing

  • gofmt
  • git diff --check

go test ./pkg/cdc -run 'Test_(compUriInfo|makeMysqlConfig|openDbConn|tryConn)' -count=1 could not complete in my local environment because required CGO headers are missing:

  • usearch.h
  • xxhash.h

CGO_ENABLED=0 is also blocked by mpool requiring CGO-backed allocator symbols.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH 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.

Requesting changes because the updated test code does not compile as written.

openDbWithConnector is now assigned from sql.OpenDB, so its signature is func(driver.Connector) *sql.DB.
But in Test_tryConn, the new gostub callback still returns db, nil instead of just db.

So the test stub has the wrong arity and the file will fail to compile. I think the stub body just needs to return db.

@CLAassistant

CLAassistant commented Jun 29, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@XuPeng-SH XuPeng-SH 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.

LGTM. The current head fixes the previous blockers I requested changes for:

  • Connection creation now stays on github.com/matrixorigin/mysql.NewConnector, matching the executor's mysql.ReuseQueryBuf named-argument path.
  • The tryConn/openDbWithConnector test stub now matches sql.OpenDB's actual signature.
  • URI parsing now uses the terminal @ as the host separator and the terminal : inside user-info as the user/password separator, with percent-decoding for both username and password. That covers MatrixOne Cloud-style account:user:role credentials and passwords containing @.
  • The new fake MySQL-server regression exercises ExecSQL after tryConn and verifies that a COM_QUERY is emitted, so the connector + ReuseQueryBuf execution path is covered instead of only testing config construction.

Local verification on the current head:

CGO-enabled go test ./pkg/cdc -run 'Test_(compUriInfo|makeMysqlConfig|openDbConn|openDbConnFailed|tryConn)|TestExecutor_ExecSQLAfterTryConnUsesReuseQueryBuf' -count=1

One remaining non-code blocker is external to this change: CLA assistant is still pending, and the branch is currently behind main.

@mergify mergify Bot added the queued label Jul 1, 2026
@mergify

mergify Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-07-01 10:54 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • Checks passed · in-place
  • Merged2026-07-01 14:42 UTC · at db568ff08ca1897bbc2bc64392d39470ed83551f · squash

This pull request spent 3 hours 47 minutes 53 seconds in the queue, including 1 hour 10 minutes 12 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64

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

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants