Skip to content

The free version of a deleted tiered version is taken for a version: the scanner expires the wrong versions, listings show a delete marker, decommission makes the object unreadable #263

Closed

Description

@botdeniska

Found while testing decommission of a pool whose versioned buckets transition to a remote tier.

When a version whose data is in a remote tier is deleted, the erasure set leaves a free version in xl.meta: an entry of the delete-marker type with the free-version flag, the remote object's name and the ModTime of the deleted version. A client DELETE ?versionId= always leaves one, and so do an overwrite of a tiered null version and an ILM expiry whose remote delete failed. The scanner's tier sweep later removes the remote object and then the free version (cmd/xl-storage.go:683, cmd/bucket-lifecycle.go:380). Until then the free version sits among the versions. Because it has the ModTime of the deleted version, it is on top when the deleted version was the latest one.

Reads already skip it. xlMetaV2.ToFileInfo ignores free versions when it computes IsLatest and SuccessorModTime (cmd/xl-storage-format-v2.go:1830), so GET and HEAD return the version below. The paths that read the whole version list do not skip it:

  • The scanner's lifecycle evaluation takes the version below for a noncurrent version. With NoncurrentVersionExpiration it deletes versions the rule must keep, including the actual latest version.
  • ListObjectVersions shows the free version as a delete marker with IsLatest=true on top of a readable object, and ListObjectsV2 does not list the key at all.
  • Decommission and rebalance move the free version to the other pool as a plain delete marker. After a decommission, the object reads 404, although its latest version was moved intact.

Expected Behavior

A free version is not a version of the object, as ToFileInfo already treats it. The version below it is the latest one: for lifecycle rules, in listings and for data movement. Healing still sees free versions, so they stay redundant until the scanner removes them. Before a pool is removed, the remote objects that its free versions still reference are removed, as the scanner would remove them. Otherwise nothing removes them.

Current Behavior

  • Scanner, lifecycle rules. The scanner reads the versions with getFileInfoVersions(buf, ..., false) (cmd/xl-storage.go:619). getFileInfoVersions (cmd/xl-storage-format-utils.go:33) moves the free versions to FreeVersions, but the remaining versions keep IsLatest and SuccessorModTime as ListVersions computed them with the free versions counted. After the latest version v3 is deleted, v2 has IsLatest=false and SuccessorModTime = the ModTime of v3. applyActions passes these versions to the lifecycle evaluator:

    • with NoncurrentDays, v2 is noncurrent since v3 was written. The scanner queues it as a noncurrent version (cmd/data-scanner.go:1132), and deleteObjectVersions (cmd/object-handlers-common.go:457) deletes it through DeleteObjects without evaluating the rule again. The latest version of the object is gone;
    • with NewerNoncurrentVersions, v2 takes one of the retained places, and one more older version than the rule allows is deleted;
    • NoncurrentVersionTransition and the Expiration of the latest version are evaluated against the wrong version in the same way.

    The scanner pass that removes a free version evaluates the rules with it present just before that. So the first scan after every such delete hits this, not only a race.

  • ListObjectVersions, ILM on listing, Walk. metaCacheEntry.fileInfoVersions (cmd/metacache-entries.go:292) returns the free versions among the versions (inclFreeVersions=true, :307). This has been the case since upstream fix: make sure we list freeVersions like DEL marker with --versions minio/minio#19878. ListObjectVersions lists a free version as a delete marker. On top, it is a marker with IsLatest=true over an object that GET returns. A key that has only a free version left is listed as a single delete marker. The ILM evaluation on listing (cmd/metacache-server-pool.go:545) and Walk (cmd/erasure-server-pool.go:2801) get the same versions.

  • ListObjectsV2. isLatestDeletemarker (cmd/metacache-entries.go:182, xlMetaBuf.IsLatestDeleteMarker at cmd/xl-storage-format-v2.go:2293) checks only the first entry. A key with a free version on top is not listed, although GET returns 200.

  • Decommission and rebalance. Both read the versions with fileInfoVersions (cmd/erasure-server-pool-decom.go:826, cmd/erasure-server-pool-rebalance.go:617). A free version is Deleted, so it is moved with DeleteObject(..., DeleteMarker: true) (decom.go:852, rebalance.go:649), which writes a plain delete marker in the other pool. removeMovedVersions then removes the free version from the source. After that:

    • the delete marker hides the object: GET returns 404, and the listings show the marker as the latest version;
    • the scanner will never remove this marker, because it is not a free version;
    • the reference to the remote object is gone. If the delete did not remove the remote object, it stays in the tier forever;
    • with lifecycle rules, filterLifecycle (decom.go:799) evaluates v2 as noncurrent too. It queues v2 for expiry and does not move it.

