Files
seaweedfs/weed/sequence
006885232e master: start file ids past the ones a previous master may have handed out (#13320)
* master: start file ids past the ones a previous master may have handed out

The file id sequence lives in memory. A master that starts, or takes over
as leader, continues it from what the volume servers report: the largest
needle id each of them holds. That is the largest id written, not the
largest one handed out, so the ids of uploads that had not landed when the
previous master was lost are handed out a second time.

Two uploads then hold one needle id in one volume with different cookies.
The one that lands second is refused, and deleting its file id, which goes
by needle id, removes the needle of the other: a file the filer had
answered 201 for lost its chunk on every replica that way.

A volume server's first report to a master now sets the sequence past its
largest needle id by a margin instead of right after it. Later reports
count as before, and a server that holds nothing adds no margin.

* master: shorten the unwritten file id margin comments

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

* master: record the file ids handed out through raft

Starting a margin past a volume server's first report does not hold for
two masters lost in a row: with nothing written in between, the second one
gets the same report and hands out the same id.

The master now records through raft how far it may hand file ids out
before it does (MaxVolumeIdCommand.FileIdCeiling, a step of 2^20 ids at a
time), and every master moves its sequence past what another one recorded,
from the log or from a snapshot. An id goes out only when it was drawn
under a ceiling this master recorded itself: recording one applies what
the masters before recorded first, so an id drawn after that is past all
of theirs, and one drawn before it is dropped.

A master that does not know the field ignores it. Snowflake ids are made
from the clock and are left alone.

* master: leave room for a file id draw larger than the ceiling step

A draw of more ids than fileIdCeilingStep never fit under the ceiling
recorded after it, so the assignment kept recording ceilings through raft.
The record now covers the dropped draw and the next one, and a count past
2^32 is refused before the additions can wrap.

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

* master: tell a recorded file id ceiling apart from another master's

A master that took over could propose the same ceiling the one before it
recorded and it had not applied yet. Applying that entry then looked like
applying its own, so its sequence stayed below ids the other master had
handed out. Each record now carries an id of the master process, and only
an entry with that id and value leaves the sequence where it is.

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

* master: charge assigned bytes only once the file id is recorded

An assignment that failed to record its file ids kept the bytes charged to
the volume, which could mark a volume near its limit full for an upload
that never came.

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

* master: move the sequence before publishing a file id ceiling

An assignment that loaded a ceiling another master recorded, before the
sequence had moved past it, could draw an id below it when this master had
proposed the same value.

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

* master: test that a failed file id record charges the volume nothing

The order c40e01786 set. Before it, an assignment that could not record its
file ids left the volume charged for them: 1 MB for an id never handed out.

* sequence: stop the memory sequencer at the largest file id instead of wrapping

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

* master: refuse a file id draw whose ceiling would wrap past the largest id

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-02 23:45:31 -08:00
..
2024-06-25 09:18:11 -07:00
2026-04-14 20:48:24 -07:00