rustfs icon indicating copy to clipboard operation
rustfs copied to clipboard

Immediate-expiry check reads the bucket incarnation even without lifecycle rules

Open AdrianPerez3 opened this issue 2 weeks ago • 0 comments

Request scope

  • [x] This is a feature request and does not ask for troubleshooting an unsupported remote or shared filesystem deployment.

Problem or use case

After every successful PUT, CopyObject and CompleteMultipartUpload, enqueue_transition_after_write (crates/ecstore/src/store/mod.rs) awaits enqueue_immediate_expiry before the response. That calls metadata_boundary::get_expiry_configs_for_options, which first takes the bucket metadata-transaction read lock and reads the bucket incarnation through an internal object read of .rustfs.sys/buckets/<bucket>/.bucket-incarnation, and only then looks at the cached bucket metadata. For a bucket without a lifecycle configuration it returns lifecycle: None and nothing is enqueued.

The lifecycle rules that decide the outcome come from that cached metadata_map entry; the incarnation read only validates that the entry belongs to the current bucket. When the cached entry has no lifecycle document, every branch enqueues nothing: a matching incarnation returns no lifecycle, and a mismatch or read failure returns an error that is logged and ignored. The lock round and the read are therefore pure overhead for buckets without lifecycle rules.

Syscall traces of earlier builds (1.0.0 through 1.0.5 and two main commits, in a Linux arm64 container, buckets without lifecycle rules) show the post-commit .bucket-incarnation/xl.meta open, fstat, read and close exactly once on each of 1,512 traced successful PUTs, in every durability mode and object shape, always before the response. Where the response write was also traced (792 PUTs), the read took 0.28 ms median under strace; strace inflates such work, so this shows that the read is on the request path, not its untraced cost.

Proposed solution

In enqueue_immediate_expiry, return before the lock and the incarnation read when the cached bucket metadata has neither a parsed lifecycle configuration nor lifecycle XML and needs no bucket-creation commit. Buckets with lifecycle rules, unreadable lifecycle documents, a pending creation commit or no cached entry keep the authoritative path, including the creation-commit migration and the metadata_unavailable report for unreadable documents. get_expiry_configs* and its other callers stay unchanged.

Alternatives considered

  • Checking the cache first inside get_expiry_configs_for_options: its other callers use the validated incarnation, so the change is kept in the write-triggered hook.
  • Leaving all write-triggered expiry to the scanner, as lockless cache buckets already do: that would drop immediate expiry for buckets that do have rules.

Additional context

On the node handling a write, a PutBucketLifecycle that still holds the transaction lock would no longer be waited for, so an object written concurrently with a bucket's first rule is left to the scanner, like any object written before the rule; queued expiries are still rechecked under the lock before deletion (#8637). Related precedent: #9034 removed redundant incarnation reads on copy and metadata paths. No end-to-end latency change has been measured; a PR follows.

AdrianPerez3 avatar Nov 13 '26 12:11 AdrianPerez3