Files
seaweedfs/weed
Chris LuandClaude Opus 5.5 0ce344d559 redis3: remove names left by expired entries, fix skip-list split and listing (#13408)
* redis3: a listing removes the names of expired entries from the directory

A listing skipped the name of an entry whose value redis expired and left
it in the directory's list for good, so the list key also outlived the
directory's last entry. For an entry past its TTL it ran ZREM on the list,
which in this store is a string key, so that name stayed as well.

Both now leave the directory's list once the walk ends, under the list's
lock and only when the master holds no value for the name, so an insert
that wrote its value first keeps its name. An entry past its TTL is
deleted only if it still holds the bytes the listing judged expired.

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

* redis3: a lookup removes what a redis-expired entry left behind

The filer asks a store that implements ExpiredLeftoverStore to clean up
after a lookup that missed under a TTL rule, as the redis and redis2
stores do. redis3 now removes the name from the directory's list too,
checking the list first so a miss on a name never written costs only
the reads of the list.

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

* redis3: key the upper half of a split node by its smallest name

When a full node splits and the new name goes to the lower half, the
upper half was keyed by that new name, which it does not hold. Deleting
the name then matched the upper node by key and removed nothing, so the
name stayed listed, and listings from a start name could come back out
of order. Only a directory list of more than one node splits.

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

* redis3: list from a start name inside an earlier node

A listing from a start name that falls inside a node, rather than on a
node's key, began at the next node and skipped the rest of the node that
holds the start name. A paged directory listing resumes from the last
name it returned, so every page after the first lost names once the
directory's list had more than one node.

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

* redis3: check a lookup's name against the one node that would hold it

The check that a missed name is still listed walked the list from that
name, which fetched the rest of its node, up to a million names, to look
at the first. It now asks that node for the one name.

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

* redis3: stop a list change on a failed read of a node's smallest name

NodeMin returned "" for a failed read as for an empty node. Deleting a
node's key name then dropped the whole node with the names it still
held, and a split keyed a node by the empty name. It now returns the
error, and both stop on it.

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

* redis3: an update that finds its value expired lists the name again

UpdateEntry only wrote the value. When redis expired the value between
the caller's read and the update, a lookup or listing could take the
name out of the directory in between, and the update left a live entry
that no listing shows. The value is now written by a script that also
reports whether one was stored, and an update that found none adds the
name back, under the list's lock as an insert does.

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

* redis3: read a split node's new smallest name before changing the list

A split that failed this read had already unlinked the node and saved
the new lower node, and returned before the list header was saved, so
the names of the node were no longer reachable.

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

* redis3: return a failed read of a node's membership

A failed read passed for a missing name: a lookup's leftover check
reported no leftover, and a delete returned success with the name still
listed.

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

* redis3: take back an update's value when listing its name fails

An update that found its value expired wrote it again and then listed
the name. If listing the name failed, the value stayed, so a retry found
it stored and returned without listing the name. The value is now
deleted again if it is still the one written.

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

* redis3: stop a list change on a failed count of a node's names

NodeSize and NodeInnerPosition read 0 from a failed ZLEXCOUNT. A delete
then took the node for emptied and dropped it with the names it still
held, and a split added the name in a node of its own ahead of the names
before it, so listings came back out of order.

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

* redis3: read the directory list from the masters when changing it

With useReadOnly or routeByLatency, redis_cluster3 sent the reads of a
list change to replicas. A lagging replica could miss a node's other
names, and the delete that read it dropped the node with them; a listing
or a lookup that removes an expired name now runs that delete too.

List changes and the EXISTS checks before them go through a second
cluster client that reads from the masters, created only when the store
reads from replicas.

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

* redis3: list an expired update's name before writing its value back

An update that wrote back an expired value and then failed to list the
name deleted the value again when it still held the update's bytes. A
concurrent write of the same bytes was deleted with it, and a failed
delete or a concurrent update of other bytes left the value without its
name for a retry that no longer looked.

The update now writes with SET XX. When the value is missing, it lists
the name and then writes the value under the list's lock, which the
removal of an expired name also takes. A failure leaves the value
missing, so the retry lists the name again.

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

* redis3: list an updated name again when the list lock's lease ran out

An update that finds its value missing lists the name and writes the value
under the list lock. If the write outlasts the lock's lease, another filer's
cleanup can take the lock, see no value and remove the name before the value
lands, leaving a value no listing shows. Unlock now reports a lost lease, and
the name is then listed again under a new lock.

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

* redis3: list a cleaned-up name again when the list lock's lease ran out

A listing or lookup removes a name after finding its value missing under the
list lock. If the removal outlasts the lock's lease, an update can list the
name and write its value in between, and the removal then takes out the name
of a live value. Unlock now reports a lost lease, and the name is then listed
again; if its value is still missing, the next listing removes it.

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

* redis3: list the name again when a change fails after the lease ran out

A cleanup that lost its lease could remove the name from its node and then
fail on the next read. The failed change skipped the lease check, so the
name of a value written in between stayed removed. The lease is now checked
whenever a write or check ran under the lock, and the change's own error is
kept.

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

* redis3: retry listing a name again after the lease ran out

Listing the name again after a lost lease is the only thing that lists a
value another filer wrote in between. A transient failure of that one
attempt left the value unlisted, so it is now retried.

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

* redis3: list an inserted name again when the list lock's lease ran out

An insert's list change made after the lease ran out could be overwritten by
another filer's change based on an earlier read of the list, dropping the
name while its value stays stored. Every insertChild now ends with the lease
check, so the name is listed again, as an update's already was.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 23:47:15 -08:00
..
2026-04-23 10:05:51 -07:00