Possible Solution

  1. getFileInfoVersions without free versions recomputes IsLatest, SuccessorModTime and LatestModTime from the remaining versions, as ToFileInfo does for a single version.
  2. metaCacheEntry.fileInfoVersions returns the versions without free versions. The free versions go to FreeVersions, as for the scanner. The three healing paths keep reading all versions.
  3. isLatestDeletemarker, xlMetaBuf.IsLatestDeleteMarker and AllHidden(true) skip free versions when they look for the latest version.
  4. ListObjectVersions skips a key with nothing but free versions before the page limit. Without this, a page of such keys comes back empty and not truncated, and the listing ends early.
  5. Decommission does not move free versions. Once the versions of a key have moved, it removes the free versions as the scanner does: first the remote object of each, then the free version. A remote object that is already gone is not an error. If the tier fails, the free version stays, and checkAfterDecom counts free versions so that the decommission fails and can be retried. Rebalance only skips free versions. The source pool stays in the cluster, and its scanner removes them.

I have a patch with tests and will open a PR.

Steps to Reproduce (for bugs)

The script is attached: repro.sh <silo-binary> <work-dir> [mc]. It runs two native servers from the same binary:

  • warm: one drive and a bucket tier, used as the remote tier WARM (type minio);
  • hot: pool p1 of 4 drives, later p1+p2, with a versioned bucket bkt and two lifecycle rules. The first transitions every version to WARM after 0 days, so a PUT transitions it right away. The second applies NoncurrentVersionExpiration with NewerNoncurrentVersions=1 to the prefix n/.

Until the decommission, the scanner runs at slowest, so the free versions are still there. Each version is 200 KiB, and its body ends with its label.

  1. Keys a, b and d get v1 v2 v3, and key c gets v1. All 10 versions reach the tier. Then DELETE ?versionId= of a's v3 (the latest), b's v1 (noncurrent) and c's v1 (the only one).
  2. Restart with p1+p2 and decommission p1.
  3. Restart with p2 only and the scanner at fastest. n/e gets v1 v2 v3, then DELETE ?versionId= of v3. Wait until the scanner has removed the free version of n/e. The rule must keep v1, the one newer noncurrent version.

main (dd905b29f):

-- after the deletes
  FAIL a versions: got "DM* v2 v1", want "v2* v1"
  ok   a GET: v2
  FAIL b versions: got "v3* v2 DM", want "v3* v2"
  FAIL c versions: got "DM*", want ""
  ok   d versions: v3* v2 v1
  FAIL ListObjectsV2: got "b d", want "a b d"
2) pools p1+p2, decommission p1
  ok   decommission of p1: complete
-- after the decommission
  FAIL a versions: got "DM* v2 v1", want "v2* v1"
  FAIL a GET: got "HTTP 404", want "v2"
  FAIL b versions: got "v3* v2 DM", want "v3* v2"
  FAIL c versions: got "DM*", want ""
  FAIL ListObjectsV2: got "b d", want "a b d"
3) pool p2 only, scanner fastest
  FAIL n/e versions before the scanner: got "DM* v2 v1", want "v2* v1"
  FAIL n/e versions after the scanner: got "v2*", want "v2* v1"
failed checks: 11

* marks IsLatest, and DM is a delete marker in ListObjectVersions. The decommission completes, and then key a reads 404 although v2 was moved. The scanner deletes n/e's v1 because it counts v2 as noncurrent. With a NoncurrentDays rule it deletes v2 itself. The stand cannot show that without faking ModTimes, but the unit test in the PR does.

