Files
seaweedfs/weed/admin
Chris LuandClaude Opus 5.5 4ff3147ee5 worker: filer_ttl job removes expired rows from stores without native TTL (#13084)
* worker: add a filer_ttl job that walks filer.conf TTL paths

A filer store without native TTL keeps the rows of expired entries until
something looks them up or lists their directory. The job lists every
TTL path subtree once per filer store, so the filer drops the expired
rows it meets.

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

* worker: register the filer_ttl job in the lifecycle lane

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

* filer: re-check an expired entry under its path lock before a listing deletes it

A listing deleted the expired entries it collected by path after the page
was read, so a write that replaced one in between lost its new row. The
delete now re-reads the row under the lock writers take, and in one
conflict-checked transaction on stores that refuse a commit over another
writer's change; anything but a still-expired row is kept.

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

* worker: read each filer store's own filer.conf, chunk-backed included

Filers with separate stores keep separate filer.conf files, so one
filer's rules could hide another store's TTL paths. A config stored in
chunks read as empty. An unreadable config now fails the detection
instead of reading as no rules.

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

* command: count filer_ttl among the mini default job types

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

* worker: resume an unfinished filer_ttl walk from its checkpoint

The walk position is saved in the job's filer store every 30s and at
the first failure, keyed by store signature, and cleared when a pass
completes. The next run skips the prefixes and subtrees already walked,
unless the TTL prefix set changed or the pass is over 7 days old.

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

* worker: save the filer_ttl checkpoint as soon as a walk fails

The first failure froze the checkpoint but only the end of the run saved it,
so a worker killed while walking later prefixes lost it. stop now saves it at
once; the end of the run saves again only if that save failed.

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

* worker: keep a path TTL rule from expiring the filer_ttl checkpoint

A filer.conf TTL rule over /etc/ gave the checkpoint that rule's TTL, so an
interrupted pass could lose its record long before checkpointMaxAge. The
checkpoint is now written with its own TTL of checkpointMaxAge, which the
filer keeps instead of the rule's.

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

* worker: remove a filer_ttl checkpoint the new pass will not resume from

An overwrite keeps the stored entry's Crtime, and the checkpoint's TTL counts
from it, so a pass that replaced a rejected record could lose its own record
before checkpointMaxAge. load now deletes a record it rejects, and the new
pass creates a fresh one.

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

* worker: expire filer_ttl entries from metadata events per TTL rule

Each run replays every filer.conf TTL rule's metadata events from that
rule's cursor up to the run start, and looks up each entry whose TTL has
passed so the filer removes its row. The first entry not yet due holds the
rule's cursor, so a later run replays it. A rule without a cursor, or
whose TTL changed, is listed once to reach rows older than its replay
window. The periodic full walk and its checkpoint are gone.

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

* filer: re-check an S3-expired entry under its path lock before a listing deletes it

A listing deleted an S3-expired object by the row it had read, so an upload
that replaced it after the page was read was removed. The delete now re-reads
the row under the path lock and removes it only if it is still S3-expired.

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

* filer: remove an expired row a lookup meets in a conflict-checked transaction

A lookup that met an expired row deleted it by path, so a replacement written
through another filer between the read and the delete was lost, even on
stores that refuse conflicting commits; a failed delete was hidden behind not
found. The lookup now re-reads and deletes through deleteIfExpired and returns
the delete error.

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

* worker: keep a failed filer_ttl lookup that ties a done event

When the first event at a timestamp was done and the second one's lookup
failed, the cursor already stood at that timestamp, so the retry subscribed
after it and skipped the failed event. A failed lookup now holds the cursor
below a tie, as a waiting entry does.

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

* worker: hold a filer_ttl event whose entry the filer still serves

A lookup that returned the live entry counted as done, so when the worker's
clock ran ahead of the filer's near the deadline the event was skipped and
the row stayed. An entry the filer still serves with the same deadline now
holds the cursor like one not yet due.

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

* worker: keep a path TTL rule from expiring the filer_ttl cursors

The cursors were written without a TTL, so a filer.conf TTL rule covering
/etc/seaweedfs/filer_ttl gave them the rule's TTL and every rule was listed
again once they expired. When a rule covers them they are now written with a
TTL of their own, which the filer keeps.

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

* worker: list a filer_ttl rule again for a live entry its replay cannot reach

A new rule nested under a longer one started its replay one TTL back, so a
live entry the enclosing rule had stamped with its longer TTL, written before
that, was in neither rule's replay: the nested rule now owns it and the
enclosing rule skips it. The listing of a new rule now records the earliest
deadline of such entries, and the rule is listed again then.

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

* worker: hand a removed filer_ttl rule's replay to the rule enclosing it

When a nested rule was removed, its entries became the enclosing rule's, but
that rule's cursor could already be past their events, so they were never
replayed. The enclosing rule now replays from the earlier of both cursors.

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

* worker: list a filer_ttl rule whose unfinished events the filer no longer keeps

When fs.log.purge removed the event of an entry still waiting for its TTL,
the rule's cursor matched, so the rule was never listed and the replay never
met the entry again. A rule whose cursor is older than the oldest kept
metadata log is now listed, and its cursor moves to that log. The cursor also
records how far a replay read with nothing left waiting, so a quiet rule is
not listed just because old logs were purged.

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

* worker: leave S3 lifecycle expiry to the s3_lifecycle job in filer_ttl

An entry whose TTL an S3 lifecycle rule set carries the S3 expiry flag;
s3_lifecycle evaluates and removes it. filer_ttl no longer looks such
entries up, and their deadline no longer holds a TTL rule's cursor.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 17:20:03 -08:00
..