You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Object storage write waits after its context is canceled #26273
objectStorageSemaphore does not observe the caller context while waiting for a slot in Write.
CopyObject and Delete use acquireContext, but Write uses the unconditional acquire path. The same waiting pattern is also used by Exists, Read, Stat, and WriteMultipartParallel.
Reproduction
On main commit c8e443bf8610b2af4333ad943ba2075485b16cf8:
Create an objectStorageSemaphore with capacity 1 and occupy its only slot.
Create and cancel a context.
Call Write with that canceled context.
The call remains waiting for the semaphore slot instead of returning context.Canceled. The isolated test repeated this result 3/3 times with a 100 ms upper bound per run.
Expected behavior
Once the caller context has ended, a queued file operation should return that context result without waiting for another operation to release the slot, and it should not call the upstream storage.
Actual behavior
The queued Write call remains blocked until the slot is released. Therefore an operation that has already been canceled can still wait behind a long-running storage operation.
Suggested direction
Use the context-aware acquisition path consistently for operations that accept a context, while retaining the existing release behavior after a slot is acquired.
Activity
LeftHandCold commentedon Aug 3, 2026
fixed
Ariznawlll commentedon Aug 7, 2026
测试版本
mainab49099c0f487255df131f45c3aecf4a4650fed7go test -race -count=3 ./pkg/fileservice原问题验证
验证 object-storage semaphore 被占用时,等待写入的 context cancellation 会立即生效,不再继续无意义等待。
Happy Path 覆盖
CopyObject正常执行正确。Unhappy Path 覆盖
白盒验证
执行
TestObjectStorageSemaphoreCopyObject、TestObjectStorageSemaphoreDeleteObservesContextWhileWaiting、TestObjectStorageSemaphoreOperationsObserveContextWhileWaiting、TestObjectStorageSemaphoreSerializes,使用-race -count=3。回归测试
已运行
pkg/fileservice既有 UT;未新增代码或回归文件。测试证据
-race未报告数据竞争。测试结论
测试通过。