Skip to content

fix(fileservice): scope DNS cache to file service clients - #27548

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-27362-dns-resolver-scope
Aug 24, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-27362-dns-resolver-scope

Conversation

@LeftHandCold

Copy link
Copy Markdown
Collaborator

What type of PR is this?

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

Which issue(s) this PR fixes:

issue #27362

What this PR does / why we need it:

FileService installs a caching DNS resolver for object storage and HDFS clients. Its package initializer also assigned that resolver to net.DefaultResolver, which unintentionally made the FileService cache process-wide.

This affects unrelated clients such as MORPC/goetty. When a service keeps the same DNS name but moves to a new IP, a replacement MORPC backend performs a new dial but can still receive the old address from the FileService resolver until the DNS record TTL expires. In the Docker reproduction, the embedded DNS TTL was 600 seconds, so CN, TN, and Proxy continued dialing the unreachable LogService IP after the endpoint and system DNS had recovered.

The MORPC backend replacement path itself remains valid and is not changed by this PR. This change only removes the process-wide resolver assignment. FileService's httpDialer continues to use the same caching resolver explicitly, so S3 SDKs, HDFS, and the FileService HTTP transport keep their existing DNS caching behavior.

The regression test verifies both ownership boundaries:

  • FileService does not replace net.DefaultResolver.
  • FileService's own dialer still uses its caching resolver.

There are no configuration, wire-format, retry-policy, or persistent-state changes. Normal active connections are unaffected; the behavioral difference is limited to future non-FileService dials, which now use Go's standard resolver and can observe endpoint IP changes.

Tested with:

TestDNSResolverScope fails on the unmodified main baseline and passes with this change.

./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/fileservice

GOWORK=off go build -mod=readonly ./pkg/fileservice

GOWORK=off go vet -mod=readonly ./pkg/fileservice

go build ./cmd/mo-service

make static-check

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

Deep review of exact head 2b559ae3484a0c215dbb0f00a457fd4b4233d068.

[P1] The resolver is still process-wide for every default HTTP client. Removing net.DefaultResolver = dnsResolver fixes MORPC/goetty, but the same init() still assigns http.DefaultTransport = httpRoundTripper. That round tripper owns httpTransport, whose DialContext uses httpDialer and therefore the same caching dnsResolver. Consequently any unrelated http.DefaultClient, http.Get, or &http.Client{} still inherits the FileService DNS TTL. Concrete in-tree consumers include Iceberg REST/signed HTTP, Grafana, and mo-debug; the ESQL and sidecar code already contain explicit workarounds for this FileService global override.

This is broader than stale DNS: the FileService transport also installs its 20-second response-header timeout, connection caps, and TLSClientConfig{InsecureSkipVerify: true} process-wide. Thus the PR's stated ownership boundary (“FileService's own dialer keeps caching; future non-FileService dials use the standard resolver”) is not true for HTTP clients, and the analogous endpoint-move failure remains.

A counterexample ownership test that asserts http.DefaultTransport != httpRoundTripper fails deterministically on this head. Please remove the remaining http.DefaultTransport assignment as well and extend TestDNSResolverScope to cover both process globals. FileService backends retain their behavior: S3/Aliyun/MinIO/QCloud explicitly use newHTTPClient, and HDFS explicitly uses httpDialer.

Validation: full pkg/fileservice tests pass; focused -race -count=20 passes; vet passes. The counterexample fails only on the incomplete ownership boundary above.

@LeftHandCold

Copy link
Copy Markdown
Collaborator Author

@XuPeng-SH Addressed the requested ownership-boundary change in e42687c1c1:

  • removed the remaining http.DefaultTransport = httpRoundTripper process-wide override;
  • extended TestDNSResolverScope to assert both Go process globals remain untouched and that FileService-created clients still use httpRoundTripper/dnsResolver;
  • updated the two now-stale comments for ESQL and sidecar dedicated transports.

Audited FileService consumers: AWS v2, Aliyun, MinIO, and QCloud explicitly use newHTTPClient; HDFS explicitly uses httpDialer.

Validation passed:

  • go build and go vet for ./pkg/fileservice ./pkg/frontend ./pkg/sql/foreigntvf
  • full go test -count=1 ./pkg/fileservice
  • go test -race -count=20 -run '^TestDNSResolverScope$' ./pkg/fileservice
  • focused ESQL and sidecar HTTP lifecycle tests

Please re-review when convenient.

@matrix-meow matrix-meow added size/S Denotes a PR that changes [10,99] lines and removed size/XS Denotes a PR that changes [1, 9] lines labels Aug 24, 2026
@LeftHandCold
LeftHandCold requested a review from XuPeng-SH August 24, 2026 11:22
@matrix-meow matrix-meow added size/M Denotes a PR that changes [100,499] lines and removed size/S Denotes a PR that changes [10,99] lines labels Aug 24, 2026
@LeftHandCold
LeftHandCold requested a review from XuPeng-SH August 24, 2026 14:51

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

Deep re-review of exact head ae345ef.\n\nThe previous P1 is closed. AWS region discovery now uses an explicitly owned FileService client and request context. The 20-second deadline bounds dial, TLS, and response-header waits; cancellation reaches http.Transport; and every successful response closes its body. The process-wide net.DefaultResolver and http.DefaultTransport remain untouched, while FileService object-storage and HDFS paths retain the intended caching resolver.\n\nI traced the validate -> region probe -> client/transport chain and found no remaining correctness, lifecycle, compatibility, or material performance blocker. The new client allocation is construction-time only and shares the existing bounded transport.\n\nValidation:\n- affected package list/build/vet: pass\n- full pkg/fileservice: pass\n- focused region/DNS tests under race count 20: pass\n- related ESQL and sidecar HTTP lifecycle tests: pass\n- git diff check: pass

