* go.mod: take seaweedfs/go-fuse from #5 until it is released
The handover builds on the server API of seaweedfs/go-fuse#5: Server.Stop,
Start and Shutdown, Server.Dev and NewServerFromDev. Until that pull request
is merged and tagged, go-fuse is replaced by its branch; the replace goes
with the release.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: quiesce the background writers, pause and resume the metadata subscription, and give a takeover its own cache directories
The periodic metadata flush, the proactive chunk flush and the idle directory
eviction check a gate before each tick, so a handover can stop them and wait
for the work they run. PauseMetadataFollow and ResumeMetadataFollow end the
subscription and start it again from the position of the last event it
handled, with the filer.conf follower it had.
A successor keeps the subscription's client id (the signature crosses), so
it subscribes at an epoch above its predecessor's: the filer then replaces
the old subscription instead of refusing the new one as a duplicate and
making it wait for a retry.
A process that takes a mount over (Option.Takeover) uses <id>.t<pid> for its
read and swap directories, as the predecessor still uses <id>. A normal start
removes the stale <id>.t* siblings.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: the handover protocol, old side and new side
A running mount listens on a unix socket (0600; the peer's uid is checked
with SO_PEERCRED on both ends, ours or root). A successor connects, says
hello, receives the FUSE fd with the INIT negotiation and the exported state,
answers ready, and is told go.
The hello carries the mount directory, the filer path and the options the
state depends on (writeback cache, routed locks, nfs export): the running
mount refuses a mismatch, a blocked lock request and a peer chunk server
before it flushes or pauses. A connection closed before its hello is a probe
(HandoverAnswers), logged at V(1).
Until go the old side rolls back at every step (pre-flush, quiesce, stop,
final flush, pause of the subscription, export, ready) and keeps serving: the
subscription restarts from its position, the background writers and the nfs
export writer resume, the server reads again. After go it closes its server
without unmounting and marks itself committed, so its exit leaves the mount
and the successor's sockets alone.
The fd is carried by a fixed-size header written with one sendmsg and read
with one recvmsg; control messages are length-prefixed JSON, and the state
stream and the go frame are read through one bufio.Reader.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: a new mount on a live mount directory takes it over
A weed mount started on a directory that is mounted already, whose weed
mount answers on the handover socket, takes that mount over instead of
replacing it: open files, locks and working directories inside it carry on.
- Every Linux mount listens on a socket next to its local gRPC socket,
<localSocket without .sock>.handover.sock, /tmp/seaweedfs-mount-<hash>.handover.sock
by default; a deployment that keeps the local socket where the next mount
process can reach it gets the same for this one. Not with -peer.enable,
whose listen port has a single owner, nor with -filer.tokenFile, as read
tokens and chunk proofs do not cross.
- Those mounts read /dev/fuse in the stoppable way.
- A new mount takes over when its directory is in the mount table and a
process answers on the socket. When none answers (none runs, it crashed,
it is an older weed), the mount proceeds as before.
- A takeover skips the pre-mount unmount and the mount point check, binds the
local gRPC socket and the handover socket only after the old process said
go, and uses cache directories of its own. One that does not go through
exits non-zero and leaves the running mount serving; to mount anew, stop
that weed mount or unmount first, as for a busy mount today.
- After go, a socket the new process cannot bind is logged, not fatal: the
mount goes on without mount.configure or without a next handover, rather
than going down.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: end-to-end handover test
test/fuse_handover starts a real weed mini and weed mount processes with the
same arguments, and lets each new one take the live mount over, twice in a
row and once more after a refusal. An appending writer, a streaming reader,
an mmap, an unlinked temp file, an unclosed new file, a directory walk and a
listing in progress, a held flock and POSIX lock, a process working inside
the mount and a renamed open file run through it. It checks that the mount
was never unmounted (mount id and st_dev), that the old processes exit 0,
that a takeover refused because a SETLKW is blocked, or because the options
differ, leaves the mount serving without a pause, and prints the pause.
With HANDOVER_SCALE_FILES=<n> a second test creates n files, takes the mount
over, and logs the pause and the size of the state. On a 2-vCPU VM: 10k files
18 ms and 360 KB, 100k files 134 ms and 2.9 MB, 300k files 410 ms and 7.1 MB.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: answer the first review of the handover
The checks before anything pauses:
- The hello carries the filer addresses, sorted, and -defaultPermissions:
the running mount refuses a successor of other filers (its open files and
inode table name entries and chunks of this filer) or of another
default_permissions (without it the kernel leaves the permission checks
to the mount, and a successor that counts on the kernel would make none).
- A successor finds the live mount for a relative -dir and for a path with a
space: the mount table is read with the absolute path, and its octal
escapes (\040 ...) are undone, which checkMountPointAvailable gets too. The
local socket keeps its name.
Rollback and commitment:
- A rolled back handover starts the FUSE server first. A subscription that
did not end in time may wait for a request to be served, and the rollback
waited for it before the server read again. The subscription now starts
again in the background once the old one has ended; until then a new
handover is refused before anything pauses.
- A successor reads the filer configuration (PrepareBackgroundTasks) before
it connects, since a failure there after go would end the process with
nobody serving the mount, and it does not create the mount root, which the
running mount serves.
- A reconnecting subscription publishes its epoch, so that a later one with
the same client id starts above it instead of being refused as a
duplicate.
- A takeover's cache directories are <id>.t<pid>-<random>: two processes
that each run as pid 1 of a container sharing the cache base got the same
directory.
Tests:
- The protocol tests run on Linux only, as the protocol does; those of the
background gate and of the cache directories run everywhere.
- The end-to-end harness bounds the probes that go into the mount, waits
until the SETLKW helper sleeps in FUSE before it asks for a takeover,
counts only complete reader passes, closes the retained files on failure,
rechecks a log after its process exited, and cleans up only mounts below
its own directory.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: read the filer configuration again after a takeover
A successor reads the filer configuration before it connects, so that
nothing that can fail is left for after go. A change that the predecessor
applied in between does not come again with the subscription, which starts
where the predecessor stopped, and the successor kept the configuration it
had read. It now reads it once more when it starts its background tasks;
on failure the one read before stays.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: build the moved handover tests where their helpers are
handover_quiesce_test.go uses newHandoverWFS, which is defined in a test
file built everywhere but on Windows; it gets the same constraint. The
mount readiness probe of the end-to-end test is also capped at the
remaining deadline.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: renew the routed lock leases before the background tasks wait on the filer
A successor with -dlm holds the routed locks its predecessor took, and the
filer drops their leases 15 s after the last renewal. StartBackgroundTasks
began renewing only after it had read the filer configuration again, a
filer call that can take longer than that. The renewal now starts first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: compare -readOnly and -allowOthers in the hello, and drop a filer configuration that is gone
- -readOnly and -allowOthers are kernel mount options, fixed when the mount
was made: a successor started with others would run with the old ones
without knowing. The hello carries them and the running mount refuses a
mismatch before anything pauses.
- The filer configuration read again after a takeover clears the one read
before when the file is gone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: close the held lock files of the handover workload on failure
The flock and POSIX lock files are opened before the takeovers and closed
in finish(); an assertion that fails in between left them open. They get a
cleanup right after they open, like the other retained files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: compare the kernel's mount options as -o sets them too, and retry the filer configuration read after a takeover
- allow_other, ro and default_permissions can come from -o as well as from
their flags. The hello compared the flags only, so a successor started
with -allowOthers=false could take over a mount made with -o allow_other.
The mount now records the kernel's options from both (KernelReadOnly,
KernelAllowOther, KernelDefaultPermissions), and the hello compares
those.
- The read of the filer configuration after a takeover is tried three times
before the subscription starts, which can wait: it starts where the
predecessor stopped. Only if all fail does the configuration read before
the takeover stay until its next change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: drop the WEED_MOUNT_HANDOVER_STOP_TIMEOUT test hook
The drain bound stays at its 10 s default; the end-to-end tests wait well
over that for a refusal, so they do not need a setting of their own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: close a descriptor that comes with a refused handover
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: take a mount over when the new process shares a filer with it
The hello required the sorted -filer list to match exactly, so a
successor started after filers were added to the cluster or taken out of
it was refused, and the old mount kept serving. A filer serves one filer
store: one filer in common means the store that the open files, the
inode table and the chunks belong to.
Compare the filers as host:port, as ServerAddress.Equals does, so that
an address written with its gRPC port counts as the same filer, and
refuse only lists with no filer in common.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* ci: run the FUSE mount handover end-to-end tests
test/fuse_handover starts a real weed mini and weed mount processes and
lets each new mount take the live one over; no workflow ran it, so only
the unit tests guarded the handover in CI. The job follows the FUSE DLM
one: it repairs the fusermount3 setuid bit, builds weed and runs the
tests with WEED_BINARY. The tests mount as the runner user without
allow_other, so fuse.conf is left alone. A failed run uploads the weed
logs, which the harness keeps in /tmp/fuse_handover_*.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: compare the kernel's mount flags in the hello, resolved in order
The hello compared ro as "-readOnly or -o ro", and no other mount flag.
-readOnly puts ro before the -o options, and both fusermount3 and
go-fuse's direct mount apply the options in order, so -readOnly with
-o rw mounts read-write while the hello said ro. A successor started
with -o noexec, nosuid or nodev also got the old mount's flags without
knowing.
Resolve the generic flags from the option list go-fuse mounts with, in
order, from nosuid and nodev as both mount paths start, and refuse a
successor whose flags differ before anything pauses. relatime is left
out: the kernel uses it unless noatime or strictatime is set.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: do not send a handover control frame the peer would refuse
writeControl sized its buffer from the encoded message without a bound,
while readControl refuses a frame over maxControlFrame. Refuse the
larger frame before allocating, as the reading side does (CodeQL
go/allocation-size-overflow).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: unmount the handover e2e mounts with fusermount when fusermount3 is missing
The harness detached leftover mounts with fusermount3 only. A fuse2 host,
such as CentOS 7 or an Alpine image with the fuse package, has only
fusermount, so the last step of TestHandoverEndToEnd failed there after
every handover had passed. Try fusermount3, then fusermount.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* go.mod: use go-fuse v2.9.6 instead of the branch of seaweedfs/go-fuse#5seaweedfs/go-fuse#5 is merged and tagged v2.9.6, whose tree is the one
this pull request was tested with (1eec9a8). Drop the replace with the
fork and require the release.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: whitebear009 <whitebear009@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
* s3: add PutBucketDefaultStorageClass and GetBucketDefaultStorageClass
The setting is kept in the bucket entry's extended attributes next to
the other bucket configuration, so every gateway sees it through the
bucket config cache. Only STANDARD and INTELLIGENT_TIERING are accepted,
matching the AWS model; STANDARD clears the stored value.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: give new objects the bucket default storage class
PutObject, POST uploads, CreateMultipartUpload and CopyObject store the
bucket default when the request names no storage class. The request
headers are left alone, so bucket-policy storage-class conditions and
the self-copy change check still see only what the client sent. Upload
parts are not tagged; a completed upload takes the class recorded when
it was initiated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: test the bucket default storage class APIs and write default
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: fail a write whose bucket default storage class cannot be read
A failed bucket config lookup used to fall back to STANDARD, so a write
could store a different class than the bucket default asks for. The
write now returns the lookup error instead. A request that names its
own class still needs no lookup.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: give extracted ZIP directory members the bucket default storage class
Directory members are created through mkdir rather than putToFiler, so
they stored no class while the files next to them did.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: reject a default storage class body with trailing data
The decoder stopped after the first element, so a valid configuration
followed by another element or stray bytes was accepted. The body is
now read with a size bound and only whitespace, comments or processing
instructions may follow the configuration.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* go.mod: bump aws-sdk-go-v2/service/s3 to v1.117.1
The release adds the PutBucketDefaultStorageClass and
GetBucketDefaultStorageClass client operations.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: test the bucket default storage class through the AWS SDK
Covers get/set, an unsupported class, the setting stored in the bucket
entry and read back by a fresh bucket config, PUT, explicit classes,
multipart initiation, copy, existing objects, and per-API grants.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: let each default storage class subtest set up its own state
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: assert the explicit STANDARD class exactly in the default class test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: note that the bucket default storage class is a label only
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat: set GOMEMLIMIT from cgroup memory limit via automemlimit
* weed: set the memory limit before dispatch and report it through glog
The blank import ran memlimit.Set in an init with slog.Default, so every
weed command, including weed version and weed shell, wrote to stderr
outside glog, and macOS and Windows printed "failed to set GOMEMLIMIT:
cgroups is not supported" each time. Call memlimit.Set before running the
command instead, and log the resulting limit or a bad AUTOMEMLIMIT value
next to the transparent huge page line of long-running commands.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: log the -memoryLimitMB override and document the automatic limit
weed mount now starts with 90% of the cgroup memory limit unless GOMEMLIMIT
is set, so -memoryLimitMB=0 no longer means unlimited inside a container.
Say so in the flag help and log the override, which replaces the limit the
startup line reported.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Rajesh Kannapalli <rajesh.kannapalli@broadcom.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg compact: optional spatial clustering of geometry tables
Compaction of an Iceberg v3 table with a geometry column merges files in
manifest order (bin-pack) or by a declared sort order. Neither keeps nearby
geometries together: after a bin-pack every output file and row group spans
the whole extent of the table, so a reader can skip nothing by the geometry
bounds and row-group geospatial statistics. In one measurement a point lookup
on a table of places read 4.59 MB after bin-pack compaction and 0.55 MB after
a spatial one. A declared sort order cannot express this either: Iceberg v3
has no spatial sort transform, a geometry cannot be a sort source, and DuckDB
refuses INSERTs into a table that declares a sort order.
This adds an opt-in spatial order to the compaction job.
Spatial clustering (`spatial_clustering`, off by default). When on, a v3
table with no declared sort order and exactly one top-level geometry column
is rewritten in the Hilbert order of each row's bounding-box centre, whatever
`rewrite_strategy` says (a declared sort order is still honoured, since such a
table does not qualify):
- The 62-bit key (31 bits per axis) is computed from the WKB while the rows
stream through the merge, carried as an extra last column through
parquet-go's sorting writer into a temporary file in `sort_spill_dir`, and
dropped when a plain writer copies the rows to the output. Row lineage is
mapped before the key is added. The grid is the globe for a lon/lat CRS and
the union of the bin's file bounds for a projected one. Null, empty and
unreadable geometries sort last. The key only orders rows; pruning stays on
the geometry bounds, so a poor key costs speed, never results.
- Files are listed by the key of their bound's centre before binning, so the
bins of one partition cover compact areas.
- Row groups target `spatial_row_group_size_mb` (2 MB, capped by the table's
`write.parquet.row-group-size-bytes`, at least 16 rows; an explicit
`write.parquet.row-group-limit` still wins). A row group is what a spatial
filter skips, and a row of a large polygon can be tens of kilobytes.
- A bin the order cannot be laid over (a projected column whose files carry
no bounds, a geometry column the merge cannot find, e.g. after a rename in
files without field ids) is bin-packed in bin-pack row groups.
- The table property `seaweedfs.compaction.spatial-column` names the column
when a table has several, or opts a table out with `none`.
- The snapshot summary records `rewrite-strategy=spatial` and
`spatial-column`, or `binpack` when every bin fell back, and
`spatial-fallback-bins` when some did. The planning
index's config hash covers the new settings.
Open time partitions (`spatial_hold_open_partitions`, default true, and
`spatial_open_partition_grace_minutes`, default 120; both only matter with
spatial clustering on). A spatially ordered partition has every row group
spanning its whole time range. On a day of vehicle positions, "where is every
vehicle now" read 2.51 MB of the spatially compacted day against 0.04 MB of
the files as written, while an area query on a closed day read 2.74 MB
against 19.35 MB. So a day or hour partition is left in write order until it
has ended plus the grace (late batches still land in it), and is ordered in
space after that. The job and detection hold the same bins; the planning
index caches its answer only until the first held partition is released, so
a table nobody writes to after midnight still gets its last day ordered.
Coarser time partitions and the other strategies are unchanged.
`github.com/twpayne/go-geom` (already in the module graph) becomes a direct
requirement for its WKB parser.
Tests:
- spatial_order_test.go: the Hilbert curve, plan resolution (version, sort
order, one or several geometry columns, the property, opt-out), 2,400
scattered points compacted end to end in spatial order with row ids kept
and no key column written, the job setting off as control, nulls last, a
projected CRS with and without file bounds, file ordering, and the
row-group sizing.
- spatial_fallback_test.go: the bin-pack fallback uses bin-pack row groups;
a geometry column the merge cannot find falls back, with the summary
saying so.
- spatial_open_test.go: partition ends for day and hour across the value
types a manifest reader returns and far from 1970; the hold, the grace and
their controls; the planning index release time and config hash; on the
fake filer, a day-partitioned geometry table where the job compacts the
past day in spatial order and leaves today's files, a table of only today
commits nothing, and the index records midnight UTC plus the grace (each
with the hold off as control); spatial clustering is off by default.
- Mutation checks: a constant key fails the spatial order tests; disabling
the hold fails four open-partition tests.
- go vet and go test (also with -race) of weed/worker/tasks/iceberg pass;
go build ./weed passes.
* iceberg compact: give the spatial sort key a name no table column has
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg compact: report spatial order only for bins it wrote
A bin skipped after a read or merge error no longer counts as
spatially ordered in the snapshot summary or the job result.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg compact: do not hold an open partition the spatial order cannot cover
A projected geometry column whose files carry no bounds is bin-packed,
so holding its open day or hour partition only left small files behind.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg compact: do not hold a drop-only bin in an open partition
A bin whose rows are all deleted removes its files and writes nothing, so
there is no spatial rewrite for an open day or hour partition to wait for.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg compact: pack delete-heavy files in the spatial file order
Delete-heavy bins took the table's order while the other bins of a spatial
plan list their files by the Hilbert key of their geometry bounds, so a
partition split into several delete-heavy bins merged overlapping areas.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* deps: bump parquet-go to v0.33.0
parquet-go v0.33.0 fixes several bugs that Iceberg compaction runs into:
- BOOLEAN columns that Arrow and parquet-mr write with data page v2 are
RLE-encoded. v0.32.0 decoded such runs wrong (a run's value byte expanded
bit by bit, runs taken as multiples of 8 values), so compaction rewrote the
flags wrong, and it wrote its own runs of trues with the value byte 0xFF,
which DuckDB refuses to read ("Payload value bigger than allowed")
(parquet-go/parquet-go#617, fixed by parquet-go/parquet-go#620).
- A column chunk without a dictionary lists the level encoding RLE next to
PLAIN. v0.32.0 took RLE as the column's encoding, so the schema derived from
a non-dictionary INT32 or DATE file could not write ("RLE: cannot encode
INT32 with invalid bit-width=0") and such files never compacted
(parquet-go/parquet-go#603, fixed by parquet-go/parquet-go#611).
- The sorting writer dropped the row groups' geospatial statistics when a
bin fit in its sort buffer, so a sorted rewrite of a geometry table wrote
files without a geometry bound (parquet-go/parquet-go#627, fixed by parquet-go/parquet-go#693 and parquet-go/parquet-go#700).
- A null in a list of required values wrote no value and shifted the rest of
the page (parquet-go/parquet-go#616, fixed by parquet-go/parquet-go#618); a short data page read leftover
values from a pooled buffer instead of failing (parquet-go/parquet-go#624, fixed by
parquet-go/parquet-go#731).
- A geometry or geography column declared without a CRS is now written
without one rather than with OGC:CRS84 spelled out (parquet-go/parquet-go#628, fixed
by parquet-go/parquet-go#688).
Changes that follow from the bump:
- A corrupt data page now fails with an error rather than a panic. The
position and equality delete readers returned that error without the file
name; they now name the file, as the data file merge already does.
- The default-CRS tests built their "spelled out" inputs with
parquet.Geometry(""), which now writes no CRS; they declare OGC:CRS84
explicitly. The footer rewrite in geometry_crs.go is still needed when an
input spells the default out, since the output schema comes from an input.
Tests:
- compact_rle_boolean_test.go with four pyarrow fixtures: two files with
v2-page RLE booleans (with nulls) read back and compacted with every flag
kept, and two non-dictionary INT32/DATE files compacted with every value
kept. All three tests fail on v0.32.0 (3005 of 6000 flags wrong; "no bins
successfully compacted").
- TestCompactSortedGeometryBoundCoversEveryRow only checked a bound when
there was one, so it passed with the statistics dropped. It now requires a
geometry bound on the data file and geometry statistics in the footer; it
fails on v0.32.0 and passes on v0.33.0.
- go vet and go test of every package that imports parquet-go
(weed/admin/dash, weed/mq/logstore, weed/mq/schema, weed/query/engine,
weed/worker/tasks/iceberg) pass; -race on weed/worker/tasks/iceberg and
weed/mq/logstore passes; go build ./weed passes.
* iceberg: fail the Arrow fixture tests on a read error
Both row-reading loops ended on any error, so rows decoded next to an
error could still pass the value checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: check each fixture row comes out of compaction exactly once
A row replaced by a copy of another kept the row count and passed the
value checks, which use the row's own id.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer: read the hard link records of a listing in batches
A hard-linked entry keeps its attributes and chunks in a record the file's
names share, and a listing reads that record for every hard-linked entry
it lists. It read them one at a time from the callback of the store's
listing: a round trip to the store for each such name, each waiting for
the one before, so a directory of hard-linked files listed far slower than
one of as many plain files.
A store may now say that it reads several KV keys in one round trip
(KvBatchReader). For a listing by such a store the wrapper holds the
entries back from the first hard-linked one on, up to 256 of them, reads
their records together and hands them on. The caller of the listing gets
the same entries in the same order, and the name of the entry it ended
the listing at.
TiKV implements it with the client's batch get. With the store on the
client library's in-process TiKV, the records of a directory of 200
hard-linked names take one batch get instead of 200 gets.
The TiKV tests run the store on that in-process TiKV, which needs
pingcap/goleveldb as an indirect dependency.
* filer: end a listing where its caller ended it, whatever the store met behind
The store goes on past the entry its caller ends the listing at, to the
entries that wait for their records with it, and may fail there. The
listing then returned the store's error, though a caller handed each entry
as it arrived would have stopped the store before it got that far. The
listing now ends at the entry its caller ended it at, and a caller that
fails among the waiting entries gets its own error, not the store's.
The same holds for the step a store takes after it is told to stop, when
the caller ended the listing at an entry the store had already passed. At
the last entry that waited the step's error is still returned, as it is
from a store that hands each entry on as it arrives.
* filer: finish a hard link listing on every return of the listing
The listing hands on the entries that wait from a deferred finish, so a
return path that lists from elsewhere with the same callback hands them on
too. The callback keeps the adjustedEntryFunc shape the prefixed listing
already had.
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>
* weed: report the host transparent huge page policy at startup
Go maps the heap with MADV_HUGEPAGE, so the host THP policy applies to a
SeaweedFS process whether or not the operator asked for it, and the advice in
the Go GC guide depends on the heap size. Operators had no way to see which
mode a node actually runs in.
Log enabled/defrag/khugepaged.max_ptes_none once at startup from the
long-running commands, and print the Go toolchain in `weed version` so a
support bundle identifies the runtime that produced the binary. Nothing
changes the policy: THP is host-wide, and GODEBUG=disablethp=1 remains the
only per-process control.
Refs #5437
* build: declare Go 1.27.4, the toolchain the releases already use
The 4.55 release binaries report go1.27.4 (`go version -m` on the published
tarball), while go.mod still said 1.26.6, the Dockerfiles pinned golang:1.26,
and the release workflows left the Go version to the action default of "the
latest stable at build time". A source build, a container and a downloaded
tarball therefore ran different toolchains from the same tag, and the next
release could silently pick up another one.
Set the go directive to 1.27.4 in the root module and in the four modules that
build in CI, bump the 16 Dockerfiles, and pin goversion: 1.27.4 in the 16
release and dev action steps.
`go mod tidy` now emits the two require blocks Go 1.27 expects; no dependency
version changed. Go 1.27's gofmt realigns 8 files.
* weed mini: report the THP policy after quieting stderr
The startup line ran from the dispatch point before runMini applied
quietMiniLogs, so every weed mini start on Linux printed it to stderr,
which mini keeps for the welcome banner, warnings and errors. Log it
from runMini after quietMiniLogs so it lands in the log file only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: report whether the Go heap can use huge pages
The runtime advises only GC metadata with MADV_HUGEPAGE and leaves the
heap arenas to the host default, so under enabled=madvise the heap stays
on small pages. The log still printed go_heap_disabled=false there, which
reads as "the heap uses THP". Report go_heap_thp, true only under
enabled=always without GODEBUG=disablethp, and drop the struct comment
that said the heap is mapped with MADV_HUGEPAGE.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: count an inherited PR_SET_THP_DISABLE in go_heap_thp
A launcher can disable THP for the process with prctl, and children
inherit it, so enabled=always alone does not mean the heap gets huge
pages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: read GODEBUG disablethp the way the runtime does
The runtime applies GODEBUG left to right, so with
disablethp=1,disablethp=0 the heap keeps THP, while the helper stopped at
the first disablethp=1. The helper also missed other nonzero values such
as disablethp=2, which the runtime treats as disabled, and trimmed spaces
around keys, which the runtime keeps. Take the last disablethp with an
integer value, treat any nonzero value as disabled, and match keys
exactly. The parser now takes the GODEBUG string, so it is tested without
changing the environment.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: honor per-size THP policies in go_heap_thp
Since Linux 6.8 each anonymous huge page size has its own policy in
hugepages-<size>kB/enabled, and only "inherit" follows the top-level
knob. A 64kB size set to "always" gives the unadvised heap huge pages
under a top-level "madvise" or "never", and a 2048kB size set to "never"
takes them away under "always", but the log judged only the top-level
value. Read the per-size policies and report go_heap_thp=true when any
size reaches the heap. Under a top-level "never", the "disabled by the
host" line is now printed only when no size reaches the heap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: report go_heap_thp=unknown when the process setting is unreadable
If PR_GET_THP_DISABLE fails, for example because a seccomp profile
rejects it, the process THP setting is not known, but the log treated it
as allowed and could print go_heap_thp=true. Print go_heap_thp=unknown
in that case. It stays false when the host or GODEBUG already rules out
heap huge pages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: report go_heap_thp=unknown when a per-size THP policy is unreadable
An unreadable hugepages-<size>kB/enabled was skipped, so the log could
say the host disabled THP while that size allowed it. Keep it as an
empty mode and report unknown unless a readable size already allows
huge pages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* ci: take the Go version from go.mod in tests and releases
posix-compliance pinned GO_VERSION 1.26 and built go 1.27.4 modules only
through the GOTOOLCHAIN auto-switch; nine workflows used go-version ^1.26 and
the kafka jobs ran in golang:1.26-alpine. Read the version from go.mod with
go-version-file, as the other setup-go steps already do, moving checkout ahead
of setup-go where it came after so the file exists. The posix report takes the
version from the setup-go output.
The release and dev builds pinned goversion 1.27.4 in 16 places. The pinned
go-release-action reads the go directive when goversion is go.mod, so the
binaries now follow go.mod without a second copy of the version.
* weed: report the THP policy from every long-running command
mount, worker, iam, master.follower, the filer sync/backup/remote/replicate
daemons and the mq agent and kafka gateway keep serving after startup like
the commands already listed; mount is likely where heap size matters most.
fuse is not listed: its first process starts a child with the same arguments
and waits, so logging at dispatch would print the line twice. It logs in
runFuse just before handing over to runMount, which only the child reaches.
---------
Co-authored-by: Konstantin Lebedev <whitefox@mayflower.work>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* mount: update go-fuse for the export support option
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: optionally retain the paths of forgotten inodes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: answer lookups of "." and ".." for file handle decoding
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: add -nfsExport to negotiate export support and retain forgotten inodes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: test file handle lookups of "." and ".."
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: fail a file handle lookup when its path now holds another file
A "." lookup resolved a forgotten inode by its remembered path, so a
file created at that path since was served to the old handle. Compare
the entry's inode with the handle's and answer ESTALE on a mismatch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: register a file handle's inode under the table lock
A "." lookup checked the file at the remembered path and then registered
it with Lookup, which hands back whatever inode holds the path by then.
LookupHandle takes the reference on the handle's own inode, or enters it
at the path only while no other inode holds it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: keep a forgotten inode's retained path across a rename
A rename whose source inode the kernel had already forgotten left the
retained path at the old name, so its file handle failed with ESTALE.
An index from retained path to inode lets MovePath move it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: register a file handle only at its current retained path
A rename between resolving a forgotten inode's path and registering it
moved the retained entry, yet LookupHandle still entered the old path.
It now compares the path with the retained one under the table lock.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: drop the target a forgotten inode is renamed over
Moving a forgotten inode's retained path onto a live name left the
replaced inode mapped there. Once a retained entry moves, the target is
taken apart as for a live source and reported as replaced.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: test that a renamed path-inode file fails its file handle closed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* go.mod: use the go-fuse v2.9.5 release
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* build(deps): bump golang.org/x/term from 0.47.0 to 0.48.0
Bumps [golang.org/x/term](https://github.com/golang/term) from 0.47.0 to 0.48.0.
- [Commits](https://github.com/golang/term/compare/v0.47.0...v0.48.0)
---
updated-dependencies:
- dependency-name: golang.org/x/term
dependency-version: 0.48.0
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* telemetry: tidy go.mod for golang.org/x/sys v0.50.0
The x/term bump raises x/sys in the root module, which telemetry/server
replaces, so its build failed with "updates to go.mod needed".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer/etcd: scan entries from one revision
volume.fsck walked etcd one directory at a time, so a file moved from a
directory not yet listed into one already listed was seen under neither
name and its chunks were reported as orphans. The etcd store now
implements filer.EntryScanner: every page is read at the revision of the
first read, and a compacted revision fails the scan instead of falling
back to the walk.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/etcd: read hard links at the scan revision
Hard-link records resolved during a scan were read at the current
revision, so a link updated meanwhile mixed two instants. Reads made with
the scan's context now use its revision.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: list etcd among the stores volume.fsck reads from a snapshot
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/etcd: skip hard-link records in a scan
Hard-link records live beside the entries under their random ids, so a
root scan could read one as an entry with a path made of random bytes,
which the traversal stream cannot send. Skip hard-link ids and keys whose
directory is not valid UTF-8.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/etcd: recognize a hard-link record by the id it stores
A hard-link id can be valid UTF-8, so the key shape alone let some
records through a root scan as phantom files. The record's value is the
shared entry, whose HardLinkId is the record's own key; no entry key
can equal its own hard-link id.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/etcd: scan entries under an invalid-UTF-8 directory
The filer sanitizes names but stores directories as given, so a path
written over HTTP can leave entries the listing never reaches. Skipping
them let volume.fsck count their chunks as orphans. Send them under the
sanitized directory instead, the substitution the filer uses for names.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/etcd: fail a scan whose sanitized path names another entry
An entry under an invalid-UTF-8 directory is reported under the sanitized
directory. When that path is also another stored entry at the scan revision,
or another sanitized entry in the same scan, acting on the reported path
(volume.fsck deleting it) would reach the other file, so the scan fails and
names the stored path instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* deps: bump seaweedfs/raft so the leader quorum check follows the election timeout
A single master resuming raft state self-elects on a 1 ms election
timeout and restores the configured one afterwards, but the leader kept
running its quorum check every 1 ms for the rest of the process. The
raft change re-arms that check from the current timeout.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* deps: bump seaweedfs/raft to the raft PR head with the extended test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* deps: bump seaweedfs/raft for the non-positive election timeout guard
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* deps: bump seaweedfs/raft so a timeout change re-arms the leader quorum check
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* deps: pin seaweedfs/raft v1.2.4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* master: keep the hostname out of raft metric names
go-metrics prefixes gauge names with the hostname by default, which gives
every master its own metric family, e.g. SeaweedFS_<host>_raft_peers.
Prometheus already tells masters apart by the scrape target.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: send Hashicorp raft metrics through the go-metrics global raft uses
hashicorp/raft and raft-boltdb report through github.com/hashicorp/go-metrics,
but the master set up its prometheus sink on the armon/go-metrics global,
so a -raftHashicorp master exported no raft metric families. The sink is now
registered on the hashicorp/go-metrics global, and armon/go-metrics is no
longer a dependency.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* grafana: chart raft commit time and leader contact
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* grafana: keep the cluster in the raft panels
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* grafana: average raft commit time and leader contact over the rate window
The go-metrics summaries keep quantiles for 10s, so a p99 scraped every
30s misses most observations. The _sum/_count rates count every sample.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* grafana: leave raft panels empty when nothing was observed
Clamping the count rate plotted 0 ms for windows without commits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: let the raft metrics test use its own registry
Registering on stats.Gather made go test -count=2 fail with a duplicate
collector registration.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: register raft metrics before opening the raft stores
raft.NewRaft starts its run loop before returning, so registering the
sink afterwards could drop the first state and boltdb samples.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* master: tell a warming-up Assign client when warm-up ends
During warm-up the master refuses Assign with Unavailable and now attaches
the remaining warm-up as a gRPC RetryInfo detail. RetryWithBackoff may
shorten a backoff step to that hint plus 50 ms, never lengthen it, and only
for a valid, positive hint, so a writer retries right after warm-up ends
instead of up to one backoff step later. The warm-up itself is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: jitter the retry-hint slack and hint LookupVolume too
Per review: the slack added to a server hint is now random in
[50ms, 300ms], so clients refused at the same moment do not all retry
in one instant. The warm-up refusal of LookupVolume carries the same
RetryInfo hint as Assign; the masterclient's lookup retry already goes
through RetryWithBackoff, so it lands at warm-up end too.
Tests: the slow guard tests are replaced by one sleep-free table test
of the step logic (zero, negative, huge, malformed, valid and wrapped
hints, a hint longer than the step, none). One timing test of the
shortened step stays, plus a jitter-bounds test and a LookupVolume hint
test. The no-hint control test, which was timing-sensitive, is dropped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: name the shared warm-up test and file the lookup test by topic
Rename the no-remaining test to TestWarmingUpErrorWithoutRemainingHasNoHint,
since the helper now serves Assign and LookupVolume, and move the
LookupVolume hint test next to the other LookupVolume warm-up tests.
Tests only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: read the retry hint through ServerStatus
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: bound the warm-up hint in tests by the remaining warm-up around the RPC
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: leave more scheduler margin in the retry-hint timing tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util, master: trim retry-hint comments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: widen the retry-hint timing bounds to just under the unhinted wait
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: require a refused warm-up call before the hinted assign retry
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: check the hinted retry wait through a test timer, not the wall clock
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: move the assign warm-up end to 2.6s for more hinted-retry headroom
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: require the hinted retry to wait out its timer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
* deps: bump seaweedfs/raft for PreVote
The default raft gains the pre-vote phase so a master returning from a
partition can no longer depose a healthy leader with an inflated term.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* deps: bump seaweedfs/raft for pre-vote review follow-ups
Picks up the post-merge fixes on top of f227dce: per-round vote workers with per-peer dedupe, pre-vote grants counted at a newer term so mixed-version clusters cannot livelock, and state/conf field locking on the startup paths.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* deps: pin seaweedfs/raft to released v1.2.3
PreVote has merged and shipped as raft v1.2.3, so switch off the
PR-branch pseudo-version.
---------
Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* iceberg maintenance: bound decimal, time, uuid, fixed and rescaled timestamp columns on compacted files
The column statistics written for a compacted data file give lower and upper
bounds only for booleans, integers, floats, dates, strings, binaries and
timestamps already stored in the Iceberg type's unit. Every other column is
left unbounded, so a reader can never skip a compacted file on it: a
DECIMAL(18,2) column written by DuckDB (stored as INT64) loses its bounds
after compaction, as does a millisecond timestamp, a TIME or a UUID.
boundLiteral now also converts:
- DECIMAL stored as INT32 or INT64 at the column's scale. A decimal stored
as a byte array still gets no bound: Parquet compares those statistics as
bytes, which does not order negative two's-complement values;
- TIME, TIMESTAMP, TIMESTAMPTZ and TIMESTAMP_NS from any Parquet time unit,
rescaled to the Iceberg unit; a value rescaled to a coarser unit is
rounded down for a lower bound and up for an upper bound so it stays a
bound, and a value that would overflow gets none;
- UUID and FIXED[n] from a FIXED_LEN_BYTE_ARRAY of the right length;
- a DOUBLE column read from a FLOAT file.
arrow-go becomes a direct dependency (decimal128, already in the module
graph through iceberg-go).
* iceberg maintenance: bound TIME(MILLIS) columns stored as INT32
* iceberg maintenance: bound timestamptz_ns columns too
---------
Co-authored-by: user.email <chrislusf@users.noreply.github.com>
The pinned dev snapshot (v1.85.0-dev.0.20260915183914) predates
grpc/grpc-go#9563, which fixes the control-buffer throttle deadlock
(grpc/grpc-go#9330) that wedges weed mini under concurrent S3 writes
over unix sockets.
Verified with the issue's standalone repro (one ClientConn over a unix
socket, concurrent unary RPCs): the old snapshot deadlocks at c=512
after 743 RPCs; the new snapshot completes 3.06M RPCs/20s at c=512 and
1.97M/15s at c=2048 with no stall -- above the v1.82.0 pre-regression
baseline of ~112k ops/s.
CI installs the templ CLI with `@latest`, which now generates code
calling templruntime.NewAttributeExpression — a symbol added after the
v0.3.1070 runtime pinned in go.mod, breaking `make install` builds on
clean runners. Bump the runtime to v0.3.1100 and regenerate.