repro.sh
#!/usr/bin/env bash
# Repro for the SILO issue: the free version that the deletion of a tiered version leaves in xl.meta is
# taken for a version of the object. Listings show it as a delete marker on top of the object, the scanner's
# lifecycle evaluation counts it when it decides which version is the latest, and a decommission turns it
# into a real delete marker, after which the object reads as deleted.
#
# Native, no Docker. Two servers from the same binary:
#   warm - one drive, bucket "tier", used as the remote tier WARM (type minio);
#   hot  - pool p1 of 4 drives, later p1+p2, a versioned bucket bkt with two lifecycle rules:
#          transition every version to WARM after 0 days (PUT transitions it right away), and for the
#          prefix n/ NoncurrentVersionExpiration with NewerNoncurrentVersions=1 (keep one noncurrent version).
# The scanner runs at "slowest" until the decommission, so the free versions are still there.
#
# Keys, each version 200 KiB:
#   a: v1 v2 v3, DELETE ?versionId=v3 (the latest)   -> want v2 latest, v1
#   b: v1 v2 v3, DELETE ?versionId=v1 (noncurrent)   -> want v3 latest, v2
#   c: v1 only,  DELETE ?versionId=v1                -> want no versions
#   d: v1 v2 v3, nothing deleted (control)           -> want v3 latest, v2, v1
# Steps:
#   1) p1 only: write, wait for the transitions, delete, check ListObjectVersions, GET and ListObjectsV2;
#   2) restart with p1+p2, decommission p1, check again;
#   3) restart with p2 only and the scanner at "fastest". n/e: v1 v2 v3, DELETE ?versionId=v3. Wait until the
#      scanner has removed the free version of n/e, then check n/e: want v2 latest, v1 (v1 is the one newer
#      noncurrent version the rule keeps).
#
# Usage: repro.sh <silo-binary> <work-dir> [mc]
# Needs curl with --aws-sigv4, python3 and mc. PORT (default 9320) is the S3 port of hot, PORT+1 its console,
# PORT+2 and PORT+3 those of warm. The work dir is recreated; the servers are stopped at the end.
# Exit code 0 when every check passes.
set -u
BIN="${1:?silo binary}"; W="${2:?work dir}"; MC="${3:-mc}"
HP="${PORT:-9320}"; WP=$((HP + 2)); EP="http://127.0.0.1:$HP"
rm -rf "$W"; mkdir -p "$W/hot/p1" "$W/hot/p2" "$W/warm/d1" "$W/mc" "$W/files"
W=$(cd "$W" && pwd) # pools are given to the admin API by their absolute paths
export MC_CONFIG_DIR="$W/mc" MINIO_CI_CD=1 MINIO_ROOT_USER=minioadmin MINIO_ROOT_PASSWORD=minioadmin
export MC_HOST_hot="http://minioadmin:[email protected]:$HP" MC_HOST_warm="http://minioadmin:[email protected]:$WP"
P1="$W/hot/p1/d{1...4}"; P2="$W/hot/p2/d{1...4}"
HPID=""; WPID=""; FAIL=0
cleanup() {
  [ -n "$HPID" ] && kill "$HPID" 2>/dev/null && wait "$HPID" 2>/dev/null
  [ -n "$WPID" ] && kill "$WPID" 2>/dev/null && wait "$WPID" 2>/dev/null
}
trap cleanup EXIT

s3() { curl -s --aws-sigv4 "aws:amz:us-east-1:s3" --user minioadmin:minioadmin "$@"; }
up() { for _ in $(seq 1 300); do curl -sf -o /dev/null "$1/minio/health/cluster" && return 0; sleep 0.2; done; return 1; }
start_hot() { # speed pools...
  local speed=$1; shift
  MINIO_SCANNER_SPEED=$speed "$BIN" server --address "127.0.0.1:$HP" --console-address "127.0.0.1:$((HP + 1))" "$@" >>"$W/hot.log" 2>&1 &
  HPID=$!
  up "$EP" || { echo "hot did not start"; exit 1; }
}
stop_hot() { kill "$HPID"; wait "$HPID" 2>/dev/null; HPID=""; }
in_tier() { "$MC" ls -r warm/tier | wc -l | tr -d ' '; }
wait_tier() { # count
  for _ in $(seq 1 120); do [ "$(in_tier)" -ge "$1" ] && return 0; sleep 1; done
  echo "only $(in_tier) of $1 versions reached the tier"; exit 1
}

