Skip to content

fix(fileservice): validate remote cache payloads - #25969

Merged
mergify[bot] merged 2 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-25885-remote-cache-validation
Jul 21, 2026
Merged

mergify[bot] merged 2 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-25885-remote-cache-validation

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 #25885

What this PR does / why we need it:

The remote-cache RPC boundary trusted request shape and response indexes.
Schema-valid requests with an empty key list or an omitted nested CacheKey
could panic the serving CN. A malformed or inconsistent response could use a
negative/out-of-range index, an index requested from a different target, or an
incorrect data length to panic the requester or mark invalid bytes as a hit.

Validate every request entry before allocating the I/O vector, require all
keys in one request to name the same file, and return bad request without
installing a response release callback on invalid input. If ReadCache
partially acquires cache data and then fails, release it immediately.

On the client, accept only indexes sent to that target, reject out-of-bounds
and wrong-length hits, and let the normal local-storage path handle every
invalid response. An invalid hit does not consume its index, while the first
fully valid response wins. The MORPC response is released on all received
response paths.

Normal same-version senders already generate valid shapes; nil repeated
message pointers are only possible for direct in-process callers. The network-
relevant cases are empty/missing nested request fields and invalid scalar
response indexes/lengths.

Validation:

  • focused fileservice regressions: PASS
  • focused fileservice regressions with -race -count=10: PASS
  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/fileservice
  • .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=240s ./pkg/fileservice
  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s ./pkg/cnservice
  • go build ./pkg/fileservice ./pkg/cnservice (repository CGo environment)
  • go vet ./pkg/fileservice ./pkg/cnservice (repository CGo environment)

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

@mergify mergify Bot added the kind/bug Something isn't working label Jul 21, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Jul 21, 2026

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

Codex automated review

No findings. The change validates malformed request/response shapes before dereference or indexing, preserves fallback-to-local behavior for invalid remote hits, and releases partially acquired cache data on server-side read errors. Existing PR reviews, issue comments, and inline threads contained no actionable feedback; CI is green. Local CGo test execution was unavailable because the worktree lacks cgo/libmo.dylib.

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

Reviewed the full diff at exact head cb8c4cd95ffc as an internal CN-to-CN network RPC reliability change. No actionable findings.

The server rejects empty/missing/mixed-path cache keys before dereference, transfers successful cache-data ownership to the MORPC response release callback, and releases partial cache acquisitions immediately on ReadCache error. The client validates response entries against the target-specific requested index set, bounds, duplicate ordering, and expected data length; invalid hits remain unfinished and flow through the existing LocalFS/S3FS fallback. Non-nil responses and server-side cache data each retain one effective release owner.

Local verification passed: focused regressions (-count=10), focused race (-count=3), full pkg/fileservice tests and race, pkg/cnservice handler tests and race, go build, go vet, and git diff --check. Current PR CI is green and the head merges cleanly with current origin/main.

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

mergify Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-21 16:24 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-07-21 19:11 UTC · at ac192b007f00b4c762aeea2c3374c3bed324e57a · squash

This pull request spent 2 hours 46 minutes 41 seconds in the queue, including 1 hour 5 minutes 25 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection] (documentation)
  • github-review-decision = APPROVED [🛡 GitHub branch protection] (documentation)
  • 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 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

@mergify
mergify Bot merged commit 0505e2a into matrixorigin:main Jul 21, 2026
24 of 25 checks passed
@mergify mergify Bot removed the queued label Jul 21, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
The remote-cache RPC boundary trusted request shape and response indexes.
Schema-valid requests with an empty key list or an omitted nested `CacheKey`
could panic the serving CN. A malformed or inconsistent response could use a
negative/out-of-range index, an index requested from a different target, or an
incorrect data length to panic the requester or mark invalid bytes as a hit.

Validate every request entry before allocating the I/O vector, require all
keys in one request to name the same file, and return `bad request` without
installing a response release callback on invalid input. If `ReadCache`
partially acquires cache data and then fails, release it immediately.

On the client, accept only indexes sent to that target, reject out-of-bounds
and wrong-length hits, and let the normal local-storage path handle every
invalid response. An invalid hit does not consume its index, while the first
fully valid response wins. The MORPC response is released on all received
response paths.

Normal same-version senders already generate valid shapes; nil repeated
message pointers are only possible for direct in-process callers. The network-
relevant cases are empty/missing nested request fields and invalid scalar
response indexes/lengths.

Validation:

- focused fileservice regressions: PASS
- focused fileservice regressions with `-race -count=10`: PASS
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=240s ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s ./pkg/cnservice`
- `go build ./pkg/fileservice ./pkg/cnservice` (repository CGo environment)
- `go vet ./pkg/fileservice ./pkg/cnservice` (repository CGo environment)

Approved by: @gouhongshen, @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
The remote-cache RPC boundary trusted request shape and response indexes.
Schema-valid requests with an empty key list or an omitted nested `CacheKey`
could panic the serving CN. A malformed or inconsistent response could use a
negative/out-of-range index, an index requested from a different target, or an
incorrect data length to panic the requester or mark invalid bytes as a hit.

Validate every request entry before allocating the I/O vector, require all
keys in one request to name the same file, and return `bad request` without
installing a response release callback on invalid input. If `ReadCache`
partially acquires cache data and then fails, release it immediately.

On the client, accept only indexes sent to that target, reject out-of-bounds
and wrong-length hits, and let the normal local-storage path handle every
invalid response. An invalid hit does not consume its index, while the first
fully valid response wins. The MORPC response is released on all received
response paths.

Normal same-version senders already generate valid shapes; nil repeated
message pointers are only possible for direct in-process callers. The network-
relevant cases are empty/missing nested request fields and invalid scalar
response indexes/lengths.

Validation:

- focused fileservice regressions: PASS
- focused fileservice regressions with `-race -count=10`: PASS
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=240s ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s ./pkg/cnservice`
- `go build ./pkg/fileservice ./pkg/cnservice` (repository CGo environment)
- `go vet ./pkg/fileservice ./pkg/cnservice` (repository CGo environment)

Approved by: @gouhongshen, @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
The remote-cache RPC boundary trusted request shape and response indexes.
Schema-valid requests with an empty key list or an omitted nested `CacheKey`
could panic the serving CN. A malformed or inconsistent response could use a
negative/out-of-range index, an index requested from a different target, or an
incorrect data length to panic the requester or mark invalid bytes as a hit.

Validate every request entry before allocating the I/O vector, require all
keys in one request to name the same file, and return `bad request` without
installing a response release callback on invalid input. If `ReadCache`
partially acquires cache data and then fails, release it immediately.

On the client, accept only indexes sent to that target, reject out-of-bounds
and wrong-length hits, and let the normal local-storage path handle every
invalid response. An invalid hit does not consume its index, while the first
fully valid response wins. The MORPC response is released on all received
response paths.

Normal same-version senders already generate valid shapes; nil repeated
message pointers are only possible for direct in-process callers. The network-
relevant cases are empty/missing nested request fields and invalid scalar
response indexes/lengths.

Validation:

- focused fileservice regressions: PASS
- focused fileservice regressions with `-race -count=10`: PASS
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=240s ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s ./pkg/cnservice`
- `go build ./pkg/fileservice ./pkg/cnservice` (repository CGo environment)
- `go vet ./pkg/fileservice ./pkg/cnservice` (repository CGo environment)

Approved by: @gouhongshen, @XuPeng-SH

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