Skip to content

fix(fileservice): honor context while waiting for object storage slots - #26532

Merged
mergify[bot] merged 6 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-26273-context-aware-semaphore
Aug 1, 2026
Merged

mergify[bot] merged 6 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-26273-context-aware-semaphore

Conversation

@LeftHandCold

@LeftHandCold LeftHandCold commented Jul 31, 2026 •

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:

Fixes #26273

What this PR does / why we need it:

objectStorageSemaphore limited concurrency with a blocking channel send. Although every object-storage operation receives a caller context, Exists, List, Read, Stat, Write, and WriteMultipartParallel waited for a semaphore slot through the unconditional acquire path. Once all slots were occupied, cancellation could not terminate that local wait, so an already-canceled operation remained blocked until another storage operation released a slot and could then reach the upstream storage.

This change:

  • uses the existing context-aware acquisition path for every context-bearing object-storage operation;
  • returns the caller context error without invoking upstream storage when cancellation wins while queued;
  • propagates acquisition failure through the lazy List iterator;
  • preserves the existing release ownership after successful acquisition, including Read holding its slot until EOF, read error, or Close;
  • removes the now-unused unconditional acquisition helper.

The regression test occupies the only slot, cancels the caller context, and verifies all six previously affected operations return context.Canceled without acquiring the semaphore. The same test fails deterministically on the pre-fix main implementation because each operation remains blocked until the test releases the slot.

Validation:

  • .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100 -timeout=120s -run '^TestObjectStorageSemaphoreOperationsObserveContextWhileWaiting$' ./pkg/fileservice
  • .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/fileservice
  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/fileservice
  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s -coverprofile=/tmp/issue26273.cover ./pkg/fileservice
  • go build -mod=readonly ./pkg/fileservice
  • go vet -mod=readonly ./pkg/fileservice

All newly added context-acquisition branches are covered by the regression test.

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

The change closes the cancellation contract consistently across every context-bearing object-storage operation that still used the unconditional semaphore path. Acquisition failure owns no slot; every successful acquisition retains exactly one release path, including Read's existing EOF/error/Close once-release contract and List's lazy iterator lifetime. Cancellation now terminates the local queue wait independently of the operation holding the slot. No unbounded resource, API/format compatibility, or material performance concern was found.

Validation on head 16b91d8: focused semaphore tests passed under -race -count=100, the full pkg/fileservice package passed under -race, and build/vet passed.

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

mergify Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-31 17:24 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ❌ Checks failed · in-place
  • 🚫 Left the queue — 2026-07-31 17:57 UTC · at f7038e9f03d1c9733b90000e2926205f9cf000be

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

Waiting for
  • any of: [🛡 GitHub branch protection]
    • 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)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • 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
All conditions
  • any of [🛡 GitHub branch protection]:
    • 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)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • 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
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86

Reason

The merge conditions cannot be satisfied due to failing checks

Failing checks:

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, 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.

Requeued — the merge queue status continues in this comment ↓.

@mergify

mergify Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-01 02:15 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-08-01 02:16 UTC · at 7a4c98ecaa6d01f35f0935a0da8d3650465f93da · squash

This pull request spent 27 seconds in the queue, including 3 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • 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 CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • 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)
  • 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 UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86

@mergify
mergify Bot merged commit 5ab0a23 into matrixorigin:main Aug 1, 2026
24 of 25 checks passed
@mergify mergify Bot removed the queued label Aug 1, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
matrixorigin#26532)

`objectStorageSemaphore` limited concurrency with a blocking channel send. Although every object-storage operation receives a caller context, `Exists`, `List`, `Read`, `Stat`, `Write`, and `WriteMultipartParallel` waited for a semaphore slot through the unconditional `acquire` path. Once all slots were occupied, cancellation could not terminate that local wait, so an already-canceled operation remained blocked until another storage operation released a slot and could then reach the upstream storage.

This change:

