Files
seaweedfs/weed/filer
e9ea21340b filer: a lookup removes what a redis-expired entry left behind (#13397)
* filer: a lookup removes what a redis-expired entry left behind

Redis expires an entry's value on its own and leaves the name in the
parent directory's list. A listing drops such a member when it meets it,
but a lookup finds nothing and returns, so the names of entries nobody
lists stay, and so do the directories they leave empty. The filer_ttl
job expires entries by looking them up and cannot reach them either.

A lookup that finds nothing under a filer.conf TTL rule now asks the
store for what expiry left of that name. The redis stores remove the
list member, guarded against a concurrent recreate as on a listing, and
when there was one the filer removes the directories this leaves empty,
as a listing that meets an expired entry does. A miss with no member to
remove costs one command, and only under a TTL rule.

* filer: keep a directory that holds an object when removing empty parents

A file promoted to a directory by a child write keeps its own object data.
Once its last child expires the directory is empty, and the cleanup
deleted it along with that object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: report a failed removal of a redis-expired leftover

RemoveExpiredLeftover returned a nil error even when the redis SREM or
ZREM failed, so the filer could not log why an expired name stayed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: check a redis orphan repair's keys on the master

With useReadOnly or routeByLatency the cluster client sends EXISTS to a
replica. A lagging replica misreads a just-written value as absent, and
the repair then drops a live entry from its directory list. A lookup miss
now reaches this repair, so check the keys with a script, which runs on
the master, as the redis2 store already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: a lookup's cleanup leaves directories alone and asks the master first

Removing the directory a redis-expired entry left empty from the lookup
went through DeleteEmptyParentDirectories, which makes none of the empty
folder cleaner's checks. With a leftover as the trigger it removed a
multipart upload's staging directory together with .uploads, a directory
of a bucket that keeps empty folders, an S3 Tables catalog directory,
and the directory of a file written between its emptiness check and its
delete, which strands that file. The lookup now only has the store
remove the name; the directory stays.

The redis stores also check the master for the value before they touch
the list. A lookup that missed on a lagging replica used to remove a live
entry's member and put it back, and a failure in between lost it.

* redis: a lookup's cleanup looks for the member before it asks the master

Most lookups that find nothing are of a name that was never written.
Those now cost one read of the directory list instead of a script and
a removal; only a name the list still holds is checked on the master.

* redis: retry the restore of a directory list member, and report a failure

The orphan repair removes a member and puts it back when the value turns
out to be stored, because an insert got in between. Nothing else puts
that member back, and a failed restore was only logged, so the entry
stayed out of its directory's listing until it was written again. The
restore is now retried a few times, and a restore that still fails is
returned as an error.

* redis: keep restoring a directory list member until redis takes it

A restore that failed every attempt left a live entry out of its directory
list for good, since nothing else puts the member back. Retry it in the
background until it lands or the store closes; the repair still reports
the failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 11:30:04 -08:00
..
2026-04-10 17:31:14 -07:00