# put <key> <label>: writes a version whose body ends with the label, records "<version-id> <label>".
put() {
  head -c 204800 /dev/zero | tr '\0' x >"$W/files/body"; printf '%s' "$2" >>"$W/files/body"
  local vid
  vid=$(s3 -D - -o /dev/null -T "$W/files/body" "$EP/bkt/$1" | tr -d '\r' | awk -F': ' 'tolower($1)=="x-amz-version-id"{print $2}')
  echo "$vid $2" >>"$W/labels"; echo "$1 $2 $vid" >>"$W/vids"
}
vid() { awk -v k="$1" -v l="$2" '$1==k && $2==l {print $3}' "$W/vids"; }
delete_version() { # key label
  echo "  DELETE $1?versionId=<$2> -> HTTP $(s3 -o /dev/null -w '%{http_code}' -X DELETE "$EP/bkt/$1?versionId=$(vid "$1" "$2")")"
}
# versions <key>: ListObjectVersions of the key, newest first; "DM" for a delete marker, "*" for IsLatest.
versions() {
  s3 "$EP/bkt?versions&prefix=$1" | python3 -c '
import sys, xml.etree.ElementTree as ET
key, labels = sys.argv[1], dict(l.split() for l in open(sys.argv[2]) if l.strip())
out = []
for e in ET.parse(sys.stdin).getroot():
    tag = e.tag.split("}")[-1]
    if tag not in ("Version", "DeleteMarker"):
        continue
    f = {c.tag.split("}")[-1]: c.text for c in e}
    if f.get("Key") != key:
        continue
    label = "DM" if tag == "DeleteMarker" else labels.get(f.get("VersionId"), "?")
    out.append(label + ("*" if f.get("IsLatest") == "true" else ""))
print(" ".join(out))
' "$1" "$W/labels"
}
get() { # key -> label of the body, or the HTTP code
  local code
  code=$(s3 -o "$W/files/got" -w '%{http_code}' "$EP/bkt/$1")
  if [ "$code" = 200 ]; then tail -c 2 "$W/files/got"; echo; else echo "HTTP $code"; fi
}
listed() { # ListObjectsV2 keys
  s3 "$EP/bkt?list-type=2" | python3 -c '
import sys, xml.etree.ElementTree as ET
print(" ".join(c.text for e in ET.parse(sys.stdin).getroot() for c in e if c.tag.endswith("}Key")))'
}
check() { # name got want
  if [ "$2" = "$3" ]; then echo "  ok   $1: $2"; else echo "  FAIL $1: got \"$2\", want \"$3\""; FAIL=$((FAIL + 1)); fi
}
state() {
  echo "-- $1"
  check "a versions" "$(versions a)" "v2* v1"; check "a GET" "$(get a)" v2
  check "b versions" "$(versions b)" "v3* v2"; check "b GET" "$(get b)" v3
  check "c versions" "$(versions c)" ""; check "c GET" "$(get c)" "HTTP 404"
  check "d versions" "$(versions d)" "v3* v2 v1"; check "d GET" "$(get d)" v3
  check "ListObjectsV2" "$(listed)" "a b d"
}

echo "== $("$BIN" --version | head -1)"
"$BIN" server --address "127.0.0.1:$WP" --console-address "127.0.0.1:$((WP + 1))" "$W/warm/d1" >"$W/warm.log" 2>&1 &
WPID=$!
up "http://127.0.0.1:$WP" || { echo "warm did not start"; exit 1; }
"$MC" mb -q warm/tier >/dev/null
start_hot slowest "$P1"
"$MC" admin tier add minio hot WARM --endpoint "http://127.0.0.1:$WP" --access-key minioadmin --secret-key minioadmin \
  --bucket tier --prefix hot/ >/dev/null
"$MC" mb -q hot/bkt >/dev/null && "$MC" version enable hot/bkt >/dev/null
"$MC" ilm rule add --transition-days 0 --transition-tier WARM hot/bkt >/dev/null
"$MC" ilm rule add --prefix n/ --noncurrent-expire-newer 1 hot/bkt >/dev/null
: >"$W/labels"; : >"$W/vids"
for k in a b c d; do
  for v in v1 v2 v3; do
    [ "$k" = c ] && [ "$v" != v1 ] && continue
    put "$k" "$v"
  done
done
wait_tier 10
echo "1) pool p1 only, all 10 versions in the tier"
delete_version a v3; delete_version b v1; delete_version c v1
state "after the deletes"

