Repository navigation
fix(ragfs): propagate S3 delete failures instead of reporting success - #3407
ZaynJarvis wants to merge 1 commit into
Conversation
Sweep findings: E-05. Preserve exact and per-object S3 deletion failures.
ZaynJarvis
left a comment
There was a problem hiding this comment.
Reviewed as an independent maintainer pass (structure, design, compatibility, correctness).
Before/after: previously remove_all discarded the exact-key DeleteObject result (let _ =), and delete_objects treated a 200 DeleteObjects response containing per-object errors as success — so a recursive delete could report success (and invalidate caches) while objects remained in the bucket. After this PR, the exact-key delete propagates via ?, and any per-object error in a batch response becomes an Error::internal listing each failed key/code/message, returned before cache invalidation.
Verified independently: DeleteObjectsOutput::errors() in aws-sdk-s3 1.119.0 returns &[types::Error] so the helper wiring typechecks; Error::internal exists; S3Client::delete_objects has no other callers besides delete_directory, and the disable_batch_delete sequential path already propagated errors, so the two paths are now consistent. CI is green.
No blocking issues. Two non-blocking inline comments below, plus one out-of-diff note: rename still swallows a delete failure of the old directory marker (let _ = self.client.delete_object(&old_dir_key).await;, mod.rs:769). It looks intentional (best-effort cleanup after data has already been copied, and largely redundant since delete_directory's batch already covers the marker key), but it is the same failure-swallowing family as E-05 — may be worth a follow-up sweep entry rather than expanding this minimal fix.
| .map_err(|e| { | ||
| format_sdk_s3_error("DeleteObjects", &format!("bucket={}", self.bucket), &e) | ||
| })?; | ||
| if let Some(error) = partial_delete_error(&self.bucket, response.errors()) { |
There was a problem hiding this comment.
[Suggestion] (non-blocking) Returning here changes the cache-consistency story for the partial failure case. Keys that were successfully deleted in this chunk (and in earlier chunks of the same delete_directory call) are already gone from S3, but because the error propagates up, S3FileSystem::remove_all now skips dir_cache/stat_cache invalidation entirely — so listings and stats keep serving entries for objects that no longer exist until the cache TTL expires or a retry succeeds.
Example: remove_all("/tree") over 1500 objects, one key in the first chunk fails with AccessDenied → the other 999 keys in that chunk are deleted, the second chunk is never attempted, the caller gets an error, and cached listings still show all 1500 entries. Before this PR the same scenario (wrongly) reported success but did invalidate the caches, so reads converged immediately.
This is inherent to failing before invalidation and matches other error paths in this file, so it may well be the intended trade-off — if so, please confirm that relying on TTL expiry / caller retry for the partially-deleted keys is acceptable.
| // Delete the file itself (if it exists as a file) | ||
| let key = self.client.build_key(&normalized); | ||
| let _ = self.client.delete_object(&key).await; | ||
| self.client.delete_object(&key).await?; |
There was a problem hiding this comment.
[Suggestion] (non-blocking) The original let _ = presumably tolerated the common case where path is a directory and no exact-key object exists. Propagating with ? is safe on AWS-semantics services because DeleteObject on a nonexistent key returns 204 — and all providers documented in this plugin (AWS S3, MinIO, LocalStack, TOS, OSS) follow that. But any S3-compatible endpoint that returns an error (e.g. 404/NoSuchKey) for deleting a missing key would now make remove_all fail on every directory-only path, where it previously succeeded. If supported-provider semantics are the deliberate contract here, this is fine as-is — just confirming that no supported backend deviates.
* fix(ragfs): preserve cache visibility on partial S3 deletes Surface exact and per-object S3 deletion failures, while always invalidating the affected directory and stat cache scope after a recursive delete attempt. Source-PR: #3407 Original-Commit: 8d6addf * fix(session): preserve legacy policy and peer identity compatibility Parse string false and other legacy boolean-like memory policy values without silently enabling extraction or breaking persisted configs. Encode mixed-script peers losslessly, while retaining their former lossy IDs as read-only retrieval and extraction aliases. Source-PR: #3422 Original-Commit: 0dfd5a9 * fix(memory): drain timer flush tasks during shutdown Retain the shielded timer flush task and await it when close cancels the timer loop, so batch failures are observed and submitters are resolved without unhandled task exceptions. Source-PR: #3438 Original-Commit: ca1d74e * fix(storage): preserve peer isolation and cache correctness * fix(ingest): reserve encoded peer namespace * ci: skip embedding-dependent resource test without secrets * fix(ragfs): invalidate caches after partial remove --------- Co-authored-by: zhiheng.liu <zhiheng.liu@bytedance.com>
|
感谢这个 PR — 两处改动已随 #3553 合入 main,commit 逐条核过:
另外合入版在本 PR 基础上多做了一件事,正好补上这个改动带来的副作用: 没有未吸收的部分,这个 PR 关掉。有遗漏欢迎重开。 |
* fix(ragfs): preserve cache visibility on partial S3 deletes Surface exact and per-object S3 deletion failures, while always invalidating the affected directory and stat cache scope after a recursive delete attempt. Source-PR: volcengine#3407 Original-Commit: 8d6addf * fix(session): preserve legacy policy and peer identity compatibility Parse string false and other legacy boolean-like memory policy values without silently enabling extraction or breaking persisted configs. Encode mixed-script peers losslessly, while retaining their former lossy IDs as read-only retrieval and extraction aliases. Source-PR: volcengine#3422 Original-Commit: 0dfd5a9 * fix(memory): drain timer flush tasks during shutdown Retain the shielded timer flush task and await it when close cancels the timer loop, so batch failures are observed and submitters are resolved without unhandled task exceptions. Source-PR: volcengine#3438 Original-Commit: ca1d74e * fix(storage): preserve peer isolation and cache correctness * fix(ingest): reserve encoded peer namespace * ci: skip embedding-dependent resource test without secrets * fix(ragfs): invalidate caches after partial remove --------- Co-authored-by: zhiheng.liu <zhiheng.liu@bytedance.com>
概述
S3 后端的删除操作在两处把失败当成成功:
remove_all丢弃精确 key 删除的结果(let _ =),delete_objects批量删除只检查了传输层错误,忽略了 S3DeleteObjects返回 HTTP 200 但响应体内携带逐 key 错误(AccessDenied/InternalError等)的情况——这是 S3 批量删除 API 的固有语义,不是异常路径。结果是对象仍在桶里,调用方却拿到Ok,随后 dir/stat 缓存被失效,上层(redis/mooncake 缓存包装、multibackend 同步)全部按"已删除"处理。本 PR 让两处失败如实传播:批量删除逐 chunk 检查
response.errors(),失败时返回带 key/code/message 明细的错误;精确 key 删除改为?传播。两处都发生在缓存失效之前,失败时缓存保持原状。为什么必要(可达性/严重性)
第一道防线,非 defense-in-depth:
remove_all从 ragfs-python 绑定(crates/ragfs-python/src/lib.rs:1297)直通 s3fs 插件,上游没有任何环节校验对象是否真的删掉。触发条件是 S3 侧的部分失败(逐 key 权限拒绝、服务端内部错误)或精确 key 删除时的网络/鉴权失败——仅 S3/S3 兼容后端受影响,本地后端无此路径。诚实定级 P1:是真实可达的数据一致性问题(用户以为删了、数据还在,涉及删除类合规场景),但只在 S3 出错时显现,属于错误上报失真而非主动损坏数据。关键设计与取舍
Result<()>签名去返回"已删除的 key 列表":当前没有消费方需要部分成功账目,改签名是为不存在的需求加复杂度。?传播不会破坏"路径仅为目录"的场景:S3DeleteObject对不存在的 key 返回 204 成功(MinIO/OSS 同),因此能传播出来的都是真实故障。作用域与已知限制
disable_batch_delete(OSS 兼容)顺序删除路径本就逐个传播错误,未改动。mod.rs:769rename 路径仍有一处let _ = delete_object(&old_dir_key):那是改名后清理旧目录 marker,失败只留下冗余 marker,不产生"假删除",不属于 E-05,故不动。Error::internal字符串,未引入结构化错误类型;上层目前只消费错误文本,够用。remove_all失败——这正是预期行为变化;唯一理论边界是"桶策略对精确 key 拒绝 DeleteObject 但允许其子对象"的畸形配置,此时报错也是正确的。修复的问题
crates/ragfs/src/plugins/s3fs/mod.rs:543、crates/ragfs/src/plugins/s3fs/client.rs:640)合入价值
P1 · 删除结果如实反馈:S3 部分删除失败不再伪装成功,不再错误失效缓存,残留对象可被重试正确处理。
验证
cargo test -p ragfs --features s3 test_partial_delete_error_reports_each_failed_key --lib— 通过(1 项)cargo check -p ragfs --features s3/cargo check -p ragfs— 通过(仅告警)自动化全仓清扫(2026-07)· draft 待 review