@mergify mergify Bot added the queued label Aug 24, 2026
@mergify

mergify Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-24 15:55 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-08-24 16:16 UTC · at 45f3ee3c05876206ef282d183411c4e52562ba2e

This pull request spent 20 minutes 49 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

Pull request #27548 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Failing checks:

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit 1909f79 into matrixorigin:main Aug 24, 2026
24 of 26 checks passed
@mergify mergify Bot added dequeued and removed queued labels Aug 24, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…in#27548)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#27362

## What this PR does / why we need it:

FileService installs a caching DNS resolver for object storage and HDFS
clients. Its package initializer also assigned that resolver to
`net.DefaultResolver`, which unintentionally made the FileService cache
process-wide.

This affects unrelated clients such as MORPC/goetty. When a service
keeps the same DNS name but moves to a new IP, a replacement MORPC
backend performs a new dial but can still receive the old address from
the FileService resolver until the DNS record TTL expires. In the Docker
reproduction, the embedded DNS TTL was 600 seconds, so CN, TN, and Proxy
continued dialing the unreachable LogService IP after the endpoint and
system DNS had recovered.

The MORPC backend replacement path itself remains valid and is not
changed by this PR. This change only removes the process-wide resolver
assignment. FileService's `httpDialer` continues to use the same caching
resolver explicitly, so S3 SDKs, HDFS, and the FileService HTTP
transport keep their existing DNS caching behavior.

The regression test verifies both ownership boundaries:

- FileService does not replace `net.DefaultResolver`.
- FileService's own dialer still uses its caching resolver.

There are no configuration, wire-format, retry-policy, or
persistent-state changes. Normal active connections are unaffected; the
behavioral difference is limited to future non-FileService dials, which
now use Go's standard resolver and can observe endpoint IP changes.

Tested with:

`TestDNSResolverScope` fails on the unmodified `main` baseline and
passes with this change.

`./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s
./pkg/fileservice`

`GOWORK=off go build -mod=readonly ./pkg/fileservice`

`GOWORK=off go vet -mod=readonly ./pkg/fileservice`

`go build ./cmd/mo-service`

`make static-check`

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…in#27548)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#27362

## What this PR does / why we need it:

FileService installs a caching DNS resolver for object storage and HDFS
clients. Its package initializer also assigned that resolver to
`net.DefaultResolver`, which unintentionally made the FileService cache
process-wide.

This affects unrelated clients such as MORPC/goetty. When a service
keeps the same DNS name but moves to a new IP, a replacement MORPC
backend performs a new dial but can still receive the old address from
the FileService resolver until the DNS record TTL expires. In the Docker
reproduction, the embedded DNS TTL was 600 seconds, so CN, TN, and Proxy
continued dialing the unreachable LogService IP after the endpoint and
system DNS had recovered.

The MORPC backend replacement path itself remains valid and is not
changed by this PR. This change only removes the process-wide resolver
assignment. FileService's `httpDialer` continues to use the same caching
resolver explicitly, so S3 SDKs, HDFS, and the FileService HTTP
transport keep their existing DNS caching behavior.

The regression test verifies both ownership boundaries:

- FileService does not replace `net.DefaultResolver`.
- FileService's own dialer still uses its caching resolver.

There are no configuration, wire-format, retry-policy, or
persistent-state changes. Normal active connections are unaffected; the
behavioral difference is limited to future non-FileService dials, which
now use Go's standard resolver and can observe endpoint IP changes.

Tested with:

`TestDNSResolverScope` fails on the unmodified `main` baseline and
passes with this change.

`./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s
./pkg/fileservice`

`GOWORK=off go build -mod=readonly ./pkg/fileservice`

`GOWORK=off go vet -mod=readonly ./pkg/fileservice`

`go build ./cmd/mo-service`

`make static-check`

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…in#27548)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#27362

## What this PR does / why we need it:

FileService installs a caching DNS resolver for object storage and HDFS
clients. Its package initializer also assigned that resolver to
`net.DefaultResolver`, which unintentionally made the FileService cache
process-wide.

This affects unrelated clients such as MORPC/goetty. When a service
keeps the same DNS name but moves to a new IP, a replacement MORPC
backend performs a new dial but can still receive the old address from
the FileService resolver until the DNS record TTL expires. In the Docker
reproduction, the embedded DNS TTL was 600 seconds, so CN, TN, and Proxy
continued dialing the unreachable LogService IP after the endpoint and
system DNS had recovered.

The MORPC backend replacement path itself remains valid and is not
changed by this PR. This change only removes the process-wide resolver
assignment. FileService's `httpDialer` continues to use the same caching
resolver explicitly, so S3 SDKs, HDFS, and the FileService HTTP
transport keep their existing DNS caching behavior.

The regression test verifies both ownership boundaries:

- FileService does not replace `net.DefaultResolver`.
- FileService's own dialer still uses its caching resolver.

There are no configuration, wire-format, retry-policy, or
persistent-state changes. Normal active connections are unaffected; the
behavioral difference is limited to future non-FileService dials, which
now use Go's standard resolver and can observe endpoint IP changes.

Tested with:

`TestDNSResolverScope` fails on the unmodified `main` baseline and
passes with this change.

`./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s
./pkg/fileservice`

`GOWORK=off go build -mod=readonly ./pkg/fileservice`

`GOWORK=off go vet -mod=readonly ./pkg/fileservice`

`go build ./cmd/mo-service`

`make static-check`

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
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 kind/test-ci 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