- uses the existing context-aware acquisition path for every context-bearing object-storage operation;
- returns the caller context error without invoking upstream storage when cancellation wins while queued;
- propagates acquisition failure through the lazy `List` iterator;
- preserves the existing release ownership after successful acquisition, including `Read` holding its slot until EOF, read error, or `Close`;
- removes the now-unused unconditional acquisition helper.

The regression test occupies the only slot, cancels the caller context, and verifies all six previously affected operations return `context.Canceled` without acquiring the semaphore. The same test fails deterministically on the pre-fix `main` implementation because each operation remains blocked until the test releases the slot.

Validation:

- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100 -timeout=120s -run '^TestObjectStorageSemaphoreOperationsObserveContextWhileWaiting$' ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s -coverprofile=/tmp/issue26273.cover ./pkg/fileservice`
- `go build -mod=readonly ./pkg/fileservice`
- `go vet -mod=readonly ./pkg/fileservice`

All newly added context-acquisition branches are covered by the regression test.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
matrixorigin#26532)

`objectStorageSemaphore` limited concurrency with a blocking channel send. Although every object-storage operation receives a caller context, `Exists`, `List`, `Read`, `Stat`, `Write`, and `WriteMultipartParallel` waited for a semaphore slot through the unconditional `acquire` path. Once all slots were occupied, cancellation could not terminate that local wait, so an already-canceled operation remained blocked until another storage operation released a slot and could then reach the upstream storage.

This change:

- uses the existing context-aware acquisition path for every context-bearing object-storage operation;
- returns the caller context error without invoking upstream storage when cancellation wins while queued;
- propagates acquisition failure through the lazy `List` iterator;
- preserves the existing release ownership after successful acquisition, including `Read` holding its slot until EOF, read error, or `Close`;
- removes the now-unused unconditional acquisition helper.

The regression test occupies the only slot, cancels the caller context, and verifies all six previously affected operations return `context.Canceled` without acquiring the semaphore. The same test fails deterministically on the pre-fix `main` implementation because each operation remains blocked until the test releases the slot.

Validation:

- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100 -timeout=120s -run '^TestObjectStorageSemaphoreOperationsObserveContextWhileWaiting$' ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s -coverprofile=/tmp/issue26273.cover ./pkg/fileservice`
- `go build -mod=readonly ./pkg/fileservice`
- `go vet -mod=readonly ./pkg/fileservice`

All newly added context-acquisition branches are covered by the regression test.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
matrixorigin#26532)

`objectStorageSemaphore` limited concurrency with a blocking channel send. Although every object-storage operation receives a caller context, `Exists`, `List`, `Read`, `Stat`, `Write`, and `WriteMultipartParallel` waited for a semaphore slot through the unconditional `acquire` path. Once all slots were occupied, cancellation could not terminate that local wait, so an already-canceled operation remained blocked until another storage operation released a slot and could then reach the upstream storage.

This change:

- uses the existing context-aware acquisition path for every context-bearing object-storage operation;
- returns the caller context error without invoking upstream storage when cancellation wins while queued;
- propagates acquisition failure through the lazy `List` iterator;
- preserves the existing release ownership after successful acquisition, including `Read` holding its slot until EOF, read error, or `Close`;
- removes the now-unused unconditional acquisition helper.

The regression test occupies the only slot, cancels the caller context, and verifies all six previously affected operations return `context.Canceled` without acquiring the semaphore. The same test fails deterministically on the pre-fix `main` implementation because each operation remains blocked until the test releases the slot.

Validation:

- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100 -timeout=120s -run '^TestObjectStorageSemaphoreOperationsObserveContextWhileWaiting$' ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s -coverprofile=/tmp/issue26273.cover ./pkg/fileservice`
- `go build -mod=readonly ./pkg/fileservice`
- `go vet -mod=readonly ./pkg/fileservice`

All newly added context-acquisition branches are covered by the regression test.

Approved by: @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.

[Bug] Object storage write waits after its context is canceled

3 participants