mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
9da4e8656cdc79dfc896a2d8709c3b46d76b5b4e
232
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
51d2b2b712 |
mq: read a table-backed topic's history from its Iceberg table (#13260)
* mq: read a topic table's data files back as log entries A view of a topic's table holds the current snapshot's offset map and, per _partition, its data files with the _offset and _ts_ns bounds from the manifests. A partition's rows are read by offset or by time, skipping files and then row groups whose bounds miss the read, and come back as the log entries they were copied from: key, timestamp, offset, and the message as _value or as the record re-encoded from its columns. Views are cached per topic, rechecked every few seconds, rebuilt only when the metadata location moves, reuse already-parsed manifests, and are evicted past a bound on the data files they hold. A table that is gone or replaced by another UUID reads as empty; one with delete files is refused. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: read a table-backed partition below its table's high-water mark from the table The merged reader takes the partition's table, looked up on every read so a table attached later is seen. An offset read below the mark reads the table up to the mark and continues into the log files and compacted parquet from the mark; a time read takes the table's rows after the time and then the files' entries at or above the mark. Log files left below the mark by a crash between the writer's commit and its delete are never read. The broker hands its partitions' disk reads to the table through the topic's cached view; a topic without a table, or whose topic.conf is gone, reads its files as before. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: start a table-backed partition's offsets at its table A partition whose log files below the table's high-water mark were deleted would reload with a high-water mark and log start taken from the files that are left. Loading it now continues its offsets no lower than the table's mark and starts its log at the table's lowest offset, or, when the table holds nothing of it, at the first file offset at or above the mark. A retired range of a repartitioned topic is read and bounded the same way, and a retention purge raises the log start likewise, so purging hot log files never makes the table's offsets out of range. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: keep a flushed data source's finished flag atomic The streaming goroutine sets finished while the merge loop reads it through HasMore, which the race detector reports on any scan that reads flushed data. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: scan a table-backed topic's history from its table The hybrid scanner hands each partition's merged read the topic's table, so a scan reads the table's data files below the partition's high-water mark, pruned by _partition, _offset and _ts_ns, and log files from the mark on, skipping any a crash left below it. Aggregations no longer answer such a topic from parquet statistics and log counts, which hold none of its table's rows; they scan instead. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: read a schematized row's raw _value back as its message A schematized topic's table can keep a message that is not a record, a tombstone or an undecodable value, as raw bytes in an optional _value with the record columns null. Such a row now reads back as those bytes; a row whose _value is null reads back as its record, and a schemaless topic's row as its _value as before. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: delete log files a topic table already holds A log file or compacted parquet whose every offset is below a partition's table high-water mark is never read again, so it can go. The mark used is that of the newest snapshot at least a minute old: a reader's view of the table is at most a few seconds old, so it already reads those offsets from the table and never from a file being deleted. Files without an offset range and the file holding the partition's highest offset are always kept. DeleteCoveredLogFiles is for the topic's writer after its commit; a leader also deletes them under its fence on load and on each retention pass, covering a writer that crashed between its commit and its delete. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: report a topic table's rows as parquet_archive A table-backed topic's scan labelled every row live_log, its table's included. The flushed data source now records the high-water mark of the table its merged read was handed and reports the rows below it, which come only from the table's parquet data files, as parquet_archive. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: delete the log files a topic table holds after each run Every mq_topic_table run now ends by deleting, in each partition, the log files wholly below the offsets of the newest snapshot at least LogDeleteGrace old, never the leader's newest file. A commit is never old enough on the run that makes it, so each run deletes what earlier ones copied; the partition's leader deletes the same files when no run follows. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: keep a time read's position when nothing on disk follows it A time read that found nothing after its position returned a position at time zero: the parquet reader reports the newest time it delivered, which is none. A loop over an empty memory buffer then read the whole partition from the start, came back to the same empty read, and started over, so a query asking a broker for its unflushed messages streamed the partition forever. The merged and the table-tiered readers now keep the position when they deliver nothing past it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: publish a topic table view under the lock eviction reads it with A loaded view was stored under its entry's loading lock while eviction, run by another topic's load, read every entry's view under the cache's lock, so two topics refreshing at once raced. A view is now stored holding both locks: a load reads it under the first, eviction under the second. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: keep no topic table view larger than the whole view cache Eviction never dropped the view just loaded, so one topic whose table had more data files than the cache's bound stayed cached past it, and evicted every other topic's view on the way. Such a view is now answered and not kept; the others stay. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: look up a topic table's mark again where a read leaves the table A read kept the table mark it started with. One slow over the table's rows could outlast the grace: the writer commits past that mark, the logs below the new mark are deleted, and the read then lists the logs from its old mark and passes over the deleted offsets without a word. The read now asks for the table again each time it leaves it and reads on in the table up to the mark it finds, until the mark stops moving; a time read takes the rows between the marks by offset. A gap where the logs begin is checked against the table once more, and read from the table if it took it meanwhile. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: read a topic table's timestamps back without going through nanoseconds A timestamp or time column was turned into micros by way of nanoseconds, which overflow for dates before 1678 or after 2261, so a year 1 or year 9999 value came back as another date. Each unit now converts to micros directly. The table fixture wrote every topic's rows whole into _value once every table had that column, so the record columns these reads take went untested; it now writes a schematized topic's rows as columns. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * iceberg: order a compaction bin by the first sort field that varies in it A topic table sorts by _partition, then _offset, and is partitioned by _partition, so every file of a bin holds one _partition. Ordering the bin by it kept the files in manifest order, and a merged file's offsets came out of order for the topic table reader, which delivers a data file's rows as offsets in order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: list a retired range from its table's lowest offset A topic lookup lists each retired range with the bounds of its own files, so once the table held a range's history and its log files went, the range was listed from its newest file on, while its reader serves the table's offsets below it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg: never merge compaction inputs across a file left out of the merge A file already at the target size takes no part in compaction, yet small files on both sides of it in sort order went into one bin, so the merged file's bounds spanned it. For a topic table that is a data file whose _offset range overlaps another's, which a reader finishing one file before the next cannot read in order. An ordered bin is now cut wherever a file left out of the merge falls between two of its files, so every merged file covers a range no file outside its run lies in. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: merge a topic table's overlapping data files by offset when reading A partition's data files were read one after another by their lowest offset, which only reads in offset order while no two ranges overlap. A rewrite by another engine can leave a file spanning another one, and then a read from inside the overlap delivered the spanning file's later rows first, and a read that stopped early left the rows in between behind. Files whose offset ranges overlap are now read together, their rows merged by offset and an offset held twice delivered once. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: open a topic table's data files only as a read reaches them A merged read opened every file of an overlapping group before it delivered a row, and a file the manifest records no offset bounds for overlaps every other one, so a short fetch held a reader for each file of the partition's history. The files of a read now wait in a heap keyed by the lowest offset each can hold, and a file is opened only once nothing before that offset is left to deliver; a file without bounds is opened where the read starts, and its row groups' statistics skip what they rule out. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: retire no log file a topic's table does not hold yet Retention deleted a table-backed topic's log files by age alone, so with the table writer behind it deleted messages the table did not hold, and they were gone from both. On such a topic a file now expires only once all it holds is below the table's mark of a grace-old snapshot, the same files the leader deletes as covered; what the table holds ages out with table retention. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: bound a table-backed range's bounds by its caller's deadline The table lookup that widens a partition's bounds ran under a background context, so a retention pass or a retired-range lookup with a deadline waited on a stalled table catalog for as long as it stalled. It now runs under the caller's context. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: check a topic table's mark again when a time read reaches its files A time read caught up with the table and then read the files above the mark it last saw. A view that had moved on meanwhile, with the logs below its new mark deleted before the files were listed, left the offsets between the two marks to neither. The time read now asks for the table again at the first file entry it would deliver, or after the files if they held none, and on a moved mark reads the table up to it before reading the files again. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: bound the topic table views kept, empty ones included, and keep those in use Eviction only counted data files, so views of tables holding none, and entries a failed first load left behind, were never dropped; and it could drop an entry while a caller was loading it, so the next caller loaded the same table again alongside. A failed first load now leaves no entry, at most maxCachedTopics views are kept, and an entry a caller still holds is never evicted. The eviction test now requires exactly the one eviction that makes room. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: check a topic table afresh before deleting the logs below its mark A leader's covered-log delete and log retention took the table's mark from the cached view, up to a few seconds old, so a table rolled back to a lower mark meanwhile had its logs above that mark deleted although it no longer held them. Both now check the table before acting: the cache takes a maximum age, a read passes ViewRefresh and a delete zero. A cached view is also reused only for the same table state, since a commit that rewrote the metadata in place keeps its location. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * iceberg: leave a sort field holding nulls to order a compaction bin A sort field whose bounds are one value in every file was taken as constant and the bin ordered by the next field, yet bounds leave nulls and NaNs out, so a column holding them besides its one value is not constant. A field is now skipped only when the files also record no null in it, and no NaN for a floating point one. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: delete a topic's covered logs only while it still names the table A run's log cleanup used the table metadata the run started with, so after the topic left the table, or the run lost its lock, it still deleted the logs below that table's marks. The cleanup now checks, when it runs, that it still holds the topic's lock and that topic.conf still names the table with its recorded UUID, and reads the marks from the table as it is then. It still runs after a run that failed otherwise. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: check a topic table again before each covered log it deletes The leader read the table's mark once, listed the files below it, then deleted them one by one, so a rollback or a detach landing in between went unseen and files the table no longer held were deleted. The delete now holds the table writer's lock, so the topic cannot leave the table meanwhile, and before each file reads topic.conf and the table afresh, stopping at the first file not below the mark it finds. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: let a caller waiting on a topic table's load give up at its deadline A caller wanting the view a stalled load of the same table was making waited on a mutex, past its own deadline, for as long as the load stalled. The entry is now held by a one-token channel a waiter selects on with its context, so it returns at its deadline and lets go of the entry. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: give up a scan's table lookup when the query is cancelled The table a scan reads below each partition's mark was looked up under a background context, and the flushed data source waited on its channels alone, so a cancelled query stayed blocked on a stalled table catalog. The scan's context now reaches the topic.conf read and the table lookup, and the data source returns once it is done. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: take a topic table's lock only when a covered log is left to delete The leader's covered-log pass took the table writer's lock for every table-backed partition it leads once the table had a mark, every five minutes, even with nothing to delete. While a copy run held the lock, each such partition waited out the lock wait and logged a failure, holding up the rest of the retention tick. List the covered files first and take the lock only when there are some; the per-file checks under the lock stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: drop a topic table view only with the last caller holding it An oversized view was removed while other callers still held it, so the next caller loaded it again alongside; an entry no load filled was removed only by a failing load that was its sole holder, so one whose callers failed or gave up in another order stayed; and eviction that found every candidate held left the cache above its bounds with nothing to evict again. Callers now let go through one release: the last one removes an entry no load filled or one marked to drop, as an oversized view is, and each release runs eviction again. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: check a topic's table again before each covered log the cleanup deletes The cleanup checked the lock, topic.conf and the table once, then deleted every file below the marks it read, so a detach, a dropped or replaced table, or a lapsed lease landing during the deletes went unseen. The deletes now check all three again before each file, with the mark of the table as it is then, and stop at the first file not below it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: let a flushed data source's producer close its own channels Next can return on the query's cancellation while the producer is still sending, and the merge then closes the source, which closed the result and error channels under that send. The producer now owns them: Close only signals it to stop, every send also selects on that signal, and the producer closes the result channel when it exits, after sending its one error if it has one. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: fail a scan whose data source fails after its first row The merge only logged an error from a source past its first row, the query's cancellation included, and returned the rows read so far, so a cancelled or timed-out COUNT or SUM answered with a wrong number. It now closes its sources and returns the error, and the scan wraps it, so a caller can tell the context's error from others. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: check a topic table again before each group retention deletes Retention read a table-backed partition's deletable mark once, chose its expired groups, then deleted them with no further look, as the covered-log delete did before it rechecked; a rollback in between left groups deleted that the table no longer held. The live and retired purges and the covered-log delete now share one guard: it holds the table writer's lock and, before each group or file, reads topic.conf and the table afresh, stopping at the first one not below the mark it finds. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: bound a partition load's reads of what it already stores Loading a partition reads its files' offset range and, for a table-backed topic, the table's, while holding accessLock, under a background context, so a stalled filer or table catalog held every other partition operation for as long as it stalled. The reads now get the bound a load's fence take has; past it the load fails, as it does when the stored offsets cannot be read, and the caller retries. Falling back to the log files' bounds would start the log above the table's offsets with no later refresh to lower it, so consumers resetting to the earliest offset would skip the table's history. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: count a flushed source's pending error as more to read The merge asks HasMore before reading a source again, and HasMore looked only at buffered rows and whether the producer finished, so a producer that failed after its last row and finished before the merge asked had its error never read, and the scan returned the rows so far as its answer. An error waiting counts as more to read now, so Next returns it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: keep the table's files of a topic that left it before the delete A topic that left its table between the listing of what the table held and the guard the delete takes got no guard, which let every listed file go, though readers take those offsets from the logs again. Files chosen by the table's rules, the covered logs and the groups retention trimmed to the table's mark, are now kept when no table remains; files of a topic that had no table when the pass began still expire as before. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: order the pending-error merge test's row before its error The test's producer could send its error before the first Next took the row, and Next then picked either one, so on some runs the error came through the first read and the test passed without exercising HasMore. The producer now holds its error until the first Next has the row, and the merge asks again only after the producer has finished, so the test fails every time without the pending-error fix. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: read a topic table's chunk-backed files under the caller's context A manifest or manifest list stored in chunks was read through a stream reader built without a context, and the stream reader looked up and fetched each chunk under a background context even when built with one, so a stalled volume server held a partition load past its bound while it held accessLock. A chunk stream reader now looks up and fetches its chunks under the context it was built with, and a table's chunk-backed files are read with the caller's. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: keep the expiredLogFiles doc comment on expiredLogFiles Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: let the table catalog read chunk-backed table metadata The broker's table catalog reached its filers through a client with no way to look up chunk locations, so a table whose catalog record holds only the location of its metadata, as one whose metadata outgrew a request does, failed to load once that file was stored in chunks: the topic's history could not be read. The client now resolves chunks the way the broker's own filer client does. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * iceberg: read chunk-backed table metadata under the caller's context A catalog record holding only a metadata location had its chunk-backed file read by StreamContent, whose lookups and fetches run under a background context, so a stalled volume server held a table load past its caller's deadline: a broker loading a table-backed partition under accessLock past its bound. The read now streams under the read's own context, which already bounds its other filer calls. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * filer: give up a LookupFn volume lookup's retries at its caller's deadline LookupFn retried a failed volume lookup through util.Retry, which sleeps its backoff without looking at the caller's context, so a lookup failing near a deadline outlived it by up to the whole backoff; a table load under a broker's accessLock held it that long. The lookup now retries through util.RetryWithBackoff with the same transient-error rule and about the same total wait, which stops when the context is done. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
960230f86d |
mq: keep keyless and valueless messages in compacted parquet (#13258)
* mq: keep keyless and valueless messages in compacted parquet mq.topic.compact treated every message without a key, every message without a value, and every value that happened to parse as a DataMessage with a Ctrl as a control entry, and left it out of the parquet it wrote. Kafka records with a null key and tombstones were gone once retention removed their logs, and so was a JSON string value whose bytes parse that way. The only control entry a log holds is a publisher's close marker, which the broker logged without its Ctrl, as an entry with neither key nor value. That is now the whole rule, for compaction and for reading parquet back. A schematized topic's message without a value is still left out, since its row has no column to hold one. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: ack a publisher's close marker without logging it The marker a publisher sends when it finishes was appended to the partition log like a message, minus its Ctrl, so it took an offset and sat in the log as an entry with neither key nor value that every reader had to recognize and skip. The broker now acks it and moves on. Every message the publisher sent before it on the stream was acked first, so the publisher's wait for its last ack is unchanged. Logs written before still hold markers, which readers keep skipping. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: log a Ctrl message that carries a key or value The close-marker branch dropped every DataMessage with a Ctrl, though one carrying a key or value was published before. Only a bare marker, a Ctrl with neither, is acked without an offset now; anything else is stored at its offset as it was. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query engine: skip only close markers, as compaction does Compaction now keeps keyless messages and values that happen to parse as a DataMessage with a Ctrl, but the SQL engine still dropped both from log scans and live-log counts, while COUNT(*) took parquet row counts from file stats. After compaction COUNT(*) included messages SELECT did not show. Scans and counts now use the same rule as compaction and parquet reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * query engine: leave out a schematized message without a value, as compaction does Compaction writes no row for a schematized message without a value, so a live log count that included one dropped by one once its log was compacted. Scans and live-log counts now skip what compaction skips. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * query engine: count only rows among broker-buffered messages The COUNT(*) fast path added every unflushed broker message, so a close marker or a schematized message without a value counted until its flush, when the live-log count left it out. Unflushed messages now count by the same row rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * query engine: test the broker-buffered count against the scan COUNT(*) adds the broker's unflushed messages by the row rule a scan of them uses, but nothing tested it. The count moves into countRows, and the scan test checks it gives the number of rows the scan returns for a schemaless and a schematized topic, so close markers and schematized messages without a value stay out of both. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
bc1b805c82 |
mq: copy a table-backed topic's sealed log data into its Iceberg table (#13256)
* mq: export logstore's log file offset range and control entry checks The topic table writer decides what is sealed from a partition's file offset ranges and drops the same control entries compaction drops, so it calls these instead of keeping copies. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: tell which of a partition's files its leader will not write again A topic table may only take what is sealed. The fence names a writer and an epoch, not a file, and each flushed window lands whole as a new file under it, so every log file but the one holding the highest offsets is sealed; the newest may still be followed by a window in flight. A sealed fence takes no more windows, so all of its files are. Parquet left by mq.topic.compact rewrites earlier logs and is always sealed. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: keep a topic table's copied offsets in its snapshot summary Each append records seaweedfs.mq.offsets, the first offset of every partition not yet in the table. A snapshot that rewrote files without carrying the map defers to its newest ancestor that has one; a table with snapshots and no map anywhere holds rows of unknown offsets and is not written to. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: build a topic table's rows from log entries A message becomes a row of its table: the system columns from the log entry, then the record's fields by name, or the whole message in _value for a schemaless topic. Rows are laid out in the table's current schema through iceberg-go's Arrow mapping, so the Parquet file they are written as carries the table's field ids and the types Iceberg readers expect. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: compare topic tables by name in topictable The table writer in the worker has to tell whether topic.conf still names the table a job was proposed for, by bucket ARN, namespace and name, the same way the broker compares a configure request with what is stored. The comparison moves next to the rest of the topic table layout so both call it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: keep a topic table's offset map through maintenance snapshots Compaction, delete rewrites and manifest rewrites keep a table's rows, so the offsets a topic table holds are unchanged by them. Their snapshots now carry the parent's seaweedfs.mq.offsets, so the topic writer and readers find the map on the current snapshot rather than only on an ancestor that snapshot expiry may remove. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: start a table's running totals at its first snapshot Totals were only carried from a parent that recorded them, so a table whose first snapshot the worker wrote never got total-records or total-data-files, and no later snapshot could carry them. A snapshot without a parent adds to an empty table, whose totals are zero. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: copy a topic's sealed log data into its Iceberg table copyTopicTable reads each partition from the offset the table's current snapshot records up to what its leader has sealed, through the merged reader that already serves log files and compacted parquet, and writes the rows as data files under data/<_partition>/ named by their offset range. A file holds one partition value, so it never spans partitions or days, and its rows are one contiguous offset run in offset order. The append goes through commitWithRetry and records the advanced offset map in seaweedfs.mq.offsets. Each attempt re-checks that topic.conf still names the table and that the table still names the topic, and re-reads the map: a partition another writer moved since this run planned keeps that writer's offset, and this run's files for it are removed, so no offset is appended twice. A run that dies before its commit leaves only unreferenced files for orphan removal. Log files are left in place; the broker cannot read the table yet. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: run mq_topic_table for topics that name an Iceberg table The worker registers an mq_topic_table job beside iceberg_maintenance and runs it in the Iceberg lane. Detection reads every topic.conf under /topics; a topic naming a table is due once one of its partitions has 128 MiB sealed past the table's offsets or a sealed file 5 minutes old. Execution takes the filer lock mq.table.<namespace>.<topic>, so one writer copies a topic at a time, and copies only while topic.conf still names the table the job was proposed for; a topic that left it ends the job without failing it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: copy only into the table whose UUID topic.conf recorded A table dropped and replaced at the topic's table name still carries the name, and may carry the topic's property if its creator copied it. The broker records the UUID of the table it created or adopted in topic.conf, so the writer checks it before planning and again before each commit attempt, and stops rather than append the topic's offsets to a table that is not the one the topic holds. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: keep keyless and valueless messages in a topic table The table becomes a topic's only copy once copied logs are deleted, and the writer dropped what compaction drops: every message without a key or without a value. Those are data; a Kafka record with a null key is one. The only control entry the log holds is a publisher's close marker, which the broker stores without its Ctrl, as an entry with neither key nor value. IsControlMarker names exactly that, IsControlEntry keeps its wider rule for compaction, and the writer skips markers only. A keyless message gets a null _key. A skipped marker's offset stays below the partition's offset in the map, so the table records it as an offset that held no message rather than a gap left to fill. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: change a topic's table under its table writer's lock A configure that left a table checked it for snapshots, then saved topic.conf. The table writer checks topic.conf before each commit, so a detach saved between that check and the commit's CAS left a table holding the topic's data with no topic. The broker now takes the writer's filer lock, mq.table.<namespace>.<topic>, before the release check and keeps it through the topic.conf save, so it sees what the writer committed, and the writer sees the change before committing. The wait is bounded at 15 seconds: a configure behind a long copy is Unavailable and retried rather than holding the configure RPC. The lock key moves to topictable so the broker and the worker share it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: make a topic table's record columns optional A field's is_required became a required column, so a message missing that field could not be written and the table writer stopped at its offset. Once copied logs are deleted the table is the topic's only copy, so every message needs a row. Record fields now map to optional columns at every level; the system columns stay required. Adopting a table still refuses one whose record columns are required, since it could not take such a message. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: keep a message its topic's record type cannot hold in _value A schematized topic's tombstone, or a value that is not a RecordValue of its type, stopped the table writer at its offset, and once copied logs are deleted the table is the only copy. Every topic table now has an optional _value column. A message whose value is empty, does not parse, carries bytes a RecordValue does not have, names a field the table lacks, or holds a value its column cannot take gets null record columns and its raw bytes in _value. A decoded message leaves _value null. A row is checked whole before any column takes it, so a fallback leaves no partial row behind. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: copy a topic's history into its table in bounded runs A run read every sealed offset past the table's map and committed only at the end, so a topic attached with a long history could not finish within the job's one-hour timeout: each attempt rewrote the same files, removed them on cancel, and the map never moved. A run now stops at a file boundary once it has written 4 GiB and commits the offsets its files cover; the next detection picks up the rest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: decode a record read back from compacted parquet into its columns logstore's parquet reader hands back a schematized row as its RecordValue, which still holds the file's _ts_ns, _key and _offset columns. The row writer took those for fields outside the table, so every message the copy read from mq.topic.compact's parquet landed as raw _value with null record columns. Those three fields are the entry's own and are now passed over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: map a repeated field already typed as a list to one list The Kafka protobuf and JSON Schema decoders describe a repeated field with both a ListType and IsRepeated, and their values are one ListValue deep. mapField wrapped the list type again, so the column became list<list<T>> and every message with a non-empty repeated field fell back to raw _value. Avro gives the item type with IsRepeated, which still gets wrapped once. MQ's own parquet schema already ignores IsRepeated on a list type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: keep a decimal past its column's precision in _value rescaleDecimal checked only that the rescaled value fit 128 bits, so an unscaled value from 10^38 up to 2^127 was written into the decimal(38,18) column, which engines then read as an overflow or null. The value is now checked against the column's precision, so such a message keeps its raw bytes in _value like any other value the record type cannot hold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: bound a published decimal before rescaling it A DecimalValue's scale, precision and bytes come from the publisher, and rescaling to the column built 10^|18-scale| before checking anything, so one message with an extreme scale could hold a worker's CPU and memory on every retry of the copy. A scale or precision beyond the column's 38 digits, or a magnitude longer than 32 bytes, cannot fit decimal(38, 18) and is refused before any arithmetic; the message keeps its row with its bytes in _value like any other value its column cannot take. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: keep a topic table's files when its commit's outcome is unknown A commit whose update of the table entry failed without an answer, a reset connection or a deadline, may still have been applied by the filer. The run then deleted its data files and manifests, and commitWithRetry its new metadata file, leaving a committed snapshot pointing at files that were gone. Such a failure is now errCommitOutcomeUnknown, and commitWithRetry keeps the metadata file for it. The topic table writer reads the table again: a snapshot it built that is in the current lineage is a commit, kept and reported as one. Otherwise, or when the table cannot be read, the files stay for orphan removal, since an update still in flight could land after the read. Only a refused commit, a conflict or a stopped run, deletes them. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: count a partition's rows after its last flush copyPartition returned total and flush() in one statement, and Go does not order reading total against calling flush, so the rows of the last file could be left out of the count. The last flush now runs first. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: report the rows a topic table commit kept A run's rows_written was every row it staged, though a commit attempt drops the files of a partition another writer already moved, and a run that commits nothing reported its staged rows all the same. It is now the record count of the files the committed snapshot added. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: wait for a topic's table writer outside topicConfLock A configure that moved a topic off its table waited up to 15 seconds for the table writer's lock while holding topicConfLock, which every configure, lookup cache miss and rebalance of every topic takes, and a caller that gave up kept waiting. The configure now reads topic.conf first and, when the request moves the topic off the table it names, takes the writer's lock before topicConfLock, the order the writer keeps since it never takes topicConfLock. The wait ends when the caller's context does, and a grant that arrives after that is released. A configure that finds the table changed under topicConfLock without holding the writer's lock is Unavailable and retried. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: bound the topic.conf read a table change starts with The read that decides whether a configure must wait for the table writer runs before topicConfLock, and so before the 30 second bound lockTopicConf puts on calls made under it. A caller without a deadline then hung on a filer that took the read and never answered. The read now gets the same bound of its own, still outside topicConfLock. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: keep what an unanswered maintenance commit may reference Compaction, delete rewrite and manifest rewrite delete everything they wrote when their commit fails. When the failure is an update of the table entry that went unanswered, the filer may have applied it, and the table then points at data files, manifests and a manifest list that were just deleted. Those are now left for orphan removal on errCommitOutcomeUnknown, as the topic table writer already does; conflicts and other definite failures still clean up. Snapshot expiry deletes nothing before its commit succeeds and needed no change. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: test a topic table retry that keeps only one partition's files A run whose commit loses to a writer that copied only one of its partitions keeps the other partition's file. The test checks that the retry reports only that file's rows and that each offset lands once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: wait for the detach's refused lock request in the table lock test A fixed sleep did not show the detach had reached the table lock, so a late goroutine let the lookup pass with nothing waiting. The fake filer now counts refused lock requests and the test waits for the first one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: check the table writer's lock before saving a table change A configure that moves a topic off its table holds the writer's lock from its release check through the topic.conf save, but never looked at it again. A lease that lapsed meanwhile, its renewals failing, may already be the writer's, which can then commit to the table the configure is about to detach. The configure now checks that it still holds the lock right before the save and is Unavailable otherwise. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: check a topic table copy's lock and topic last before committing Each commit attempt checked the lock, topic.conf and the table's owner before writing its manifests and manifest list, and nothing after, so a lease that lapsed or a detach that landed while they were written went unnoticed. The attempt now checks again once they are written, the last step before commitWithRetry saves the metadata file and updates the table pointer. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: read a topic's conf with the topic table job's context The table writer and detection read topic.conf with ReadConfFile, which takes no context, so a filer that took the read and never answered held the job, its worker slot and its renewed table lock, and held up detection, past any cancel. They now read through ReadConfFileWithMetadata with the job's or the detection's context, so a cancelled job ends and lets its lock go. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d6dee41f00 |
ec: do not place shards on a volume server in maintenance mode (#13227)
* master: report a volume server's maintenance mode in DataNodeInfo Planners that work from VolumeList had no way to tell a volume server in maintenance mode from any other, so they kept choosing it as a target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: give a volume server in maintenance mode no free capacity It refuses new data, so EC encode and balance planning must not pick it as a destination; it stays listed so it can still be a source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec_balance: never move shards to a volume server in maintenance mode It refuses every shard copy, and right after an evacuate it is the emptiest server, so the planner kept targeting it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: count no free EC shard slots on a volume server in maintenance mode Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: report the volume server's error when it refuses a shard upload A refused ReceiveFile ends the stream, so Send returns only io.EOF and the job logged "failed to send file content: EOF" instead of the reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: test that a refused shard upload reports the server's error Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: never plan EC shard moves onto a volume server in maintenance mode Zero free slots alone did not keep it out: a shard the planner moves off the node credits a slot back, and a later move could take it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: test that ReceiveFileSendError reports a refusal in the response's Error field Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec_balance: move the maintenance-target test to the end of the file Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
c637d60dfc |
filer.sync: keep an informational replay cursor on the source, and let the log purge honor it (#13176)
* filer.sync: save the sync position on the source filer as a replay cursor The position stays authoritative on the target. The source copy holds the last position the target checkpoint stored (a fresh sync without one holds just before the first event it received) and is rewritten hourly while the sync runs, even when the position does not move. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.sync: do not replicate the sync cursors of the source A target never holds cursors that describe the source's log. A rename into or out of the cursor directory replicates the ordinary side. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * metadata log purge: keep the logs a filer.sync still needs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.sync: describe the sync in its source cursor The source cursor is informational: besides the position it records the source and target filers and paths, exclusions, host, version, when the sync started, whether the position is a target checkpoint, and the processed and failed event times, for display in admin tools. The target checkpoint stays authoritative. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.sync: save the first sync cursor when the first event arrives and retry failed saves A fresh sync only saved its cursor on the next minute tick, and a failed save still pushed the next attempt out by an hour, leaving the purge without a cursor while the sync replayed old log days. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.backup: do not seed the source's sync cursors in the initial snapshot Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * metadata log purge: say that a position not saved for 7 days stops holding the log Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.backup test: lock the recording sink for concurrent snapshot workers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.sync: leave the sync cursors out of the metadata log gap check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
3da9c41404 |
iceberg maintenance: worker setting for the row-group size of compacted files (#13128)
* iceberg maintenance: worker setting for the row-group size of compacted files Compaction takes a compacted file's row-group size from the table property `write.parquet.row-group-size-bytes`, and falls back to Iceberg's default, 128 MB, when the table sets none. Most tables set none, and the default target file size is also around 128 MB, so a compacted file usually comes out as a single row group. A reader's column filter (a time range, an id range) can then skip the whole file or nothing inside it. Setting the property table by table is the only way to change that today. This adds a worker setting, `row_group_size_mb`, that sets the size for tables without the property: - default 0 = Iceberg's 128 MB, so nothing changes unless an operator sets it; - the table property still wins over it, so an engine or a user that chose a size keeps it; - `write.parquet.row-group-limit` (rows) is untouched. For example, `row_group_size_mb = 64` gives about two row groups per 128 MB compacted file. Test: `TestRowGroupSizeWorkerSettingAndTableOverride` (the default is 0, the setting is read, a table without the property gets the worker's size, the property wins). `go vet ./weed/worker/tasks/iceberg` and `go test ./weed/worker/tasks/iceberg` pass; `go build ./weed` builds. * iceberg maintenance: raise the descriptor version with row_group_size_mb The admin keeps a stored descriptor unless the new one's version is not lower. With both at 1, an older worker serving a descriptor refresh during a rolling upgrade replaced the form and row_group_size_mb disappeared. The test fails at version 1. * iceberg maintenance: say row_group_size_mb also caps the spatial row group size Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg maintenance: keep at least one row per row group when a row outgrows the byte size With an explicit row limit the estimate had no floor, so a byte size smaller than one row gave 0, which parquet-go takes as no limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg maintenance: say row_group_size_mb only caps a spatial rewrite's row groups 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> |
||
|
|
81f9231e2f |
iceberg compact: optional spatial clustering of geometry tables (#13135)
* 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> |
||
|
|
bf14326c3c |
iceberg maintenance: apply deletion vectors in compaction; optionally rewrite delete-heavy files (#13131)
* iceberg maintenance: recognise deletion vectors whose format is written in lowercase Iceberg maintenance tells a Puffin deletion vector from a Parquet position-delete file by its `file_format`, compared exactly with iceberg-go's constant `PUFFIN`. DuckDB records the format in lowercase, `puffin` (as it records `parquet`, which compaction already compares without case). Such a vector was never taken for a vector: - the data file it covers was not kept out of compaction bins, and - the vector itself was handed to the Parquet position-delete reader, which cannot read a Puffin file, so compacting any table holding one failed (and the position-delete rewrite tried to read it the same way). The fix adds `isPuffin`, a case-insensitive comparison, and uses it at the four places that compared the format. Test: `TestLowercasePuffinDeletionVector` wraps a deletion-vector entry so its format reads `puffin` (as the Avro reader passes it through) and checks that the data file it covers is excluded and that `collectPositionDeletes` does not try to read the vector. It fails without the change (`dv paths = map[]`). `go vet ./weed/worker/tasks/iceberg` and `go test ./weed/worker/tasks/iceberg` pass; `go build ./weed` builds. * iceberg maintenance: apply deletion vectors in compaction; optionally rewrite delete-heavy files Compaction has no reader for Puffin deletion vectors (DVs), so every data file a vector covers is kept out of compaction for good (`excludeDeletionVectorFiles`). A format-version 3 table that is reloaded with DELETE + INSERT (DuckDB writes a vector hiding all of the old file) keeps the old file and its vector forever, and every reader pays for both. Bins also form only from `min_input_files` small files per partition, so deleted rows never enter the decision. This builds on #13127 (the case-insensitive `puffin` format check); the first commit on this branch is that PR. Changes: - **Vectors are applied.** The vectors of the compaction candidates are read with iceberg-go's `table/dv` (length, magic and CRC checked, and the decoded cardinality checked against the manifest's `record_count`) and joined with the Parquet position deletes the merge already applies. A vector that does not decode keeps its file out of every bin, as before, so a file never merges without its deletes. One Puffin file is read once per run even when it holds several vectors. - **A consumed vector leaves with its data file.** When the snapshot removes a data file, the delete manifests holding its vector are rewritten (that vector `DELETED`, the other entries `EXISTING`); manifests without one are carried as they are. Vectors are matched by the data file they cover, never by the Puffin file path, because one Puffin file may hold the vectors of several data files (Spark writes them that way) and the vectors of files left in place must stay. - **A bin whose deletes leave no row writes no empty file**; its files are just removed. - **New setting `delete_ratio_threshold_percent`** (default 0 = off, so bin selection is unchanged unless set; Iceberg's own `rewrite_data_files` uses 30%). When set, a Parquet file whose vector deletes at least that share of its rows is rewritten in a bin of its own, whatever `min_input_files` says, packed by live bytes up to the target size. A file whose decoded vector deletes exactly positions 0..n-1 is dropped without being read; a manifest count that says "all" with positions that do not is rewritten row by row instead. Only files under the target file size are taken (the merge reads a file whole into memory), except a file dropped unread. - **Detection reads no vector**: a DV's `record_count` is its cardinality, which is all the ratio needs. With `apply_deletes` off, planning ignores vectors (execution skips tables with deletes then). The planning-index cache key includes the ratio. Tests (`deletion_vector_test.go`): - a vector with a lowercase `puffin` format is matched to its data file under either path spelling; - a merge with a vector and a Parquet position delete: every file merges minus its deleted rows, row ids kept, and the delete files leave the table (ratio off); - a reloaded table: the wholly deleted file and its vector are dropped without the file being read (it is not even present), the new file untouched; - ratio past / under / vector not decodable / manifest count says all but positions do not / partly deleted file past the target size left alone; - two vectors in one Puffin file, only one data file compacted: the other file's vector stays; - detection with the ratio on and off. Each was checked red against a mutation of the rule it covers (exact format compare, vectors not applied, vector consumed by Puffin path, size check skipped, whole-file check skipped). `go vet ./weed/worker/tasks/iceberg` and `go test ./weed/worker/tasks/iceberg` pass; `go build ./weed` builds. * iceberg compact: check a deletion vector's blob range without overflow Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg detection: key the cached compaction plan on apply_deletes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg detection: skip a table with deletes while apply_deletes is off Execution already skips it, so detection proposed a job that never ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: a drop-only bin is not held to the sort input cap Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: split delete-heavy bins at the sort input cap The packer counted live bytes only, so two partly deleted files could share a bin the sort input cap then dropped on every run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: compare the delete ratio in whole rows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: merge delete-heavy files in the order of their bounds Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: read only the vectors of files a bin can take Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: pack a vector whose count and positions disagree by its whole size 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> |
||
|
|
347f1cf705 |
deps: bump parquet-go to v0.33.0 (#13130)
* 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>
|
||
|
|
5017a07475 |
iceberg maintenance: whole-pass tests of equality deletes on a partitioned table (#13132)
* iceberg maintenance: whole-pass tests of equality deletes on a partitioned table The equality-delete tests call the pieces (`collectEqualityDeletes`, `eqDeleteGroupsForBin`, `mergeParquetFiles`) one at a time. These run `compactDataFiles` end to end and check what a reader sees after the commit, including the deletes carried for files left uncompacted and the sequence numbers of the merged files. Tests only; no code changes. The table has three partition specs: 0 unpartitioned, and 1 and 2 both `identity(name)` on the same partition field, so only the spec ID tells their deletes apart. It is written as a writer commits it: one snapshot per data sequence number, its manifests carrying the number and their ADDED entries inheriting it. Its equality deletes come in every scope: partition-scoped, global, by another column, and with keys that live in other partitions or specs. Each test reads the table before and after the pass with its own merge-on-read (each delete applies to data files with a lower data sequence number, under an unpartitioned spec or the same spec and partition) and compares the rows. - Every two-file bin compacts, bin-packed and sorted; one partition's single file does not. The live rows are unchanged and the deletes are carried for the file left as it was (a merged file given an input's lower sequence number would lose rows to the carried deletes). - Every file compacts: the rows are unchanged and the deletes leave the table. - An unreadable partition delete fails the pass, names the file, and commits nothing; once the file is back the table reads as before. - A delete under a spec the table does not list fails the pass and commits nothing. Checked red against a mutation of the sequence-number rule (equality deletes applied whatever the sequence numbers): the first two tests fail. `go vet` and `go test ./weed/worker/tasks/iceberg` pass. * iceberg maintenance: whole-pass table snapshot IDs differ from its sequence numbers The fixture gave each commit's snapshot the ID of its data sequence number, so a compaction that read an entry's snapshot ID in place of its sequence number still kept the right rows. The IDs now count down as the sequence numbers count up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg maintenance: a whole-pass name-keyed delete that removes a live row The only name-keyed delete matched no row, so a pass that ignored deletes keyed by name still kept the right rows. u1 now holds a "zz" row that a global name-keyed delete removes. 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> |
||
|
|
a963c1309c |
worker: purge the filer metadata log from a lifecycle job that keeps it past every TTL (#13101)
* worker: share the one-filer-per-store selection with other filer jobs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: add a meta_log_purge job that keeps the log past every TTL The job deletes whole metadata log days once per filer store, keeping every day that the longest filer.conf TTL, the longest S3 lifecycle rule, a registered retention floor or a running replay job's cursor still needs. A floor input that cannot be read stops the run before anything is deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: register meta_log_purge in the lifecycle lane Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * maintenance: stop purging the metadata log from the default scripts The meta_log_purge job now deletes old log days, keeping what TTLs, lifecycle rules and replay jobs still need. fs.log.purge stays for manual use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: let an idle filer_ttl rule's read position release the log filer_ttl no longer needs events up to read_ns, and an idle rule keeps an old ts_ns while read_ns advances, so the floor follows the later of the two. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: cap min_retention_days so a huge value cannot overflow Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: show the min_retention_days limit in the admin form Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: give a registered retention floor the store's filer client A floor that only gets a context cannot tell which cluster or store it answers for, so it cannot ask that cluster's master or read the store's own settings. Pass the filer client the job already holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: keep the log an unfinished lifecycle walk will replay A cold-start or recovery walk that resumes across runs rewinds its shard cursor to the walk's start minus the longest lifecycle TTL once it completes. Until then only its walk checkpoint records that start, so a walk running for more than a day let the purge delete the creation events the rewound replay reads. A checkpoint with buckets done or partly walked now holds the floor at started_ns minus that TTL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: hold the walk start until the checkpoint goes stale A walk clears its checkpoint in finish() before each of its shards saves the rewound cursor, so a purge scan that read the old shard cursor and then the cleared checkpoint saw neither. A cleared checkpoint keeps started_ns, so every live checkpoint now holds the floor at its start minus the longest lifecycle TTL. A finished one stops holding once it has not been saved for cursorStaleAfter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: read walk checkpoints before the shard cursors they rewind A purge scan that read a shard cursor, then a checkpoint that a later walk had already replaced, saw neither the earlier walk's hold nor the rewind its shards saved. A walk replaces its checkpoint only after the previous walk's rewind is on disk, so reading the checkpoints first always sees one of the two. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * lifecycle: save a fresh walk's checkpoint at its first progress A walk that progressed during its first save interval and then stalled for more than a day had no checkpoint on disk, so the metadata log purge saw nothing holding the days its completion replays. A fresh walk now saves on its first finished entry or bucket; a resumed walk already has its record on disk and keeps the interval. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * lifecycle: rewrite an unchanged shard cursor so its mtime stays fresh A shard stuck on RETRY_LATER saved identical bytes each pass, and SaveInsideFiler skips identical content, so the file's mtime aged past the meta log purge's staleness cutoff while the shard still needed it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: keep the log day a reader from the cursor lists first Log files are named for their flush start, so a file from just before midnight holds events after a cursor just past it. The reader backs off one flush interval before choosing its first day; the purge now does too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: stop the meta log purge on an unreadable lifecycle policy LoadCompileInputs reports a bucket whose lifecycle XML does not parse separately from its error, so the purge used the shorter floors and deleted days that bucket's rules may need once the policy is fixed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: read shard cursors with the replay's loader in the meta log purge A shard cursor the replay refuses, such as an empty object, decoded as a zero position and released the purge; it now stops the run instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: saturate the meta log purge's TTL plus a day A lifecycle TTL near the largest duration wrapped negative once a day was added, so the purge fell back to the shorter floors; the walk hold at started_ns minus that TTL likewise dropped below zero and was lost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: leave disabled lifecycle rules out of the meta log purge floor AllActivePriorStates activates every compiled rule, so a disabled rule still held the log for its TTL, and disabling it could not release it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: compute the meta log purge floor in SafeKeepFrom Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: fs.log.purge keeps the logs the meta log purge floor needs unless -force Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: run the fs.log.purge floor test without a master client Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
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> |
||
|
|
a9fda6b50f |
filer clients: authenticate filer gRPC calls with per-call admin tokens (#13039)
* Add per-call filer authentication sources and pooled client wrappers * Authenticate gateway filer calls with per-call admin tokens * Authenticate shell admin and synchronization filer calls * Authenticate workers MQ and remaining filer client paths * Cache filer client signing keys and sign subscriptions with the shared key Re-reading security.toml on every filer RPC cost about 125us against 8us for signing. Keep the keys for up to a second, re-reading at once when a WEED_ override or the configuration directory changes. When the file exists but cannot be read, keep the last keys read, else the startup keys, as FilerAdminKeys does, so a process without a key stays tokenless. Metadata subscriptions prefer the shared key, as filer peers do, because older filers verify subscription admin tokens only with it. * Authenticate admin-script, maintenance and filer.conf shell paths Plugin worker admin scripts and master maintenance scripts build their own shell options and carried no filer token source; fs.configure and s3.bucket.quota.check read filer.conf without it. * filer.cat: report a failed read; isolate key overrides in the admin-script test filer.cat ignored the error from its filer call and exited successfully, leaving a truncated -output file. Report the error and exit with failure. The admin-script token test now clears the WEED_ signing-key overrides, which take precedence over security.toml. * security: refuse gRPC keys too short to sign; query engine uses client TLS Under GODEBUG=fips140=only, hmac.New panics on keys under 14 bytes. The startup check now covers jwt.filer_signing.grpc_key and grpc_previous_key, and filer client token sources check the keys they read, so a reloaded or per-endpoint security file with a short key is refused instead of panicking when the next RPC signs. The query engine's broker client dialed every master, filer and broker in plaintext, so the admin token it now sends could cross the network in the clear. It dials with the grpc.client TLS settings instead, and weed-sql loads security.toml as weed-db does. * security: per-endpoint admin tokens ignore WEED_ key overrides FilerAdminTokenFromFile honored WEED_JWT_FILER_SIGNING_GRPC_KEY and WEED_JWT_FILER_SIGNING_KEY. Those are process-wide, so filer.sync with -a.security and -b.security signed both clusters' admin tokens with the one key, handing each cluster a token valid on the other. A per-endpoint file now supplies its own keys only. * weed-sql, weed-db: refuse to start on an unreadable security.toml Both only warned when security.toml was present but could not be read or parsed. They then dialed without the grpc.client TLS settings while the filer token source could still sign admin tokens from WEED_ environment keys, so the tokens could travel in plaintext. They now exit with an error that does not quote the file; a missing file is still fine. * pb: take the filer token source in WithGrpcFilerClient and WithOneOfGrpcFilerClients Fold WithGrpcFilerClientAuth and WithOneOfGrpcFilerClientsAuth into the existing helpers instead of keeping two names for each. Callers without a token source pass nil. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: return the read error from ReadConfiguration Fold ReadConfigurationWithError into ReadConfiguration. The error is returned and not logged, since parser errors can quote values; the existing reload callers already warn when no file was read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: keep the test-only filerAdminToken helper in the test It had no production caller. The test helper now resolves keys through filerClientKeysFrom, as the token sources do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: read security.toml once in LoadSecurityConfigurationOrError It validated the file, then merged it with a second read whose failure was ignored and whose parser error was logged. It now merges with one read and logs nothing from the parser. Viper's search also treats a directory the process cannot search as holding no file; a candidate that cannot be checked for lack of permission is now refused too. * security: verify admin subscription tokens with the gRPC clock leeway CheckGrpcMetadataSubscription checked admin tokens strictly, while unary filer calls allow jwt.filer_signing.clock_leeway_seconds. With ten-second client admin tokens, a subscriber whose clock trailed the filer's by more than ten seconds was refused with a matching key. It now takes the leeway, and the filer passes its configured one. The leeway check moves from the server package to security.IsFilerAdminTokenWithLeeway so both use it. * util: start without security.toml only when every candidate is confirmed absent A candidate whose check fails for any reason other than not existing, such as a symlink loop, is refused like one the process cannot search. --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
e01133bfa3 |
ec_balance: keep node addresses out of the task ID so tasks can be persisted (#13062)
* ec_balance: keep node addresses out of the task ID The ID embedded both host:port node addresses, and the admin's task persistence rejects any ID containing ':', so every ec_balance task failed to save on each state change and lived only in memory. The volume, shard, timestamp and index already make the ID unique; the nodes stay in the task's Reason and params. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: test that a detected ec_balance task saves and loads Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
9ffb5fe185 |
filer, s3, filer.sync: one digest per cluster, set by the filer's -digest and followed by its clients (#12913)
* util, filer: choose the digest at filer startup with -digest
NewMd5 and NewSha1 returned SHA-256 cut to size whenever the process ran
under GODEBUG=fips140=only, so the kind of digest a cluster stores followed
each process's own environment. They now follow a digest mode set once at
startup: util.SetDigest("md5"|"sha256"), or "" to keep following
fips140.Enforced(). The default is unchanged.
weed filer -digest, weed server -filer.digest and weed mini -filer.digest
set it; fips140=only refuses md5 at startup. The leveldb2/leveldb3
directory-key marker follows the mode, as do the places that compare a
NewMd5 digest with Content-MD5 or pass it on as one: S3 PutObject, filer
HTTP uploads, the Content-MD5 the filer returns, and the uploader's
Content-MD5 to volume servers. Places that verify Content-MD5 with a real
MD5 (volume servers, S3 request bodies and archive uploads) keep keying on
fips140.Enforced(), since they can check it whenever MD5 is available.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer, command: report the filer's digest and make its clients use it
GetFilerConfigurationResponse carries the filer's digest mode in a new
field 16, digest. weed s3, mount, webdav, sftp, iam and filer.copy adopt
it before they serve or write, so a gateway started with a different
GODEBUG writes the same kind of ETag and chunk digest as the rest of the
cluster. A process under fips140=only refuses a filer that reports md5. A
filer that reports no digest predates the field; the client then keeps
its own mode and logs a warning.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.sync, s3 sink: keep digests within one kind
filer.sync copies entry digests and ETags as they are, so syncing a filer
with digest sha256 into one with md5 left SHA-256 ETags in the md5
cluster. It now reads both filers' digests and refuses to start when they
differ, with a warning when either filer does not report one.
The S3 sink sent the entry digest as Content-MD5 unless its own process
ran under fips140=only. From a sha256 source into a target that checks
Content-MD5 every single-part upload failed with BadDigest and the backup
retried it forever. It now asks the source filer for its digest once and
forwards the entry digest only when that is md5.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.meta.backup, filer.backup, filer.replicate: keep digests within one kind
filer.meta.backup opened its backup store in its own digest mode, so a copy
of a sha256 filer made by a process outside fips140=only got MD5 directory
keys and could not be opened as that filer's store. It now adopts the source
filer's digest before the store opens.
filer.backup and filer.replicate with a filer sink copied entry digests into
the target filer without comparing digests, as filer.sync did before. Both
now refuse, and exit, when the source and target filers report different
digests. replication.CheckDigestsMatch is the shared check; filer.sync uses
it too.
weed server and weed mini apply -filer.digest before they start the master
and volume server, so every part of the process hashes with one digest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer, filer.sync: refuse a peer filer with another digest; exit on mismatch
Filers peering through the meta aggregator now compare digests. A peer with
a store of its own would replay entries holding the other kind of digest
into this filer's store, so its changes are refused and the reason logged
on every reconnect. A fresh filer bootstrapping from such a peer refuses the
copy, so a new filer whose digest differs from the existing filers' exits at
startup. A peer on the same store writes into it directly, and refusing its
stream would only starve this filer's subscribers, so that mismatch is
logged as an error and the stream kept.
filer.sync exits with status 1 when the two filers use different digests,
as filer.backup and filer.replicate do: it is a configuration error a
restart cannot fix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: -digest help says a store keeps the digest it was created with
The help text said existing data keeps the digest it was written with,
which reads as if the flag could be changed on a store with data. Stores
that hash keys stop finding existing entries under another digest, so the
text now says to set it when the store is created, and that switching means
copying the metadata into a new store with fs.meta.save and fs.meta.load.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer, s3, replication, admin, iceberg: address review of the digest checks
- A filer checks its peers' digests on every start, not only at the fresh-store
bootstrap: the store signature is written when the store opens, so a fresh
filer refused at bootstrap restarted as an initialized store and served
without its peers' files.
- Under digest sha256 with MD5 available (not fips140=only), a client's
Content-MD5 is checked against a separate real MD5 of the body, in S3 object,
part and directory-marker uploads and in filer HTTP uploads. It goes
unchecked only when no MD5 can be computed.
- filer.backup and filer.replicate exit only on a DigestMismatchError; a filer
that cannot be reached is retried, so a backup started before its target is
up resumes once the target answers.
- The admin file browser and Iceberg compaction write chunks into a filer they
do not follow at process level. They read that filer's digest and pass it to
the chunk upload (ChunkedUploadOption.Digest), so their content and chunk
digests match the filer's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer, s3 sink: retire digest-refused peers; no Content-MD5 for an unknown digest
- A peer refused for its digest counts as unreachable: the check now runs
before notePeerReachable and its error wraps errPeerUnreachable, so the
subscribe loop retires the peer from the low watermarks after the usual
grace instead of keeping its zero watermark, which held every aggregated
subscriber at the settled horizon.
- When the source filer's digest cannot be read, the S3 sink no longer sends
the entry digest as Content-MD5: it may be a SHA-256 digest the target
would reject.
- TestCheckPeerDigest skips the cases that need MD5 locally under
GODEBUG=fips140=only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg, util: tests for the per-filer digest
The Iceberg tests' fake filer serves GetFilerConfiguration, which uploads now
call to read the target filer's digest; it reports none, as a filer that
predates the setting does. TestNewContentMd5 computes a real MD5, so it skips
under GODEBUG=fips140=only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: bound each startup peer digest read with a timeout
CheckPeerDigests read each peer's configuration with the caller's context,
which at startup has no deadline, so a peer that accepted the connection but
never answered held the filer's startup. Each read now has its own
peerDigestReadTimeout (10s, inside the one-minute announce cap), after which
the peer is logged and skipped like an unreachable one.
setDigestForTest restores the previous digest setting instead of the default.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util, s3, filer: one-shot digests for data held in memory
Md5For hashes with md5.Sum or sha256.Sum256 instead of writing into a
hash.Hash, and the Content-MD5 checks of S3 directory markers and of filer
uploads saved inside the filer use BodyMd5Of on the bytes they already hold.
Streaming uploads keep their io.TeeReader.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: hash Content-MD5 on the upload's digest hash, not on its body
teeContentMd5 wrapped the request body in a TeeReader before
uploadRequestToChunks. CodeQL's go/reflected-xss query follows the body
from r.Body through the chunk upload to upload_content.go's
w.Write(prepared.data), which it resolves to the response-writer
wrappers in s3vectors, s3tables, webdav and server/common.go. Those
flows exist on master from other sources (extract, tagging, the
multipart POST); the wrapped body put them through lines this PR
changed, so CodeQL reported six of them as new.
newUploadHash now builds the digest hash that uploadReaderToChunks and
the inline-append paths already tee the body into, and adds the
separate MD5 there; uploadBodyMd5 reads it back for the check. The body
reaches uploadRequestToChunks as on master. Behaviour is unchanged:
under digest sha256 with MD5 available, Content-MD5 is checked against
the body's MD5, including empty and inline appends.
Checked with CodeQL 2.27.6 (go-queries 1.6.16, ReflectedXss.ql) on this
tree: no flow of the nine reflected-XSS results passes a changed line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* replication: keep the ReadFilerSignature name and return the digest with it
Renaming it to ReadFilerSignatureAndDigest left its other callers with an
undefined function. Keep the name and add the digest to what it returns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: keep HashToInt32 off the digest mode
HashToInt32 names things that processes derive on their own, such as a
mount's local socket path and MQ partition key hashes. weed mount adopts
a -digest=sha256 filer's digest before it names its socket, while
weed shell mount.configure keeps md5 and dialed a different socket.
Follow GODEBUG only, as before the digest setting.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.meta.backup: wait for the source filer's digest instead of exiting
A backup with a saved offset used to start its stream loop and retry
until the source filer answered. Reading the digest first made it exit
when started before the filer. Retry the read; exit only when the
digest is refused.
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>
|
||
|
|
64a64ca75b |
volume, seaweed-volume: an EC shard copy can require a disk type (#12901)
* volume_server.proto: let an EC shard copy name the target disk type Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: an EC shard copy that names a disk type lands only on that medium With disk_id 0 the copy auto-selects a disk, and the disk that already holds the volume or its index wins regardless of medium. A move onto an empty disk of another medium therefore landed beside the existing copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: EC shard moves pass the target disk type to the copy ec.balance and the ec_balance worker plan a move onto disks of one type, but the copy only named a disk id, and the master reports 0 (auto-select) for a disk that holds nothing yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-volume: an EC shard copy that names a disk type lands only on that medium Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: an EC blob delete records on every local copy of the volume A volume mounted on several disks of one server has one runtime per disk, each with its own deletion set, and a shard read checks the runtime of the disk holding the shard. The delete stopped at the first runtime, so a read of a shard on another disk still returned the deleted needle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-volume: an EC blob delete records on every local copy of the volume Mirrors the Go handler: each disk's runtime of the volume keeps its own deletion set, so the delete is journaled on every runtime, not the first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: a typed EC shard copy yields to the shard's file on another medium The mount walks disks in order and loads the first file of the shard it finds, so a copy placed on the requested medium while another disk still holds an unmounted file of that shard could leave the old file mounted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-volume: a typed EC shard copy yields to the shard's file on another medium Mirrors the Go selector. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: a typed shard move refused by its pinned disk lets the server pick Balancers pin the destination disk from the medium its mounted shards report, which can differ from the disk's own medium after encoding spilled onto another one. The server refuses such a disk before copying anything, so the move now retries once with the server picking a disk of the type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-volume: name the requested disk type in a pinned-disk refusal Same wording as the Go server, which movers match to retry with a server-picked disk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: an EC blob delete records on the first local copy last A retry on this server resolves the volume through its first copy, so a delete that fails on another copy left the first one tombstoned and the retry stopped there. Locate the needle on every copy first, then journal the others before the first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-volume: an EC blob delete records on the first local copy last Mirrors the Go handler: a retry on this server resolves the volume through its first runtime, so that runtime journals after the others and a failure on any other leaves it live for the retry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-volume: a local EC delete records on every local copy When this server holds the shard, the distributed delete journals locally instead of calling VolumeEcBlobDelete on itself, and that path journaled only the first runtime. Record on every runtime, the first last, as the handler does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
2037af1a37 |
erasure_coding: report and check the encode run when verifying a shard set (#12893)
* volume: report the encode run in VolumeEcShardsInfo Go and Rust volume servers now fill EcShardConfig.encode_ts_ns from the mounted EC volume's .vif, next to the block layout they already report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * erasure_coding: keep the source when holders serve different encode runs VerifyShardsAcrossServers records each holder's encode run, and RequireAgreedEncodeRun fails when holders that report one disagree. The encoder checks it before deleting the source volume, so a shard set that only looks complete by shard ids does not replace the source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * erasure_coding: refuse a holder that reports more than one encode run A holder whose disks serve shards of different encode runs reports MixedEncodeRuns, and RequireAgreedEncodeRun fails on it even when no other holder answers or every other holder agrees on one run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: report mixed encode runs across local disks in VolumeEcShardsInfo The reply listed shards from every disk under the first disk's encode run. When the shard-bearing disks of a volume hold different nonzero runs, Go and Rust volume servers now report MixedEncodeRuns instead, so the source-deletion check sees the conflict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: refuse an EC shard copy of another encode run than the mounted one VolumeEcShardsCopy committed the copied .vif and reopened replaced shards without updating the mounted volume's encode run, so the holder kept reporting the old run while serving the new bytes. Go and Rust volume servers now stage the .vif before anything is committed and fail with FailedPrecondition when it names a nonzero run different from a run this server mounts for the volume. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: list only mounted shards of every disk in Rust VolumeEcShardsInfo The Rust reply listed every shard slot of the first disk's runtime, with unmounted slots as size-0 entries, and skipped shards mounted on other disks. Callers build each holder's shard bits from this list, so a Rust holder counted as holding shards it did not have. The reply now lists the mounted shards of every local disk, each id once, as Go does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: check the source encode run of an EC shard copy without a .vif A copy that leaves out the .vif could still replace a mounted shard with another encode run's bytes. Fetch the source .vif for the run check in every copy, and install it only when asked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: refuse to serve EC files of a volume held from two encode runs CopyFile looks each requested file up on its own, so a server that holds a volume's shards on one disk from one encode run and its .vif on another disk from a different run would hand a copier mismatched files. Refuse the copy when the .vif files of this server disagree on a nonzero run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: refuse a rebuild whose holders serve different encode runs The rebuild groups holders by volume id and collection only. When they serve two encode runs, the copied shards land beside the first run's .vif and .ecx and the rebuild regenerates from the mixed set. Before copying, ask every holder for its run and refuse unless they agree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: bound each holder query in the rebuild's encode-run check A holder that accepts the connection but never answers VolumeEcShardsInfo kept the rebuild waiting forever. Give each holder its own deadline; one that times out is skipped like an unreachable holder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: check only the rebuilder and copy sources for the encode run The rebuild copies each shard from its first listed holder. Extra copies are never read, so asking them for their run only adds servers that can stall the check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: do not copy from a source whose encode run went unchecked A copy source whose VolumeEcShardsInfo query fails or times out has an unknown run. The copy fence on the rebuilder compares a source's run with the run the rebuilder mounts, so on a rebuilder that holds none of the volume's shards nothing checks it, and its shards could join a rebuild of another run. The rebuild now skips such a source like a failed copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: leave holders of shards the rebuilder has out of the run check The rebuild uses a shard the rebuilder already holds and never reads its other listed holders, but the run check still asked the first of them. A stale replica listed first for such a shard refused a rebuild that would not touch it. Pick the holders to check the way prepareDataToRecover picks its copy sources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
ec87407c0d |
ec balance: don't let leftover shards of an earlier encode win dedup or move (#12888)
* ecbalancer: keep the majority encode run's copy when removing a duplicate shard The dedup kept the copy on the node with the most free slots without comparing copies. When a failed encode left a shard behind and a retry encoded it again elsewhere, it could keep the stale copy and delete the fresh one. Nodes now record each disk's encode identity; when a shard's copies differ, only a copy from the run that holds most of the volume's shards is kept, and the shard is left alone when no run has a clear majority or none of its copies is from that run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec.balance, ec_balance: pass each disk's encode identity to the planner Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ecbalancer: keep only a complete encode run's copy, freeze conflicted volumes A majority counted over a filtered snapshot can pick the wrong run, and a shard left with conflicting copies could still be moved onto its other copy by a later phase. Mixed-run duplicates are now resolved only in favour of the one reported run that has every shard id, counted per disk, since filters can hide shards but not add them. Otherwise the volume is frozen: no phase of this plan moves its shards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec_balance: freeze EC volumes that still have a plain replica Their shards belong to the encoder until the plain replicas are gone. They stay in the plan's load counts but no phase moves or dedups them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ecbalancer: refuse dedup when an unreported run is also complete A copy that carries no encode identity may be the newer set, so a second complete run that does report one cannot be kept over it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ecbalancer: freeze a volume whose shard copies on one node disagree A shard held on two disks of one node at different encode runs has no duplicate on another node, so dedup skipped it, and a later move could take the stale copy and delete the fresh one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f3b838e234 |
ec: encode past deletes a replica missed while it was down (#12879)
* volume_replica: encode past deletes a replica missed A delete that reaches only some replicas, for example while one is down, leaves that replica holding the needle live. The encoder's idx gate then refused the volume forever. A needle live on one replica and tombstoned on another by a record appended after that write is a delete the first replica missed. MissedDeletes finds them; the gate leaves them out of the live-set comparison and encodes from a replica that holds none of them, so the EC volume does not bring them back. A tombstone older than the live write, a needle absent on the other side, and volumes without AppendAtNs still refuse, as does a volume where every replica missed some delete. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * erasure_coding: test encoding a volume one replica missed a delete on Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume_replica: prove a missed delete from one replica's own index AppendAtNs comes from each server's own clock, and vacuum's makeupDiff re-stamps tombstones it carries over with the commit time, so comparing a tombstone's AppendAtNs against another replica's write can order a later rewrite before an older delete. Prove the delete instead from the replica that applied it: its .idx shows the live row the tombstone replaced, and when that record has the same cookie, CRC and last-modified time as the needle still live on the other replica, that very write was deleted. Replicated writes share all three, a rewrite does not. A tombstone with no earlier write row (its write vacuumed away) proves nothing and still refuses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume_replica: test a missed delete with a third replica holding no row Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume_replica: never count a needle its own replica deleted as missed A same-content upload with the same ts after both replicas deleted the needle matches the deleted write on cookie, CRC and last-modified. The replica holding it has its own tombstone for the needle before that live row, which a replica that missed the delete never has, so skip it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume_replica: count a missed delete only for a needle written once An overwrite that keeps cookie, CRC and last-modified, such as a TTL volume re-append or a client-set ts, also matches the write another replica deleted. A replica whose own index replaced an earlier row for the needle, by an overwrite or by its own delete, may hold a write made after that delete, so it never counts as having missed it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: compare capacity replicas first so a clean one is the encode source When the preferred replica missed a delete, the gate falls back to the first replica that holds none, and that could be one without the free slots RequireCapacitySource needs, failing the encode although another capacity replica was clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume_replica: keep the row an offset-0 delete removes as an earlier write A remote-tier delete writes an offset-0 row and drops the key, so a later identical rewrite looked written once and could count as a missed delete. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume_replica: refuse a missed delete whose live write is not older than the tombstone Compaction keeps only the latest row per needle, so a same-meta rewrite after the delete can lose the earlier row that marked it as rewritten. Its record still carries its own append time, which then is not older than the tombstone. The index proof still decides; the clocks only refuse. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume_replica: count a missed delete only when both replicas appended the write together Compaction can drop the rows that show a replica rewrote a needle, and the tombstone stamp is not a reliable delete time: a vacuum commit stamps deletes made during the copy with the commit time, and replicas stamp with their own clocks. A replicated write lands on every replica within the forwarding time plus clock skew, so the live write and the deleted write must also be stamped within a minute of each other. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
3796162ba6 |
erasure_coding: clear stale EC shards on every holder the master lists (#12876)
* plugin/worker: look up a volume's EC shard holders on the master LookupEcVolumeLocations returns every server the master currently lists for any shard of the volume. The master's "ec volume N not found" answer means no holders; any other failure is returned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * erasure_coding: clear stale EC shards on every holder the master lists The encode preflight and the post-distribute rollback cleared stale shards only on the planned targets and on the EC holders detection saw. A server that was down at detection and came back with a failed attempt's shards was outside both, so its shards survived and ended up beside the new encode: EC balance could later keep that stale copy as a duplicate. The cleanup now also asks the master for the volume's current holders and clears every one of them. A lookup failure counts as a cleanup failure, so the preflight retries later instead of encoding beside shards it cannot see. Without a master address the cleanup behaves as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * erasure_coding: ask every master for the EC shard holders The execution defaults keep only the first master address, so a follower there failed every holder lookup and with it the encode preflight. The plugin handler now hands the task the whole cluster master list, and the lookup moves on past a master that refuses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * erasure_coding: refuse the preflight wipe when a regular replica is gone A replayed job whose earlier run already committed the EC copy and deleted the source would wipe those shards, now on every holder the master lists, before failing on the missing source. Check that every regular replica is still there before clearing anything. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
862913d199 |
volume, ec_balance: clean up failed EC shard copies; stop re-proposing empty-index volumes (#12718)
* volume: remove files a failed VolumeEcShardsCopy wrote The shard files were copied before the .ecx, so a source holding a 0-byte index failed the request only after its shards had landed, and nothing removed them: every retried move stranded another unmounted shard on a new disk. Copy the .ecx first, staged beside its target, so a bad index fails before any shard lands; rename it into place only after the shards and sidecars have copied, so a failed copy never truncates or replaces an .ecx the destination already has. On any error, remove exactly the files this call created; files already on the disk (an existing holder's shards, index or journal) are left alone. Go and Rust volume servers behave the same. Claude-Session: https://claude.ai/code/session_011UpvafcfUuC2mLxNAXLQJi * ec_balance: skip EC volumes whose every holder reports an empty .ecx A shard copy refuses a 0-byte .ecx, so detection proposed the same failing move of such a volume every cycle. Leave volumes with no holder reporting a needle out of planning; their shards still count toward disk occupancy. Claude-Session: https://claude.ai/code/session_011UpvafcfUuC2mLxNAXLQJi * volume: serialize VolumeEcShardsCopy per volume Overlapping copies of one vid shared the staged .ecx, and a failed copy's cleanup removed shards that a concurrent copy had already committed and mounted. Hold a per-vid EC lifecycle lock across the whole copy and its cleanup, named as in the enterprise build (Store.EcLifecycleLock / ec_lifecycle_lock). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: overwrite an existing .ecx in place when committing a copied index A mounted EcVolume reads its index through an open handle, so renaming the staged copy over it left the reader on the replaced inode: tombstones the source had folded into its .ecx never reached the mounted holder. An index already on the disk is now overwritten in place, as before the staging change; a fresh destination still gets the rename. Go and Rust. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: stage replacements of shards a VolumeEcShardsCopy finds on disk The shard transfer opened an existing destination shard with O_TRUNC and removed it on a stream or write error, so a failed retry deleted a shard this disk already held. A shard already present is now copied to <shard>.copying and renamed into place only after every other file has copied; a mounted copy is reopened so it serves the new file. Fresh shards still write in place and are removed on failure. Go and Rust. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: stage the .vif and .ecsum a VolumeEcShardsCopy brings until commit The sidecars landed as soon as they transferred, ahead of the deferred .ecx commit, so a failure after them left a new .vif beside the index the failed copy kept. They are now staged as .copying and renamed into place with the shards and index once every transfer has succeeded; a source without one still stages nothing. Go and Rust. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: run a Rust VolumeEcShardsCopy to completion when its caller goes away tonic drops a cancelled handler future at its current await, which released the EC lifecycle lock while file operations the copy had started (a cleanup remove_file on the blocking pool, a create or rename) could still land; a retry taking the lock could then lose its files to them. The copy now runs in a spawned task that owns the lock, as Go's handler runs to completion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: fail the sidecar copy tests with an unreadable source .ecsum A directory at the source path reads as "not found" on volume servers that skip non-regular EC files, which turned the failure into a no-op. A mode-000 file fails the transfer on every implementation; root and Windows, which can read it, skip the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: copy each shard a VolumeEcShardsCopy lists once A shard listed twice and already held here was staged twice; the first commit rename consumed the staged file, so the second failed the request after the shard was replaced, and every retry failed the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: wait out an in-flight VolumeEcShardsCopy before mounting its shards A shard the copy had already landed could be mounted while the copy was still running; the copy's failure cleanup then removed the file but left the shard registered and announced. MountEcShards takes the per-volume lifecycle lock, as the enterprise build already does, and the Rust mount handler takes the same lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: fail a VolumeEcShardsCopy whose replaced mounted shard cannot be reopened The copy reported success while the mounted shard kept serving the replaced file. The error lets the caller retry the copy instead of treating the shard as delivered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: check which transfer fails in the EC copy cleanup tests An earlier failure, before any shard or sidecar landed, would leave the destination unchanged and pass every assertion without exercising the cleanup. The sidecar test also skips on Windows, where a mode-000 file stays readable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: fail the sidecar transfer in the EC copy test by injection A mode-000 file is still readable to root and on Windows, so the test skipped there. The source now returns an error for the .ecsum request only, and the test checks that it served .vif before that failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: take the EC lifecycle lock for a blanket full teardown A teardown acknowledged while a detached copy of the same volume was still waiting on its source let that copy recreate the index and shards afterwards. Go and Rust now wait for the copy, as the enterprise build does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: keep the request id on a Rust EC shard copy The copy now runs in a spawned task, outside the gRPC layer's request id scope, so its CopyFile calls to the source went out with a new id. Carry the caller's id into the task. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: unmount a replaced EC shard whose reopen fails The failed copy left the mount reading the replaced file's inode, so the destination kept serving the old shard. Unmount it, which also reports the removal to the master, so a retry copies and mounts it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: make the Rust EC copy tests fail for the right reason The sidecar test now serves a directory as the source .ecsum, which root cannot read either, so it no longer returns early there. The cancel test holds the store until the handler's join reports the cancellation, so a copy that finished before the abort can no longer pass it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: stage every shard a VolumeEcShardsCopy transfers A shard missing here was written in place with a cleanup guard armed before its transfer started, so a failed copy removed a shard that ReceiveFile wrote meanwhile. Every shard is now staged, and only one that did not exist when it is moved into place is removed on failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: take the EC lifecycle lock for VolumeEcShardsRebuild A rebuild folds the deletion journal into .ecx. Run during a copy of the same volume, the copy's index then replaced the folded tombstones. Go and Rust take the lock the enterprise build already takes here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: check the staged .vif bytes in the EC sidecar failure test A source without the optional .vif also returns success, so the served extension list could not prove the transfer. The test now reads the staged .vif when the .ecsum request fails and compares it with the source's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: unmount a failed reopen's shard on the copy's disk only UnmountEcShards walks every disk, so a reopen failure on the destination also unmounted a healthy copy of the same shard on a sibling disk. The copy now unloads the shard from its own disk and reports that disk's removal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: take the EC lifecycle lock for an ordinary EC shard delete Shards a copy has staged are invisible to the delete's last-shard check, so deleting the only canonical shard removed the index the copy was about to commit its shards against. Go and Rust deletes now wait for an in-flight copy of the same volume. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: leave a mounted shard's copied file in place on copy failure A shard mounted on the copy's disk whose file was missing got the copied file reopened into its mount, then that file was unlinked by a later failure's cleanup while the mount kept serving it. Only an unmounted shard's new file is removed now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: skip repeated shard ids with a seen set Scanning the request prefix for each id made a request with many repeats quadratic while the copy held the volume's lifecycle lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: make the Go EC copy and lock tests observe their effects The fake source counts requests per extension, so the duplicate-id test proves .ec05 is fetched once, and returns fixture errors instead of failing the test from its handler goroutine. The staged .vif reaches the test through a channel. The mount and teardown lock tests seed real files and check that nothing happened while the lock was held and that the operation took effect after it was released. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: poll the handler directly in the Rust EC lifecycle lock tests A spawned handler that had not run when the 200 ms timer fired passed the blocking check without ever reaching the lock. The tests now poll the pinned handler future themselves, which guarantees it is waiting on the lock, and cover the ordinary shard delete as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: observe the lifecycle-lock waiter in EC copy lock tests The mount, teardown, shard-delete and rebuild tests slept 200 ms while holding the lock, so a handler scheduled only after the unlock passed without ever taking it. Wait until the handler's goroutine is blocked on the mutex instead; each test now fails within its timeout if the handler skips the lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: check the shard is staged before the failure-path write in a copy test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: recover a missing EC index under the volume's lifecycle lock Missing-index recovery fetched the index and then ran a store-wide mount of every orphan shard, without the per-volume lifecycle lock. It could mount shards an in-flight VolumeEcShardsCopy of another volume had just renamed in, and that copy's failure cleanup then unlinked a mounted shard. Each recovered volume now holds its lifecycle lock across a re-check, the fetch and a mount restricted to that volume. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): recover a missing EC index under the volume's lifecycle lock Mirror of the Go change: recover_missing_ec_indexes takes the volume's ec_lifecycle_lock, re-checks that the index is still missing, fetches it, and mounts only that volume's shards through mount_recovered_ec_shards_only, so an in-flight VolumeEcShardsCopy of another volume never has its renamed-in shards mounted from under it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: mount a volume whose index a copy installed during recovery Recovery re-checks under the lifecycle lock that the index is still missing. When a copy installed it in the meantime, the re-check skipped the mount too, and the volume's other shards stayed unmounted because later scans no longer list it. Skip only the fetch and still mount the volume's orphan shards under the lock, in Go and Rust. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: fetch a recovered EC index into the disk the locked re-check found The re-check under the lifecycle lock only kept a yes/no answer, so the fetch still wrote to the destination from the first scan, which may be a disk that has since gone away. Fetch into the record the re-check returned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: mount a copy-installed EC index even when no peer is known Recovery skipped the locked step when the master was unreachable, the lookup failed or no peer was listed. A copy that installed the index after discovery then left the volume's other shards unmounted, and later scans no longer list it. Always run the locked re-check, and give up for lack of peers only when the index is still missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: grow the stack buffer before scanning for a lock waiter A full buffer can cut off the handler goroutine's stack, so the test would report a handler that is waiting as one that never waited. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): fetch a recovered EC index into the disk the locked re-check found Mirror of the Go change: fetch into the record the re-check under the lifecycle lock returned instead of the destination from the first scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): mount a copy-installed EC index even when no peer is known Mirror of the Go change: a failed lookup or an empty peer list no longer skips the locked re-check, so a volume whose index a copy installed after discovery still gets its orphan shards mounted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): run missing-index recovery to completion when the mount RPC is cancelled Dropping the mount handler mid-recovery released the volume's lifecycle lock while the .ecj merge it had started on a blocking thread was still landing, so a teardown could remove the volume before that late write. Run recovery on its own task, as the copy handler does, so the lock is held until it finishes; Go's handler already runs it to completion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: skip other volumes before stat in a single-volume EC scan Recovery re-checks and mounts each volume with its own scans, so a request with many orphans repeated whole-store discovery once per volume. The index-owner and orphan-shard scans now take the same volume filter and drop other volumes' files by name, before the per-file stat, and the locked re-check scans only its own volume. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): skip other volumes before stat in a single-volume EC scan Mirror of the Go change: the index-owner and orphan-shard scans take the volume filter and drop other volumes' files by name before the per-file stat, so recovery's per-volume re-check and mount no longer repeat whole-store discovery under the store lock for every orphan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): announce shards recovered after the mount RPC was cancelled Recovery now outlives a cancelled mount RPC, but the heartbeat nudge stayed in the handler, so shards it mounted after the caller left waited for the next full EC heartbeat. Nudge it from the recovery task, as Go's loads announce each recovered shard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: match the collection as well as the volume id in the recovery re-check Discovery keys orphans by (collection, vid), but the locked re-check matched the vid only. Two collections with orphans of the same vid could both resolve to the first record, so the other's index was never fetched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): match the collection as well as the volume id in the recovery re-check Mirror of the Go change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
63806b7073 |
s3 lifecycle: bound each LifecycleDelete attempt with its own deadline (#12646)
* s3 lifecycle: bound each LifecycleDelete attempt with its own deadline Replay and walker deletes used the job context with no request deadline, so one stalled unary RPC could hold a shard for the whole job. Each attempt now runs under DeleteTimeout (default 1m), set after the limiter wait. A timeout while the job is still live is retried like a transport error and then halts the shard or walk without advancing; parent cancellation still stops both the attempt and the backoff. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: admin setting for the delete RPC timeout Adds delete_timeout_seconds to the S3 Lifecycle admin form and passes it to both the replay drain and the walker. 0 keeps the 60s default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: describe replay and walker timeouts separately in the help text Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: fail the pass when a replay delete exhausts its attempts A transport error or attempt timeout that outlived the retries halted the shard with a nil error, so the job reported success. processMatches now returns the error (the cursor still holds at the event), and runShard treats a drain error as a clean stop only when its own context ended, since an attempt timeout also wraps DeadlineExceeded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: test that a replayed LifecycleDelete resolves after a lost reply Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: skip the expiration write once the attempt deadline passed A worker retries a LifecycleDelete whose attempt timed out, while the first attempt can still be running on the S3 server. An attempt that stalled before its marker write would then stack a second delete marker after the retry wrote one. The gRPC deadline reaches the handler context, so check it right before the expiration writes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: recheck the attempt deadline after the suspended null delete The null-version delete can block on the owner filer past the attempt deadline; the worker may have retried and written a marker by then. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: finish the suspended marker once the null version is deleted Skipping the marker after a successful null delete left an older version as the latest, and the retry then resolved as a no-op without hiding it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: let a routed delete marker commit only while its latest guard holds createDeleteMarkerIf passes an optional condition, evaluated on the .versions directory entry under the object's lock on the owner filer, and reports a refused commit as errLatestVersionChanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: write the expiration marker as a compare-and-set on the latest pointer A timed-out attempt can still be running on the S3 server while the worker's retry writes the marker. The marker commit is now conditioned on the .versions pointer as read just before it and skipped when the latest is already a delete marker, so whichever attempt commits second writes nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: resolve the marker as stale when another version became latest The marker's compare-and-set only covered changes after its own pointer read, so a version promoted after the expiration checks passed could be hidden by the marker. The enabled path now passes the validated version and a conflict retry that finds a different named latest resolves the request as VERSION_NOT_LATEST. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: resolve a null expiration as stale once a version takes the pointer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: read the marker's latest version the way getLatestObjectVersion does A pointer names a version only with its file name; an id alone falls back to the null object, and the null-is-latest signal makes the null version current. An expiration that validated a named version no longer hides a null written by a suspended PUT, and a current null under an id-only pointer now expires instead of resolving as stale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: hold the object write lock for an unrouted expiration marker Off the ring createDeleteMarkerIf cannot carry the pointer guard, so a PUT committing between the pointer read and the marker write was hidden. The read and the write now run under the object write lock that unrouted writers take. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: share transient-error retries between walker and replay deletes (#12649) * s3 lifecycle: retry only transient LifecycleDelete failures dispatchWithRetry retried every RPC error except parent cancellation, so an authentication, permission or argument error spent the whole retry budget before surfacing. Retry only attempt timeouts and the failures util.IsTransientError recognizes (Unavailable, ResourceExhausted, network resets); everything else returns on the first attempt. A nil response is now an error instead of a nil dereference. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: take a delete-rate token for every LifecycleDelete attempt processMatches waited on the shared limiter once per match, so the retries behind it ran outside the cluster-wide deletes/sec budget. The retry loop now waits on the limiter before each attempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: give walker deletes the replay retry policy WalkerDispatcher sent each LifecycleDelete once, so one dropped connection aborted the bucket's daily walk while the same failure on the replay path was retried. The walker now goes through deleteWithRetry and shares its transient-error retries, per-attempt limiter wait and nil response handling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: retry a DeadlineExceeded the server sends back A server or proxy can end the RPC with DeadlineExceeded while the attempt's own deadline is still running. util.IsTransientError rejects that status, so the delete halted with retries left. It is a timed-out attempt like the client-side one, so retry it the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: say walker deletes get 3 attempts in the timeout help Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
799fd10342 |
s3 lifecycle: fail over between S3 fronts during a pass (#12647)
* s3 lifecycle: add a LifecycleDelete client that fails over between S3 fronts When the current front returns Unavailable, the client closes it, marks it failed for the rest of the pass, picks the next front that passes checkLifecycleReady and resends the same request there. Callers cut off by that switch closing their connection resend on the new front. When no front is left, every later call returns one error naming the fronts tried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: serve the pass through the failover client Execute hands the replay drain and the walker one failover client built on the selected front, reports each switch as job progress, and closes the current connection when the pass ends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: keep failing over until a front serves the resent delete The resend after a switch went straight to the new front, so a second lost front ended the call even with a healthy third one, and the walker has no retry of its own. Resend through the failover loop instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: do not recheck fronts skipped when the pass started The failover client started with no failed fronts, so losing the selected front checked the fronts selectS3Front had already skipped again, holding every delete for another readiness timeout per front. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
a91b333658 |
s3 lifecycle: persist daily walk checkpoints and resume them safely (#12650)
* s3 lifecycle: walk checkpoints take each entry's resume position Versions of one object share a Path, so a checkpoint set from Path after the first version made a resume skip the rest. The ListFunc now gives each entry the start value that continues after it, and leaves it empty on all but an object's last version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: resume a bucket listing where the walk stopped The filer listing skipped entries with key <= start, but its order is not key order: each directory emits its .versions groups before its files, and a directory's children come before a sibling like dir.txt. Positions are now one (pass, name) frame per directory level, so a resume seeds each listing and skips exactly what was finished. A version group is one unit, and a skipped group still keeps its bare null version out of the second pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: content hash of a walk view Hashes every non-disabled action of a view and the versioning of their buckets, so a saved walk position can be tied to the walk it came from: another rule set, another walk mode, or a bucket that turned versioned gives another hash. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: persist daily walk progress and resume it A walk that failed or was cut short started over on the next pass, listing again every bucket it had already finished. WalkBuckets now keeps the finished buckets and each unfinished bucket's position in a checkpoint file next to the shard cursors, one per shard set, and the next walk of the same view and shards resumes from it. The record is saved every 30s and when the walk stops, and cleared when a walk completes, so the next walk is full again and sees keys added behind the position; a clear that fails fails the walk rather than leave a record that would skip buckets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: a stuck resumed walk starts over A bucket that fails at the same place on every pass kept the walk from completing, so the buckets it had finished were never walked again and their due objects waited forever. A resumed walk that fails again without finishing anything clears its checkpoint, and the next walk is full. A canceled walk keeps it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: do not resume a walk checkpoint left for a week A checkpoint is cleared only by a later walk of the same shard set, so a set that stopped walking, such as a one-off per-shard walk, left its record behind, and a walk of that set much later would skip buckets finished long before. Records now carry their save time and are not resumed after seven days; a walk that keeps retrying saves on every attempt and stays fresh. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: a failed walk without progress leaves its checkpoint alone A pass canceled while it read the checkpoint failed the read, then saved its own empty progress over the record it never loaded, so the next pass started every bucket again. A failed walk that finished nothing has nothing new to record and no longer writes; the stuck resume reset still clears. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: space out walk checkpoint saves after a failed one The save time advanced only on success, so once the filer refused a periodic save every following entry tried again and logged another warning. The interval now counts from the last attempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: a walk checkpoint save that errors may still be on disk A save whose reply was lost left onDisk false, so a walk that then completed skipped the clear and the next walk resumed from the stale record instead of walking everything. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: keep a stalled walk checkpoint for a day A resumed walk that failed again without progress dropped its record right away, so an outage spanning two attempts restarted the whole walk. Treat the walk as stuck only once its record has not advanced for a day. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: a resumed walk counts its earlier buckets as walked Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: replay a resumed recovery walk from the walk that began it A recovery or cold-start pass rewinds replay to runNow - maxTTL. When the walk resumed a checkpoint, its finished buckets were listed in an earlier attempt, so an object there that was not yet due then and whose write is now older than maxTTL was neither expired by the walk nor replayed. The checkpoint now keeps the start of the walk that began it, WalkBuckets returns that time (its own start for a fresh walk), and runShard floors the recovery rewind and the cold-start replay at it. A record without a start is not resumed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: a cold start that resumed a walk replays on the next pass The pass's shared subscription starts at runNow - maxTTL for a shard without a cursor, before its walk reports an earlier start, so flooring the cold-start drain at the walk start could not deliver the older events. Such a shard now saves its cursor at the walk start minus maxTTL and returns, like the recovery branch, and the next pass replays the window from that cursor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: test that a cursor below the floor opens the next subscription Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: test the cold-start replay across two Run passes A cold start whose walk resumed an earlier attempt sees an older event only on the next pass. The test runs Run twice against a filer that serves events past the requested floor, with a later in-window event that would otherwise move the cursor past the older one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
fd4603d657 |
s3 lifecycle: count filer entries a walk reads but skips as progress (#12658)
* dailyrun: count entries read from the filer, skipped ones included A versioned bucket's pre-pass and a resumed walk read entries without emitting them, so a walk can read for hours with no visited entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: count listed entries as progress work Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
512f898600 |
s3 lifecycle: report work-based job progress during a pass (#12644)
* s3 lifecycle: report work-based job progress during a pass The daily pass sent progress only while starting, so a healthy scan that ran for many hours could reach the admin's 24-hour no-progress guard. Worker heartbeats prove the worker is alive, not that this job moves. While dailyrun.Run is in progress the handler now sends a progress update every 5 minutes, and only when the pass's counters (entries visited, replay events, RPC outcomes including errors) moved since the last delivered update. An idle tick sends nothing, so a stalled pass still expires. A failed send is retried on the next tick. The reporter is stopped and joined before the completion is sent, so no progress can follow the terminal result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: test that progress, not heartbeats, keeps an old job active Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: label progress phase and bucket as the last started Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
858f8cbad8 |
s3 lifecycle: check internal S3 authentication before starting a pass (#12645)
* s3 lifecycle: add a LifecycleReady RPC that only authorizes the caller LifecycleReady runs the same checkAdminAuth as LifecycleDelete and reads no bucket or object metadata, so a lifecycle worker can confirm that an S3 front accepts its internal credentials before it starts a pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: check S3 fronts with LifecycleReady before the pass Execute used to dial the first registered S3 front and start loading policies and walking buckets, so a missing or mismatched jwt.filer_signing.key surfaced only as repeated per-bucket delete failures. It now checks each front in order with LifecycleReady, using the credentials LifecycleDelete sends, under a 10s bound that also follows parent cancellation. The first front that passes serves the pass; fronts that fail are reported in the job's progress and the log. When none passes, the job fails before any listing with an error that names the front and says whether this worker has the key set, without key or token material. Fronts that predate LifecycleReady are checked with an empty LifecycleDelete, which they authorize and then reject before any lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
c819e3fbea |
s3 lifecycle: per-pass run results and last full-pass status (#12643)
* s3 lifecycle: collect per-pass bucket results and work counters WalkBuckets kept only the first bucket error and logged the rest. A RunStats shared by the walker, the walker dispatcher and the replay drain now records every bucket's walk result (walked, failed, skipped on cancellation), entry and object visits, replay events, and LifecycleDelete outcomes under the dispatch_total outcome labels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: persist the last fully successful pass Shard cursors and walk timestamps advance on partial passes as well, so neither says when lifecycle last covered every policy. Keep that in its own record next to the cursors, plus a worker gauge for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: report each pass's result in the job record The job ended with a fixed success summary, or with only the first error, and malformed lifecycle policies were V(1) logs. The completion now carries the pass status (complete, partial, failed, canceled), bucket totals and failures, invalid policies, entry, object and event counts, LifecycleDelete outcomes, the last phase and bucket, the elapsed time and the last full pass, on failed passes as well. Only a complete pass advances the full-pass record; a malformed policy makes the pass partial. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: keep a failed job's result in its record Completions with Success=false dropped Result.Summary and Result.OutputValues, so a handler could not report what a failed run had done, which buckets failed, or how far it got. Keep them; the error message still drives the job's message and run record. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * grafana: chart the time since the last full lifecycle pass Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: a replay halted on an unresolved delete is a partial pass BLOCKED, RETRY_LATER and exhausted transport retries stop a shard's replay without an error, leaving its due events for a later pass. Count those shards and report the pass as partial, so it no longer advances the full-pass record. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: a pass with throttled walks is not a full pass WalkerInterval can skip the walk for walk-only rules (ExpirationDate, ExpiredDeleteMarker, NewerNoncurrent) with no error. Count those shards and keep the full-pass record for passes that evaluated every rule; the job reports full_pass and walks_deferred. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3 lifecycle: keep the saved full-pass time when the save fails Publishing a timestamp that never reached the filer let the gauge move back on the next job's reload. Keep the previous value and report the save error in the job result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: drop a failed attempt's summary when the retry reports none Retries reuse the job record, and failed completions now keep their result summary, so a retry that completes without a Result showed the failed attempt's summary, and a successful one used it as its message. Clear the summary when a completion carries no Result, as the output values already are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
55a4a5974c |
ec_balance: make the per-rack cap on global moves a worker setting (#12478)
* ec_balance: make the per-rack cap on global moves a worker setting The global load-balancing phase planned at most 10 moves per rack per detection run, hard-coded. On a cluster where one disk per machine holds several times its siblings' shards, that is about 20 moves an hour against tens of thousands needed, however many moves the worker can execute. Add global_max_moves_per_rack to the plugin worker config. The default stays 10, so nothing changes unless it is raised. It is clamped to 1..5000 because the planner reads 0 as unlimited and would plan a whole drain in one run. Claude-Session: https://claude.ai/code/session_011UpvafcfUuC2mLxNAXLQJi * ec_balance: clamp global_max_moves_per_rack before narrowing it to int A value past the int32 range made ReadIntConfig return the default, so a request asking for more than the maximum got 10 moves instead of 5000. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec_balance: test the configured global cap through Detection The helper test still passed if Detection handed the planner a literal cap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec_balance: plan no more global moves per rack than the detection keeps Each global move scans the source node's volumes, and the detection keeps at most max_results moves. With the cap at 5000, three skewed racks of 20,000 volumes planned 15,000 moves to keep 500, taking about 70 s of the 300 s detection budget; bounded by max_results it takes about 5 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec_balance: test the configured global cap with a result limit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
554593796e |
ec_balance: drain a server holding far more shards than its siblings (#12477)
* ecbalancer: drain a full server through any target that can take a shard The global phase paired the fullest server with the single emptiest one and stopped for the whole rack when that pair had no legal move. Where every volume already has a shard on each machine, no cross-machine move keeps the spread, so on hosts running one volume server per disk the first server's disk kept its pile while its siblings on the same machine stayed nearly empty: the phase never planned a move. Try sources fullest first and targets emptiest first and take the first pair with a legal move, so such a server drains onto its own machine's emptier servers. A same-machine move goes only to a server holding none of the volume, so one disk never carries two of its shards. Per-machine counts are indexed once per rack and pairs without a move are remembered until a move can change them, so an uncapped drain stays fast. Claude-Session: https://claude.ai/code/session_011UpvafcfUuC2mLxNAXLQJi * ec_balance: keep global moves ahead of within-rack moves under the detection cap Detection truncated the plan to the per-cycle job limit in planner order, which puts the global moves last. A long within-rack backlog pushed all of them past the limit, so even a planned global move never ran. Order dedup and cross-rack first, then the capped global phase, then within-rack. Claude-Session: https://claude.ai/code/session_011UpvafcfUuC2mLxNAXLQJi * ec_balance: keep each volume's moves in plan order when promoting global moves The admin scheduler runs only the first proposal per volume each cycle. A global move promoted ahead of its volume's within-rack moves can take a shard that one of those moves placed, so it ran while the shard was still on the original server and failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ecbalancer: order global targets by fullness after taking the shard The search stops at the first target that would end up fuller than the source, which only holds when targets are ordered by that same value. With unequal capacities an empty one-slot server sorted first and ended the search before a larger server that could take the shard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ecbalancer: free the source disk slot on a global move The global phase cleared the moved shard's bits but left the source disk's free slots and shard count unchanged, unlike every other phase. Use releaseShard so a later pick of that server sees the freed disk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec_balance: test that a capped detection keeps a global move Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ecbalancer: test the same-machine move skips a sibling holding the volume Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
5b1450b06b |
s3tables, iceberg: one catalog record per table location (#12473)
* s3tables: refuse a table or view location another record holds A create, register, update or rename could name a location at, under or above another catalog record's files, including the files a renamed table left under its old name. The new record then loaded that table's metadata, had credentials vended for its files, and could purge them on drop. Each of those writes now scans the bucket's records and refuses a root another record claims, and a drop of a record sharing its files is refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg: check a table's location before writing to it REST create and stage-create write a metadata file, and stage-create vends write credentials, before the catalog registers the table, so the create gate now also validates the location and refuses one another record holds. RegisterTable runs the same gate before it reads the metadata file, instead of reading first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg: keep a dropped location another record holds DropTable and DropView purge the dropped record's location after the catalog delete. A view recorded at a table's location took that table's directory, record included. The purge now leaves a location another record still holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3tables: authorize CreateTable before reporting the namespace A caller without CreateTable got 404 for a missing namespace, 403 for an existing one and 500 with decoder text for an unreadable one. The grant is now evaluated against the bucket first, and only a caller that passes learns the namespace is missing or unreadable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg maintenance: skip a table whose files another record shares Orphan removal and snapshot expiry delete what a table's metadata does not reference. For two records over one location that deletes the other's files, so detection leaves such tables alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3tables: count another record's catalog entry as claimed A table keeping its files elsewhere still owns its entry directory, and a view recorded there would take that entry with it on drop. The ownership check now refuses a root at, above or under another record's entry too. Maintenance still compares files only, so a table created over a renamed table's old name does not stop that table being maintained. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3tables: check a claimed location again once the record is written Two creates, or a create and an update moving a root, could both read the same root free and both land. A create now checks again after writing its still-marked record and backs out if another record claims the root, and an update that moved its root checks again after the write and puts the previous metadata back. Of two racing writers at least one sees the other. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg: enable stage-create in the location ownership test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg maintenance: check for a shared location again before removing orphans A job can run long after its table was scheduled, or come from a detector that never checked, so remove_orphans reads the bucket's records itself and leaves the files alone when another record shares the table's location. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3tables: check a renamed record's new root again once it is written A record without a location moves its root with its name, and was checked only before the rename wrote the destination, so a create landing on that root in between could share it. The rename now checks again with the destination written and backs out, like a create. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3tables: put a moved record back when its location cannot be checked again An update that moved its root kept the move when the check after the write failed to list the bucket, so a racing writer that relied on that check could share the root. The move is now undone as it is when the root is taken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3tables: hold a moved record's old root until the move lands An update moving a record's root wrote the new metadata first and put the old metadata back when the check that followed found the new root taken. The old root was free in between, so a create racing for it could pass its own check and then share it with the restored record. The update now stores the metadata it is about to write beside the current one, so the record holds both roots, checks the new root with that reservation in place, and only then switches the metadata. A move that backs out drops the reservation without touching the metadata, and an update that keeps its root clears a reservation a crashed move left behind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3tables: test a move racing another update of the record Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3tables: drop a move's reservation when a rename or delete takes the record A rename or a decoupled delete that took a record while an update held its move reservation left the reservation on the old name, where the move could no longer clear it, and later creates of that name were refused as taken. Both now clear it with the record's other attributes, and a failed rename does not put it back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: register a table from metadata under its own location The Spark register test registered a live table's metadata file under a second name, which now fails because both records would own the source's files. It checks that refusal instead, and registers a copy uploaded under the new table's own directory, with its location pointing there, to cover reading and writing a registered table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
4be28fef2d |
iceberg maintenance: cache a remote-only file before reading it (#12191)
* iceberg maintenance: an unreadable parquet file fails the job, not the process parquet.NewReader panics on any file it cannot open (wrong magic, a truncated footer, zero bytes), and parquet-go's row decoder panics on a corrupt page under a valid footer. Maintenance runs in the worker's goroutines with no recover, so one bad delete or data file in any table ended the whole process. - Every parquet open in compaction goes through newParquetReader, which opens with parquet.OpenFile and returns the error. - A panic while decoding a delete file or a data file's rows is recovered into an error naming the file (recoverRead/guardRead). - As a backstop, detection recovers per table and Execute per operation: the table is skipped or the operation fails, and the worker keeps running. A failed delete file still fails the table's compaction (no commit), as a read error did before; a failed data file still skips only its bin. * iceberg maintenance: cache a remote-only file before reading it On a bucket mounted with remote.mount, a file that is not cached locally has no chunks and no inline content, only its RemoteEntry. Maintenance read it as an empty file: a parquet reader failed on zero bytes (before the previous change, it panicked and ended the process) and a manifest failed to parse, so a table whose files had been uncached could not be maintained. lookupFileByIcebergPath, the lookup every read goes through, now calls CacheRemoteObjectToLocalCluster for a remote-only entry, as the S3 gateway does on a read, and reads the entry it returns; the call is tried twice, and an entry still remote-only after caching is an error. The lookups that only resolve a path (orphan removal) do not cache. readEntryContent reports a file with no content and no chunks as empty instead of returning zero bytes. The fake volume server in the tests now serves chunk reads, so the remote-only tests read the cached file through the chunk reader as a real one is read. * iceberg maintenance: bound the metadata location read before caching a remote file * iceberg maintenance: bound the metadata read on the entry the cache returns * iceberg maintenance: enforce the metadata size bound inside the remote cache call The worker checks the resolved entry before asking the filer to cache a remote-only object, but the filer resolves the entry again at cache time and downloads whatever its remote size then says. A replacement landing in between could push an oversized object through the download even though the post-cache check would refuse to read it. CacheRemoteObjectToLocalClusterRequest gains an optional max_size; the filer rejects an over-limit remote object before the download starts. loadMetadata passes metadataFileMaxBytes; data-file reads leave it unset. * iceberg maintenance: key the remote cache singleflight by the size limit Callers sharing one flight share its outcome, including a bounded caller's over-limit rejection: an unrestricted reader joining the same path would fail even though its own bound allows the download. The limit joins the key so only callers with the same bound share a flight. * iceberg: gofmt compact_order_test.go * filer: bound remote cache callers before the shared download Each caller's max_size is now enforced on the entry the filer resolves before that caller joins the singleflight, which is keyed by path again. A bounded caller's rejection is never shared with other callers, and callers with different bounds share one download instead of pulling the same remote object twice. * filer: bind the remote cache size bound to the downloaded entry The pre-flight check and the shared download resolve the entry separately, so a remote metadata refresh landing in between lets a larger object through: the download ran to the refreshed size and only the reader's post-check refused it. The bound is now re-checked inside the flight on the entry the download streams. The rejection is typed so a co-tenant sharing the flight does not inherit it: callers whose own bound permits the reported size retry on a fresh flight instead of failing for another caller's limit. --------- Co-authored-by: user.email <chrislusf@users.noreply.github.com> |
||
|
|
e9c280e095 |
iceberg maintenance: bound decimal, time, uuid, fixed and rescaled timestamp columns on compacted files (#12190)
* 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> |
||
|
|
edf2b0f5ee |
iceberg maintenance: an unreadable parquet file fails the job, not the process (#12188)
* iceberg maintenance: an unreadable parquet file fails the job, not the process parquet.NewReader panics on any file it cannot open (wrong magic, a truncated footer, zero bytes), and parquet-go's row decoder panics on a corrupt page under a valid footer. Maintenance runs in the worker's goroutines with no recover, so one bad delete or data file in any table ended the whole process. - Every parquet open in compaction goes through newParquetReader, which opens with parquet.OpenFile and returns the error. - A panic while decoding a delete file or a data file's rows is recovered into an error naming the file (recoverRead/guardRead). - As a backstop, detection recovers per table and Execute per operation: the table is skipped or the operation fails, and the worker keeps running. A failed delete file still fails the table's compaction (no commit), as a read error did before; a failed data file still skips only its bin. * iceberg maintenance: test a corrupt page inside a merge fails it naming the file * iceberg maintenance: assert a skipped bin's files stay in the snapshot --------- Co-authored-by: user.email <chrislusf@users.noreply.github.com> |
||
|
|
55f2234026 |
iceberg maintenance: apply equality deletes only to older data files in their partition (#12187)
* iceberg maintenance: apply equality deletes only to older data files in their partition
Compaction applied every equality-delete key to every data file of every
bin. The Iceberg spec ("Scan Planning") applies an equality delete file only
to data files with a strictly lower data sequence number, and only to data
files in the delete file's own partition unless its spec is unpartitioned.
An upsert writer (Flink, the Iceberg Kafka Connect sink, CDC tools) commits
an update as the row's new version plus an equality delete of its key in the
same commit, so the compaction deleted both the old and the new version of
every updated row.
- equalityDeleteGroup is keyed by equality field ids and scope (unpartitioned,
or spec id plus partition) and keeps, per key, the highest data sequence
number of the delete files carrying it. A delete file without a data
sequence number is an error rather than a guess.
- Partition values are compared typed through the spec's partition type, so
one partition decoded in different Go shapes (a uuid as uuid.UUID or
[16]byte, a long as int32 or int64, a null present or missing) is one
partition. A spec whose fields are all void is unpartitioned. A delete whose
scope cannot be decided (unknown spec, no partition values under a
partitioned spec, a value that does not convert) stops the compaction; a bin
whose own partition cannot be typed while a delete of its spec exists is
not compacted.
- Each bin is merged with only the groups that apply to its partition, and a
row is deleted only by a key whose sequence number is higher than its data
file's.
- A where filter no longer drops unpartitioned delete files (the clause's
field is not in their spec), which let deleted rows return in a filtered
compaction.
Tests: the table fixture now commits its delete files after the data (data
sequence number 1, deletes 2), as writers do; hand-built entries in the unit
tests get sequence numbers. New eqdelete_sequence_test.go covers rows written
with and after their delete, partition scope, unpartitioned and all-void
specs, typed partition matching, missing sequence numbers and partition
values, where filters, and group-key collisions.
* iceberg maintenance: split the undecidable-scope branch in deleteInPredicateScope
---------
Co-authored-by: user.email <chrislusf@users.noreply.github.com>
|
||
|
|
b62bbb99fc |
fix(iceberg): serve a registered table's metadata on load and commit (#12159)
* iceberg: serve a registered table's metadata on load and commit RegisterTable saved only the metadata location, and loads and commits never read the file there. They served a placeholder with no schema, no snapshots and a new random table UUID on every load, so a registered table read as empty, an INSERT failed against the empty schema, and every other commit failed its assert-table-uuid requirement. Metadata uploaded through the S3 gateway, as a migrated table's is, is stored in chunks that registration did not read, so it registered an empty table. Read the file following its chunks, reject one that is not Iceberg metadata with a 400, and keep its content and table UUID in the record the way CreateTable does. Records registered before this change hold only the location. Loads and commits now read the file there, and the first commit stores it in the record under the file's table UUID. * iceberg: transactions read a location-only registration's metadata file * iceberg: cover transactions on a location-only registration * iceberg: refresh the default name mapping on transaction commits * iceberg: cover name-mapping refresh in transactions * iceberg: roll a transaction back to a registration's metadata file A transaction that failed after flipping a table registered before the record kept its metadata could not undo the flip. The rollback restored the record's prior metadata, which for such a table is only a location, and UpdateTable keeps the full metadata a flip stored when the restore sends none. Loads went on serving the change the client was told had failed, and a client retrying the transaction could apply it twice. Restore the metadata loads served from the file instead, under the file's table UUID. * iceberg: register oversized metadata by its location Registration sends the metadata file's content to the S3 Tables manager, which refuses a request over its 10MB body limit, so a table whose metadata is larger could no longer be registered at all. Register such a file by its location and table UUID alone; loads read it from that location, as they do for a record that never kept its metadata. Export the limit as s3tables.MaxRequestBodySize so the catalog can check against it. A commit to such a table still sends the whole metadata to UpdateTable and stays over the limit. * iceberg: commit oversized metadata by its location * iceberg: let maintenance follow a location-only table record * admin: read a table's metadata file when the record keeps none * iceberg: bound the metadata file a location-only record reads * iceberg: bound only chunked metadata reads in the worker Inline content is what the catalog itself wrote and the REST load path accepts it at any size, so rejecting it in loadMetadata stranded tables over 64 MiB from every maintenance scan. Cap only the chunked read, where the recorded location can name any object in the bucket. --------- Co-authored-by: chrislusf <chrislusf@users.noreply.github.com> |
||
|
|
fefac028ec |
feat: send EC shards in parallel per destination disk (#12050)
* feat: send EC shards in parallel per destination disk One stream per destination disk. max_shard_transfers unset means no global cap, 0 sends shards sequentially, and N is a global cap that still keeps one stream per disk. The value is persisted through TaskPolicy. The maintenance form is a checkbox plus Max transfers because unset and 0 differ. The key is intentionally omitted from GetConfigSpec. * ec shard distribution: treat negative max_shard_transfers as sequential The config layer (normalizedMaxShardTransfers) clamps negative values to 0, which selects sequential distribution. shardTransferCap diverged: a negative cap that reached ShardDistributionOptions directly would have selected uncapped parallel mode, the most aggressive setting. Align the options layer with the same normalization so invalid input degrades to the conservative mode. * ec: serialize shard transfers to a server when a target leaves disk choice to the receiver disk_id 0 is auto-placement on the receiving volume server, so an auto-placed stream can land on a disk another queued stream is pinned to. Grouping by (destNode, disk_id) alone let both run at once; collapse all of that server's transfers under the destNode key instead. * worker: clamp max_shard_transfers to the int32 wire range ReadIntConfig returned the 0 fallback for values above MaxInt32, turning a large positive cap into sequential mode. Read int64 and clamp into range instead. * worker: drop unused shard-transfer form helper The maintenance form renders and collects max_shard_transfers in plugin.templ JavaScript; the Go copy had no callers. * worker: bound max_shard_transfers conversion under an in-range guard --------- Co-authored-by: Chepurnov Simon <195125934+CHEPURNOV-S-S@users.noreply.github.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
18f9d9a0b6 |
feat: Free Volume Deadband (M) for EC shard placement (#12029)
* feat: Free Volume Deadband (M) for EC Place nodes and racks |ΔfreeSlots| ≤ M is a tie; remainder is liveShards. M=0 stays strict freeSlots. M is free volume slots (× dataShards). pickNodeInRackEligible and pickRackEligible share the rule. Worker plugin config free_slots_deadband, default 0. Not on the write path. * fix: anchor EC freeSlots deadband on class maxFree Pairwise |Δfree|≤M vs the current winner is not transitive: 120→110→100 at M=10 slots picked 100. After evenness, rank by maxFree, keep |free-maxFree|≤M, then min liveShards. Shared by node and rack. M=0 is still only maxFree then live. * worker: add free_slots_deadband to ErasureCodingTaskConfig * erasure_coding: persist free_slots_deadband through TaskPolicy ApplyMaintenanceConfigFromToml accepted the key but the admin save path round-trips config through ToTaskPolicy, so the value was dropped on reload; serialize it like the other EC settings. * erasure_coding: bound free_slots_deadband at its declared maximum The TOML loader and the plugin worker config only clamped negatives, so a value above the spec's 100000 could reach the int32 TaskPolicy field and wrap; cap at 100000 on both entry paths and declare MaxValue on the plugin field. * erasure_coding: document free_slots_deadband in scaffold admin.toml --------- Co-authored-by: Chepurnov Simon <195125934+CHEPURNOV-S-S@users.noreply.github.com> Co-authored-by: user.email <chrislusf@users.noreply.github.com> |
||
|
|
ecd778a4a0 |
iceberg maintenance: a merged file with null row ids names no first_row_id (#11973)
* iceberg maintenance: a merged file with null row ids names no first_row_id
Compaction stamps a merged v3 data file with the _row_id of its first row as
first_row_id (mergedFileFirstRowID). When the bin mixed rows that carry a
materialized _row_id with rows that carry none (a data file with no
first_row_id, as a v2 table's files are after an upgrade to v3, gives null
ids), the null rows then inherit first_row_id + their position in the file:
ids that other rows already hold, so two rows answer to the same row id.
A merged file now names a first_row_id only when its footer shows no null
_row_id in any row group. Otherwise the commit assigns the file a fresh range
from the table's next-row-id: the null rows get new, unused ids and the
materialized ones keep theirs (a materialized value overrides inheritance).
Test: TestMergedFileFirstRowIDOnlyWithoutNullIDs ("materialized first, a null
later" fails without the fix).
* iceberg maintenance: name no first_row_id when the merged file has a null _row_id
mergedFileFirstRowID stamped the merged file with its first row's id
without checking later rows. A null _row_id in a merged file inherits
first_row_id+position, an id another row already holds, so the commit
produced two rows answering to the same row id.
Check the footer's null counts for the _row_id column across row groups
first: any null means the file is committed without a first_row_id, so its
nulls take fresh ids from the table's next-row-id while materialized
values still override inheritance.
* shell: retry filer discovery until master knows a filer
A shell started against a freshly booted cluster (weed mini, the
s3tables/lance test harnesses) can list cluster nodes before the filer's
first heartbeat lands on the master. The empty list left FilerAddress
unset and the next command died with "dial tcp: missing address". Poll
ListClusterNodes until a filer appears or the connect timeout expires.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* shell: discover the filer on first use instead of at startup
The startup retry loop made every weed shell invocation wait out the
connect timeout on clusters that have no filer, even for commands that
only talk to the master. Discovery now runs once, on the first command
that actually needs a filer, keeping the retry-until-registered fix for
the fresh-cluster race without stalling master-only commands.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* shell: stop filer discovery retries on non-transient errors
A master that keeps answering ListClusterNodes with a permanent error
(permission denied, unimplemented) cannot gain a filer by retrying, so
discovery returns instead of polling until the deadline.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
---------
Co-authored-by: Javier de la Torre <jatorre@lakehousebox.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Chris Lu <chris.lu@gmail.com>
|
||
|
|
0d00e92178 |
iceberg maintenance: match percent-decoded keys when checking file references (#11978)
* iceberg maintenance: match percent-decoded keys when checking file references Writers may percent-escape partition directory names in the file paths they record in manifests (e.g. "part%3D1"), while the S3 layer decodes the key before storing the object. remove_orphans compared the escaped reference to the decoded filer path, counted the live file as an orphan, and deleted it once it passed the age window — readers then got NoSuchKey on the next scan. Match both spellings of every referenced path in remove_orphans, apply the same coverage to the kept-file set in expire_snapshots, and delete expired files at their decoded key so the object the S3 layer stored is the one removed. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * iceberg maintenance: retry filer lookups at the percent-decoded key A manifest reference carrying an escaped segment resolves to a filer name that does not exist, because the S3 layer decoded the key on write. When a lookup misses and the reference contains escapes, retry once at the decoded spelling so maintenance can still read the file. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * iceberg maintenance: resolve referenced files verbatim-first, decoded fallback filer_pb.LookupEntry reports misses as ErrNotFound rather than a gRPC NotFound, so the escaped-reference retry never fired against a real filer. Both maintenance reads and expired-snapshot deletes now resolve through one verbatim-first/decoded-fallback lookup, and expiry refuses to delete a resolved path outside the table's data directory. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * iceberg maintenance: test expiry of a file stored at a literal percent key * iceberg maintenance: resolve referenced files in one filer lookup lookupFileByIcebergPath re-fetched the entry resolveFilerPath had just looked up, doubling the RPC per referenced file during compaction and expiration. The resolver now returns the entry alongside the path so a hit costs one lookup and a decoded fallback two. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * iceberg maintenance: keep every decoded spelling of a referenced path The kept-reference sets recorded a path plus a single decode of it, but lookupResolvedEntry decodes recursively until the spelling is stable. A doubly-escaped reference could resolve to a spelling absent from the set and be deleted while still referenced. addFilerPathSpellings now walks the same decode chain the resolver does. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * iceberg maintenance: keep every decoded spelling of a referenced path * iceberg maintenance: test expiry keeps a doubly-escaped kept reference * iceberg maintenance: clean decoded spellings in the referenced-path set * iceberg maintenance: test expiry keeps a kept reference resolved via decoded parent segment * iceberg maintenance: decode only the reference in the spelling set Decoding the composed filer path also decoded the table directory, so a table at a literal percent-escaped path produced a kept set missing the spelling the resolver returns, and expiry could delete a live file. * test: gofmt the s3tables cluster helpers Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> |
||
|
|
7154732b84 |
worker/ec: retry the pinned volume copy after a mid-copy compaction (#11929)
* worker/ec: retry the pinned volume copy after a mid-copy compaction The EC task pins .idx/.dat copies to the CompactionRevision read from ReadVolumeFileStatus so the pair comes from one volume generation. When vacuum compaction lands between that read and either CopyFile, the server rejects the copy with "volume N is compacted" and the whole task fails — on clusters with queued maintenance this makes most EC tasks die to a race they cannot avoid. On a compaction mismatch the copy now restarts under a freshly read revision, up to a bounded number of attempts; other errors still fail immediately. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * worker/ec: read the retried copy's expiry from its own file status A mid-copy compaction makes the source reload the volume, and the fresh ReadVolumeFileStatus can carry a different expireAtSec than the pre-compaction read. Keeping the attempt-0 expiry could let the EC volume outlive its source TTL. * worker/ec: cover the compaction retry with a stub volume server * worker/ec: also observe revised .idx bytes in the compaction retry test * worker/ec: read the fake source under its mutex in the retry test --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> |
||
|
|
ac319fe318 |
volume: never compact a volume tiered to remote storage (#11895)
* volume: never compact a volume tiered to remote storage A tiered volume's data backend is the remote object, but compaction reads the local .dat path. When tiering removed the local .dat, every vacuum of a tiered volume with garbage fails with "no such file or directory", and the master's sweep and the worker's vacuum task keep selecting it. When the local .dat was kept, the compaction succeeds against the stale copy and the commit reloads the volume to read the remote object (old layout) through the compacted index, so live needles stop reading. Mirror the Rust volume server (#11545): - CompactByIndex and CompactByVolumeData refuse a volume with a remote file before creating .cpd/.cpx ("volume N is tiered to remote storage, cannot compact"). - CommitCompact refuses under the data-file locks when the volume became tiered during the copy, and removes .cpd/.cpx. - Store.CheckCompactVolume reports no garbage for a tiered volume, so the master's vacuum and volume.vacuum do not select it. - The worker's vacuum detection skips a volume with a remote copy, as balance and EC detection already do. Tests (each fails on master): TestCompactRefusesTieredVolume, TestCommitCompactRefusesVolumeTieredDuringCopy (on master the commit succeeds and a surviving needle no longer reads), TestPickPrimaryReplicaSkipsTieredVolumes. * volume: skip tiered replicas in vacuum selection, keep their real ratio Reporting a zero garbage ratio for a tiered volume hid it from volume.tier.compact, whose preflight reads that ratio while the volume is still remote, and did not exclude it from a vacuum with a zero threshold. Report the real ratio again, as the Rust volume server does, and have the master's vacuum check skip a replica whose volume info names remote storage, whatever the threshold or request. When CommitCompact refuses a volume tiered during the copy, also close the temporary needle map and remove .cpldb: nothing else would, since no later vacuum selects the volume. The tiered-compaction test no longer depends on random needle sizes reaching a 0.3 garbage ratio. * volume tier: do not attach a copy of a .dat a compaction replaced The upload copies the .dat, then records the remote file in the .vif and switches the backend. A compaction commit in between swaps in a compacted .dat and index; the upload then served the old-layout remote object through the new index, so live needles stopped reading. CommitCompact's tiered check cannot see this: the volume is not tiered until the switch. AttachRemoteDatFile records the remote file and switches the backend under the data-file locks, and refuses when the backend is no longer the file that was copied. The upload then removes the unused remote copy. * volume tier: keep a committed .vif entry when only the dir fsync fails AttachRemoteDatFile rolled back the in-memory remote entry on any SaveVolumeInfo error. A NotCrashDurableError comes after the rename, so the .vif on disk already names the copy; with the entry gone, the upload handler deleted that object, and a reload would serve from a missing remote file. Keep the entry and switch to the copy as the .vif says, and still return the error so the caller keeps the local .dat. * vacuum worker: filter tiered replicas instead of skipping the volume A partially tiered volume is the leftover of an interrupted volume.tier.upload; skipping the whole volume left garbage on its local replicas unreclaimed. Per-replica filtering matches the master's batchVacuumVolumeCheck and is safe: a tiered replica refuses both compaction and commit. --------- Co-authored-by: Javier de la Torre <jatorre@lakehousebox.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
763e2a2090 |
iceberg: record geometry bounds on the data files compaction writes (#11898)
* iceberg: record geometry bounds on the data files compaction writes Compaction collected column statistics for every primitive column except geometry: the bound converter has no geometry case, so a compacted file's manifest entry carried value and null counts for a geometry column but no lower or upper bound. Readers that skip files by these bounds for a spatial filter (for example DuckDB for `geom && <box>`) had to open every compacted file, where the files before compaction could be skipped. The bound follows the spec's single-value serialization for geometry: the lower bound is the point (xmin, ymin), the upper bound (xmax, ymax), each an 8-byte little-endian double; z and m are not written. It is the union of the written file's row-group geospatial statistics, which parquet-go computes from every non-null value. A bound that is too small makes a reader skip rows, so any doubt gives none: a row group with non-null values but no geospatial statistics (parquet-go omits them when a value does not parse as WKB), a box that is not finite, an inverted box, or a chunk whose statistics cannot be read. A row group of nulls only constrains nothing. Geography gets no bound, as iceberg-go writes none for it (geodesic edges, boxes across the antimeridian). Tests: points and polygons far apart through a bin-packed compaction (the bound equals the union of every geometry), a sorted compaction (any bound covers every geometry), a column of nulls only, an unparseable value in a second row group (no bound; without the rule the file got the bound of the first row group only), geography, and the aggregation rules. * iceberg: do not order compaction bins by a geometry column When a table declares no usable sort order, compaction orders a bin's files by the first column every file has bounds for. A v3 table whose first column is a geometry qualifies as soon as its files carry geometry bounds (DuckDB writes them, and compacted files now do too). Those bounds decode into geo literals that compareLiterals cannot compare, so the order sorted nothing, yet an oversized bin was still split into "ordered" runs by splitOrderedBin. Geometry and geography columns are now skipped in both the declared sort order and the inferred one, so such a table is ordered by its next column with bounds. Test: TestResolveCompactionOrderSkipsGeometry, a geometry column first and an id column second; on master the order is the geometry column. --------- Co-authored-by: Javier de la Torre <jatorre@lakehousebox.com> |
||
|
|
a882565cd7 |
iceberg: keep a default-CRS geometry column without a CRS after compaction (#11899)
* iceberg: keep a default-CRS geometry column without a CRS after compaction Writers such as DuckDB write a GEOMETRY column whose Iceberg type has the default CRS (OGC:CRS84) with no CRS in the Parquet logical type. parquet-go spells the default out when it writes such a column (geometryType's LogicalType), even when the column it read declared none, so every compacted file declared GEOMETRY(crs=OGC:CRS84) where its inputs declared GEOMETRY. Both mean the same to the Parquet spec, but a reader may treat the file column as another type than the table column: DuckDB casts it to the table's GEOMETRY, and a cast column is no longer pruned by its row-group statistics, so a spatial filter read every row group of a compacted file. After a bin is merged, the footer's schema elements of every GEOMETRY column whose Iceberg type has the default CRS (top-level or nested) are rewritten to declare no CRS. The data, the page indexes and every offset stay byte for byte; only the footer is re-encoded. An explicit CRS is left as it is. Retyping the writer's column instead does not work: parquet-go refuses to convert between two GEOMETRY types that both mean the default, and its sorting writer converts. Tests: geometry_crs_test.go, a bin-packed and a sorted compaction of default-CRS inputs (one of them spelling the default out) write no CRS, with a control showing parquet-go spells it out on its own; an explicit CRS is kept; a nested geometry. On master the binpack and sort cases fail with CRS "OGC:CRS84". * iceberg: compress the row lineage columns of compacted v3 files A v3 compaction appends _row_id and _last_updated_sequence_number to the merged file. The two leaves were built without a codec, so they were written uncompressed, 16 bytes a row, whatever codec the data columns use; on a table of points the compacted files grew by about a third. The lineage leaves now take the codec of the reference file's first leaf that declares one, ZSTD when none does. Test: TestCompactCompressesLineageColumns; on master both columns are written UNCOMPRESSED next to ZSTD data columns. * iceberg: match list and map geometry by Iceberg name in files without field ids A Parquet footer path runs through the repeated group of a LIST or MAP (shapes.list.element, attrs.key_value.value), which Iceberg leaves out of its field names (shapes.element, attrs.value). The name lookup for a file without field ids therefore missed every geometry inside a list or a map and left the default CRS spelled out. Name the paths as Iceberg does, including the legacy two-level list forms. * iceberg: rewrite the geometry CRS footer inside the merged file's buffer Removing a CRS shortens the footer, so the new one fits where the old one was. Copying the whole merged file to replace a few hundred bytes of footer doubled the memory of a compaction near the target file size. * iceberg: take the lineage codec from the data columns, not an input's _row_id An input that already carries _row_id may list it before its data columns, and write it uncompressed; the new lineage columns then copied that codec instead of the data columns'. Choose from the columns the layout keeps. --------- Co-authored-by: Javier de la Torre <jatorre@lakehousebox.com> |
||
|
|
222e96d6ab |
iceberg maintenance: merge bin files across parquet schema spellings (#11875)
* iceberg maintenance: compare parquet schemas by field id in bin-pack merge parquet.EqualNodes ignores Iceberg field ids, so a column dropped and\nre-added under the same name and type compared equal and was merged,\nfiling the new column's values under the dropped field id. Require the\nfield ids to agree wherever both sides carry one; the v3 layout's\nper-field check uses the same test.\n\nGenerated with [Devin](https://devin.ai)\n\nCo-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * iceberg maintenance: merge bin files whose schemas differ by field id A bin used to take the first file's Parquet schema as the writer's and\nrefuse every file that was not structurally identical, so a table never\ncompacted once files had a different column set or REQUIRED-vs-OPTIONAL\nrepetition. A file whose flat columns the writer's schema covers by\nfield id is converted into it (a column the file lacks reads as null);\na file that covers the writer's schema restarts the bin with it, so no\ncolumn is dropped. Equality-delete columns resolve on each file's own\nschema. Renames, type changes, nested columns and files without field\nids stay refused. The sorted and spatial merges are unchanged.\n\nGenerated with [Devin](https://devin.ai)\n\nCo-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * iceberg maintenance: test bin-pack merge across parquet schema spellings Regression coverage for the field-id merge: an added column in either\norder, REQUIRED vs OPTIONAL, equality deletes resolved per file, the\nre-added column refused on v1/v2 and v3, and the refusals that stay\n(rename, type change, one-sided columns, an added required column, no\nfield ids).\n\nGenerated with [Devin](https://devin.ai)\n\nCo-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * iceberg maintenance: resolve missing delete columns as null in bin-pack merge An equality delete on an optional column added after a data file was\nwritten no longer refuses the bin: the file reads the column as null,\nso a real delete key cannot match its rows and a null key deletes them.\n\nGenerated with [Devin](https://devin.ai)\n\nCo-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * iceberg maintenance: write bin-pack merges under the files' union schema The writer schema is now the union of the bin's file schemas by field\nid, computed in a schema-only pass before any row is written: a column\nstays REQUIRED only where every file has it and spells it so, and the\nmerge refuses only true name/type/id conflicts. Files that need a union\nneither side covers (an added column plus a REQUIRED/OPTIONAL\ndifference, disjoint added columns) now merge in a single pass instead\nof refusing, and progressively wider bins no longer reread and rewrite\nevery earlier file per restart.\n\nGenerated with [Devin](https://devin.ai)\n\nCo-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * iceberg maintenance: spell the re-added column's test file for codespell Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * iceberg maintenance: resolve equality-delete columns by field id A column renamed after its data and delete files were written still carries its field id there; resolving it by id instead of the current name keeps a rename from turning every equality key null. The missing-column null-key fallback is now for data files only: an equality-delete file that lacks its equality column is refused, as the spec requires it to carry them. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * iceberg maintenance: read only the parquet footer choosing a bin's writer schema The union-schema pass downloaded every input in full, then the merge downloaded each again. The footer suffices for the schema, and a chunked file's ReadAt pulls only the chunks the footer spans. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> |
||
|
|
610346ae8c |
iceberg: keep version-hint.text out of remove_orphans (#11867) (#11871)
Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> |
||
|
|
6b6a268903 |
volume balance: stop replica-fallback moves between equally full servers (#11851)
* volume balance: unify the per-move convergence guard Evaluate the post-move utilization comparison through serverUtilization so the guard also applies when servers lack MaxVolumeCount info (raw-count mode), where it previously did not run at all. * volume balance: restrict fallback destinations to improving servers The score-based fallback inside createBalanceTask could redirect a move to any valid server, including ones as full as the source — between equally full servers the move only relocates the imbalance and the next detection cycle reverses it (#11839). Exclude from eligibleTargets any server whose post-move utilization would exceed the source's, so a fallback destination satisfies the same convergence guard as the loop-chosen target. * volume balance: skip a volume when the chosen target violates placement When the detection loop's target resolves but cannot host the replica (it already holds one, or is out of the filtered scope), createBalanceTask now returns nil so the loop advances to the next volume — matching shell volume.balance, which continues to the next candidate instead of redirecting the move to a different server. The score-based fallback is kept for the case where the target cannot be resolved at all; its allowed set is already limited to servers the move would improve. * volume balance: regression test for replica-constrained targets (#11839) Reproduces the reported loop: the emptiest server holds the second rp=001 replica of the lowest-ID volumes on the fuller servers, so it is never a legal target for them. Detection must skip those volumes and send the movable ones to the under-utilized server, and re-running detection after applying the plan must never move the same volume twice. |
||
|
|
d04d838ebd |
ec: compare live idx NeedleId sets before encode (#11812)
* ec: compare live idx NeedleId sets before encode Refuse encode when replicas' live .idx NeedleId sets differ. Walk only live rows (skip deleted and Size<=0) and compare NeedleId, ignoring Size so MIME/flags drift does not abort a matching id set. Mark the volume read-only for encode and reject writes after that. * fix(ec): compare all replicas then pick capacity source Log matching live idx sets with "replicas are consistent" for the shell CI check. After readonly, compare every replica's live NeedleId set, then require the encode source to have FreeVolumeCount>=2. Empty live-idx vs non-empty refuses encode instead of skipping superblock stubs. Drop the FileCount rebind after the idx gate. * volume: mark readonly under the write lock so checked appends finish first * ec: fix readonly deadlock and restore worker-host source preference MarkVolumeReadonly held dataFileAccessLock while calling reopenIdxForWrite, which re-acquires the same mutex and deadlocks TestMarkVolumeReadonlyCanDelete. Split out reopenIdxForWriteLocked for callers already holding the lock, matching the existing Locked pattern. The worker task lost its worker-host source preference when the idx gate replaced the replica union. Late-bind the source to a replica on the worker host using only the checked location set, with no FileCount rebinding. Drop the now-unused helpers, trim comments added by the earlier commits, and rename tests whose names still claimed convergence while asserting refusal. --------- Co-authored-by: Chepurnov Simon <195125934+CHEPURNOV-S-S@users.noreply.github.com> Co-authored-by: Devin <devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Chris Lu <chris.lu@gmail.com> |
||
|
|
443ae1cd83 |
s3 lifecycle: share daily bucket walk and prune listings (#11797)
* s3 lifecycle: share the daily bucket walk across shards The daily pass invoked the walker once per shard, and every shard's walk listed the full bucket tree while keeping only its own 1/16 of the entries — 16 full listings per pass by default (#11791). Run now groups the shards by the walk branch they'll take (recovery vs steady, using the same cursor data and hash checks runShard applies) and starts one shared walk per group, so a pass lists each bucket at most twice. WalkerFunc and WalkBuckets take a shard set instead of a single shard. runShard keeps its own decision and waits on its group's walk; a shard whose freshly-loaded cursor disagrees with the plan falls back to a per-shard walk, so mid-pass cursor rewrites can't under-cover a shard. * s3 lifecycle: skip the .versions/ pre-pass on non-versioned buckets walkBucketTree listed every directory twice — once looking for .versions/ dirs, once for regular entries. On a bucket that never had versioning enabled the first pass can only find coincidentally-named user folders, so the extra listing is pure cost (#11791). FilerListFunc now takes the walk view and consults Snapshot.BucketVersioned; non-versioned buckets skip pass 1 entirely. A *-suffixed .versions user folder on such a bucket is recursed into as a regular directory so real objects inside still surface; a nil view keeps the two-pass behavior. * s3 lifecycle: prune walk directories to active rule prefixes The daily walk listed every directory under a bucket even when no rule prefix could reach it. Collect the active rule prefixes of each bucket from the walk view (new Snapshot.BucketPrefixes) and skip recursing into directories whose keys can never match; a bucket with no active actions is skipped entirely, saving the listing. .uploads stays in scope regardless of prefixes because AbortMPU rules match DestKey, and .versions expansion is pruned only conservatively (the logical key is a string-prefix of the dir key). * s3 lifecycle: join planned walks before Run returns planWalks starts a shared walk goroutine per group, but a shard whose authoritative cursor load then fails exits runShard without waiting on it. Run returned while the walk still listed or dispatched deletes against connections the caller closes on return. Join every planned walk after the shard waitgroup. * s3 lifecycle: treat object-locked buckets as versioned in the walk Object Lock requires versioning and every writer sets both extended attributes, but IsBucketVersioned only read ExtVersioningKey. A locked bucket missing that attribute would have its .versions dirs walked as ordinary folders, hiding version siblings from lifecycle. Classify ExtObjectLockEnabledKey as versioned too. |
||
|
|
887b1aac76 |
ec: carry the source volume's TTL expiry into the worker-written .vif (#11777)
* ec: carry the source volume's TTL expiry into the worker-written .vif ReadVolumeFileStatus now reports the volume's ExpireAtSec (last write + TTL), and the admin worker stamps it into the .vif it distributes with the shards. Previously every worker-encoded .vif had expireAtSec 0, so EC volumes of TTL collections never expired. * ec: report expiry from the Rust volume server and cover the .vif carry The seaweed-volume drop-in server omitted expire_at_sec from its ReadVolumeFileStatus response, so worker-encoded volumes sourced from it lost the TTL. Fall back to the nested VolumeInfo expiry for servers that predate the top-level field, and pin the nonzero/zero carry with a test. |