stop_hot
start_hot slowest "$P1" "$P2"
echo "2) pools p1+p2, decommission p1"
"$MC" admin decommission start hot/ "$P1" >/dev/null
st=""
for _ in $(seq 1 180); do
  st=$("$MC" admin decommission status --json hot/ "$P1" | python3 -c '
import sys, json
d = json.load(sys.stdin); d = d.get("decommissionInfo", d)
print("complete" if d.get("complete") else "failed" if d.get("failed") else "")')
  [ -n "$st" ] && break; sleep 1
done
check "decommission of p1" "$st" complete
state "after the decommission"

stop_hot
start_hot fastest "$P2"
echo "3) pool p2 only, scanner fastest"
n=$(in_tier)
for v in v1 v2 v3; do put n/e "$v"; done
wait_tier $((n + 3))
delete_version n/e v3
check "n/e versions before the scanner" "$(versions n/e)" "v2* v1"
# The deleted version leaves a free version, marked in xl.meta by this metadata key.
meta="$W/hot/p2/d1/bkt/n/e/xl.meta"
for i in $(seq 1 300); do grep -q "x-minio-internal-free-version" "$meta" || break; sleep 1; done
grep -q "x-minio-internal-free-version" "$meta" && { echo "  FAIL the scanner did not remove the free version in 300 s"; FAIL=$((FAIL + 1)); }
sleep 5 # the expiry workers run asynchronously
echo "   the scanner removed the free version after about $i s"
check "n/e versions after the scanner" "$(versions n/e)" "v2* v1"
check "n/e GET" "$(get n/e)" v2
echo "remote objects in the tier: $(in_tier)"
echo "failed checks: $FAIL"
[ "$FAIL" -eq 0 ]

Context

We use versioned buckets with transition to a remote tier and plan to decommission a pool. Every client delete of a tiered version by ID leaves a free version. A decommission run before the scanner has removed all of them turns each one into a permanent delete marker. Where the deleted version was the latest one, that object becomes unreadable. Separately, the first scanner pass after such a delete applies noncurrent rules to the wrong versions, and a NoncurrentDays rule deletes the latest version.

Upstream minio#19878 started listing free versions on purpose ("list freeVersions like DEL marker with --versions"), so that --versions shows every entry of xl.meta for supportability. The author of free versions objected in that PR that "free-versions are internal to MinIO and shouldn't be visible to applications via S3 API". The fix above follows that view for listings and keeps the free versions visible to healing.

Regression

No. The partition in getFileInfoVersions, the latest-marker checks and the movement of delete markers come from upstream MinIO. Listing free versions as versions comes from minio#19878 (June 2024).

Your Environment

  • Version used (silo --version): main at dd905b29f, built from source
  • Server setup and configuration: one node; hot with pool p1 of 4 local directories, then p1+p2; warm as a second server with one directory, added as tier WARM of type minio; MINIO_CI_CD=1
  • Operating System and version (uname -a): macOS (Darwin 27.0.0, arm64); mc RELEASE.2025-07-21T05-28-08Z

Activity

  1. moved this from Backlog to In progress in Siloon Oct 31, 2026
  2. moved this from In progress to Done in Siloon Nov 1, 2026
  3. Vonng commented on Nov 9, 2026

    @Vonng
    Member

    Post-20261026 resolution record.

    Implemented: 3f13c26ee, fb1a619ee, 7ce7fc8d1.

    Free-version records are excluded when determining the latest ordinary version, looking for a latest delete marker, listing versions and walking objects for migration. Their remote-cleanup role is retained. The later, separate remote-ownership safeguards are recorded in #308.

    Verification: TestFreeVersionScannerLatestVersion, TestFreeVersionListObjectVersions, TestFreeVersionDataMovement passed in the preserved 2026-11-08 validation at bb31c2618. This audit checked the pass records, log hashes and recorded exit codes.

    Result: A cleanup record no longer changes lifecycle ordering or appears as a user-visible delete marker in these paths.

    These changes are in public main. They are not part of the latest published server release, RELEASE.2026-10-26T00-00-00Z.

  4. added theissue type on Nov 9, 2026
  5. added this to the 20261109 milestone on Nov 9, 2026
  6. added
    bug
    on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions