Repository navigation
Description
An Expiration rule that expires the current version of a transitioned object deletes the object in the remote tier, then only puts a delete marker on top of the version. The version stays in the bucket as a noncurrent version. It is listed, with the tier's storage class, but GET ?versionId= returns 404 NoSuchKey, because its data is gone from the tier. Nothing restores it. A bucket that pairs Expiration with NoncurrentVersionExpiration to keep a window for recovering overwritten or expired data has no such window for transitioned objects.
No decommission, rebalance or failure is involved. The scanner does it on its own, and a GET, HEAD or listing of an expired object queues the same expiry.
Expected Behavior
In a versioned bucket, the expiry puts a delete marker on top of the current version, as it does for an object that is not transitioned, and as a DELETE without versionId does for a transitioned one. The former current version becomes noncurrent and stays readable. Its tier object is removed when the version itself is deleted later, by NoncurrentVersionExpiration or DELETE ?versionId=, through the free version.
With versioning suspended, the expiry puts a null delete marker on top. A current version with a non-null version ID stays readable as a noncurrent version. A null current version is replaced by the marker, and its tier object is removed.
Current Behavior
- Versioning enabled. The delete marker is added and the former current version is still listed (
WARM), butGET ?versionId=returns 404NoSuchKeyand its object is gone from the tier bucket. Older versions are not affected. - Versioning suspended, current version with a non-null version ID (written while versioning was enabled). The expiry deletes the tier object, then
DeleteObjectfails withVersionNotFound, whichapplyExpiryOnTransitionedObjectdrops without a log line. No delete marker is added. The version stays current and returns 404NoSuchKey. Every scanner cycle repeats theDELETEon the tier: 8 times in 2 minutes withMINIO_SCANNER_SPEED=fastest. - Versioning suspended,
nullcurrent version. The version and its tier object are removed, but without thenulldelete marker that the same rule leaves for an object that is not transitioned.
Possible Solution
expireTransitionedObject (cmd/bucket-lifecycle.go:610, main b91e1c6f2):
opts := ObjectOptions{
Versioned: globalBucketVersioningSys.PrefixEnabled(oi.Bucket, oi.Name),
Expiration: ExpirationOptions{Expire: true},
}
if lcEvent.Action.DeleteVersioned() {
opts.VersionID = oi.VersionID
}
...
// Delete remote object from warm-tier
err := deleteObjectFromRemoteTier(ctx, oi.TransitionedObject.Name, oi.TransitionedObject.VersionID, oi.TransitionedObject.Tier)
if err == nil {
// Skip adding free version since we successfully deleted the
// remote object
opts.SkipFreeVersion = true
} else {
transitionLogIf(ctx, err)
}
// Now, delete object from hot-tier namespace
if _, err := objectAPI.DeleteObject(ctx, oi.Bucket, oi.Name, opts); err != nil {
return err
}- The remote object is deleted unconditionally (
:634-642). ForDeleteAction, the expiry of the current version,opts.VersionIDis empty, so in a versioned bucketDeleteObjectonly adds a delete marker and the version survives. The userDELETEpath already has the right rule inobjSweeper.shouldRemoveRemoteObject(cmd/tier-sweeper.go:108-121): "If bucket versioning is enabled and version id is not specified, nothing to be done (a delete marker is added)". opts.VersionSuspendedis never set (:612-615), unlike inapplyExpiryOnNonTransitionedObjects(cmd/data-scanner.go:1235-1236). With versioning suspended,DeleteObjectgets neitherVersionednorVersionSuspendedand an empty version ID, so it deletes thenullversion, if there is one, and adds no marker. If the current version is thenullversion, it is removed without a marker. If the current version has a UUID and there is nonullversion, the call fails withVersionNotFound, andapplyExpiryOnTransitionedObject(cmd/data-scanner.go:1213) returns quietly.
A fix is to set VersionSuspended as for objects that are not transitioned, and to skip the remote delete when the expiry only adds a delete marker on top: the version ID is empty, and versioning is enabled, or suspended with a non-null current version. The tier object then goes through the free version when that version is deleted. I have a patch with a test and will open a PR.
Steps to Reproduce (for bugs)
Two SILO servers from main on one host: a hot server with 4 drives, and a single-drive server used as a minio tier. Needs mc, aws CLI v2, jq and curl with --aws-sigv4.
export MINIO_ROOT_USER=minioadmin MINIO_ROOT_PASSWORD=minioadmin MINIO_CI_CD=1
export AWS_ACCESS_KEY_ID=minioadmin AWS_SECRET_ACCESS_KEY=minioadmin AWS_DEFAULT_REGION=us-east-1
W=/tmp/tier-expiry; mkdir -p $W
silo server --address 127.0.0.1:9001 --console-address 127.0.0.1:9091 $W/warm >$W/warm.log 2>&1 &
MINIO_SCANNER_SPEED=fastest silo server --address 127.0.0.1:9000 --console-address 127.0.0.1:9090 \
"$W/hot/d{1...4}" >$W/hot.log 2>&1 &
until curl -sf http://127.0.0.1:9000/minio/health/cluster && curl -sf http://127.0.0.1:9001/minio/health/cluster; do sleep 0.5; done
mc alias set hot http://127.0.0.1:9000 minioadmin minioadmin
mc alias set warm http://127.0.0.1:9001 minioadmin minioadmin
mc mb warm/tier
mc admin tier add minio hot WARM --endpoint http://127.0.0.1:9001 \
--access-key minioadmin --secret-key minioadmin --bucket tier --prefix hot/
# 1. Transition every new version right away (Days=0).
cat >$W/transition.json <<'EOF'
{"Rules":[{"ID":"tier","Status":"Enabled","Filter":{"Prefix":""},
"Transitions":[{"Days":0,"StorageClass":"WARM"}]}]}
EOF
for b in versioned suspended; do
mc mb hot/$b && mc version enable hot/$b
aws --endpoint-url http://127.0.0.1:9000 s3api put-bucket-lifecycle-configuration \
--bucket $b --lifecycle-configuration file://$W/transition.json
done
for i in 1 2 3; do head -c 300000 /dev/urandom | mc pipe hot/versioned/obj; done
head -c 300000 /dev/urandom | mc pipe hot/suspended/obj # gets a non-null version ID
mc version suspend hot/suspended
sleep 5
mc ls --versions hot/versioned/obj hot/suspended/obj # every version is WARM
mc ls --recursive warm/tier | wc -l # 4 objects in the tier
# 2. Expire the current versions. A past Expiration.Date applies at once.
cat >$W/expire.json <<'EOF'
{"Rules":[{"ID":"tier","Status":"Enabled","Filter":{"Prefix":""},
"Transitions":[{"Days":0,"StorageClass":"WARM"}]},
{"ID":"expire","Status":"Enabled","Filter":{"Prefix":""},
"Expiration":{"Date":"2020-01-01T00:00:00Z"}}]}
EOF
for b in versioned suspended; do
aws --endpoint-url http://127.0.0.1:9000 s3api put-bucket-lifecycle-configuration \
--bucket $b --lifecycle-configuration file://$W/expire.json
done
sleep 60 # a few scanner cycles
# 3. Every version is still listed, but the tier lost the data of the expired ones.
mc ls --versions hot/versioned/obj hot/suspended/obj
mc ls --recursive warm/tier | wc -l
for b in versioned suspended; do
for v in $(mc ls --versions --json hot/$b/obj | jq -r 'select(.isDeleteMarker | not) | .versionId'); do
printf '%s ?versionId=%s -> ' $b $v
curl -s -o /dev/null -w '%{http_code}\n' --aws-sigv4 aws:amz:us-east-1:s3 \
--user minioadmin:minioadmin "http://127.0.0.1:9000/$b/obj?versionId=$v"
done
doneOutput of step 3 on main b91e1c6f2 (dates trimmed):
$ mc ls --versions hot/versioned/obj hot/suspended/obj
0B STANDARD f5bf38d0-9389-4a56-876a-dc47fd7efd0b v4 DEL obj
293KiB WARM a3d2cbdc-adf5-447e-8b9d-0e32212b8458 v3 PUT obj
293KiB WARM a374d523-a28c-48b8-80c0-33c94863eb43 v2 PUT obj
293KiB WARM 89e57427-375b-404c-8144-5522a680a0c9 v1 PUT obj
293KiB WARM dff114ea-2532-46b8-aa4e-ddb5c78d0440 v1 PUT obj <- suspended/obj
$ mc ls --recursive warm/tier | wc -l
2
versioned ?versionId=a3d2cbdc-adf5-447e-8b9d-0e32212b8458 -> 404
versioned ?versionId=a374d523-a28c-48b8-80c0-33c94863eb43 -> 200
versioned ?versionId=89e57427-375b-404c-8144-5522a680a0c9 -> 200
suspended ?versionId=dff114ea-2532-46b8-aa4e-ddb5c78d0440 -> 404
versioned: the delete marker is on top, v3 is listed as WARM and returns 404. suspended: no delete marker, v1 is still the current version and returns 404. The tier went from 4 objects to 2. hot.log has no error.
Context
- Where the expiry comes from. The scanner (
cmd/data-scanner.go:1130), GET (cmd/object-handlers.go:497) and HEAD (:977) of an expired object, and listings (cmd/erasure-server-pool.go:1842,:1903,cmd/metacache-server-pool.go:557) all queue it. The expiry worker (cmd/bucket-lifecycle.go:349) callsapplyExpiryOnTransitionedObject→expireTransitionedObjectfor every transitioned version. - Pool decommission and rebalance move transitioned versions correctly. The versions they move are lost later by this expiry like any other.
- Not affected, checked on the same setup:
NoncurrentVersionExpiration(NoncurrentDays,NewerNoncurrentVersions) deletes the noncurrent version by version ID and removes its tier object, which is correct. In an unversioned bucket the expiry removes the object and its tier object, which is also correct. A current version that is not transitioned gets a delete marker and stays readable. - A separate problem, not addressed by the fix above.
ExpiredObjectAllVersionson a transitioned current version also goes throughexpireTransitionedObjectwith an empty version ID. In a versioned bucket it therefore only adds a delete marker and keeps all versions, and, because of this bug, the current one loses its tier data. For an object that is not transitioned,applyExpiryOnNonTransitionedObjectssetsDeletePrefixand removes all versions.
Regression
No. The unconditional remote delete predates the fork; upstream MinIO has the same code.
Your Environment
- Version used (
silo --version):mainatb91e1c6f2, built from source withCGO_ENABLED=0 go build -tags kqueue -trimpath; the tier server runs the same build - Server setup and configuration: one node, one pool of 4 drives,
MINIO_SCANNER_SPEED=fastest; a second single-drive server as theminiotier - Operating System and version (
uname -a): macOS 27, darwin/arm64; mc RELEASE.2025-07-21T05-28-08Z, aws-cli 2.38.4
Activity