* filer: RecursiveLister, a store capability to list a subtree in path order
The wrapper hands it to the default store, reading hard links as listings
do, and declines it when path-specific stores could hold part of the
subtree.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/sql: list a subtree with one range scan when rows are keyed by path
AbstractSqlStore lists recursively when its generator implements
RecursiveListSqlGenerator. The range runs from the directory and prefix to
the least string past every path starting with them. A directory whose
subtree spans the bucket tables is declined.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/postgres: the postgres_flat generator lists a path range
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/store_test: check recursive listings
Byte order across +, -, / and non-ASCII names, prefixes holding a slash,
literal % and _, resuming after a path, pages of one and three, a
directory outside the buckets, and the directories that span bucket
tables.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/sql: a recursive listing's start path outside the bucket table bounds it by full path
A start path in another bucket was trimmed as if it were inside this one, so
a start path past the bucket listed it all again, and one before it could
skip entries.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer/store_test: conformance suite for filer stores
Entries in and out of buckets, byte-ordered and prefixed listings,
key-value records, transactions, bucket tables and the snapshot scan.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer: run postgres2 and mysql2 through the conformance suite
RUN_POSTGRES_TESTS and RUN_MYSQL_TESTS enable them, as RUN_REDIS_TESTS
does the Redis stores; each test gets a schema or database of its own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* ci: give the go test job Postgres and MySQL services
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/sql: generators bind the arguments of row statements
Insert, update, find and delete now take the row key and return their
arguments with the query, so a generator decides how a key maps to its
columns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/sql: generators bind the arguments of directory statements
Listing and deleting a directory's children take the directory and return
their arguments with the query.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/sql: batch lookup takes row keys and matches rows by name and directory
A key-value key's directory column already determines its dirhash, so the
batch read no longer selects dirhash to match its rows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/postgres: build the connection string with pgxutil.BuildDSN
The credential store already does; it quotes values per libpq, so a
password or certificate path with spaces or quotes no longer breaks the
connection string. The OpenPGXDB alias has no callers left.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/sql: scan pages take the row key of the last row as their cursor
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/postgres: postgres and postgres2 share their connection setup
ReadConnection reads the settings and their defaults, Connection.Open
opens the store's pools.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/sql: key-value records may live in a table of their own
A store whose entry tables have another layout keeps its key-value
records in KvTable, written by KvSqlGenerator; its scans then read only
entries and need not tell the records apart.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/postgres: SQL generator keyed by the full path
Rows have path as their primary key; a (directory, name) unique
constraint serves the directory listings.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer: postgres_flat store
Entries are keyed by their full path, the object key inside a bucket's
table; buckets get tables of their own as in postgres2. Key-value
records keep the postgres2 layout in filemeta_kv. The store refuses a
filemeta table of another layout, so it needs a schema of its own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer: register postgres_flat and add it to the filer.toml scaffold
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/sql: test the arguments each generator binds
Each statement's arguments must match its placeholders in count and
column. Check them for every generator method, including the Postgres
UPDATE whose parameters are now numbered key first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/postgres_flat: name a missing filemeta table instead of a foreign layout
With createTable = false and no filemeta table, the layout check said the
table had no path column and blamed a postgres2 layout. Report the missing
table and the key-value table that also has to be created.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/postgres: postgres_flat escapes the table name inside its quotes
A double quote in it is doubled, as PostgreSQL reads a quoted identifier.
Bucket names cannot hold one, but the statements no longer rely on that.
Reported by CodeQL (go/unsafe-quoting).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/postgres: escape the table name inside its quotes
A double quote in it is doubled, as PostgreSQL reads a quoted identifier.
Bucket names cannot hold one; the statements no longer rely on that.
Reported by CodeQL (go/unsafe-quoting) on the lines this branch changed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/postgres: postgres_flat shares the generator's tableIdent
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/postgres: keep the nameExpr doc comment on nameExpr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/postgres_flat: find filemeta along the search path when checking its layout
The store's queries name filemeta unqualified, so with schema = "a,b" they
reach a table in b; the layout check looked in current_schema() only and
refused it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/postgres_flat: force byte order when the path column is locale-ordered
Directory listings order and bound rows by path, but only the name
column's collation was checked. A createTable with a locale-ordered path
column listed in locale order, and byte-order bounds missed entries.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/postgres: read the ordered columns' collation along the search path
The collation check looked for filemeta in current_schema() only. With the
tables in a later schema of the search path it found no column and took the
database's order, so a locale-ordered path column next to a C database went
unforced, and byte-ordered columns in a locale database got a needless sort.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/postgres_flat: list a directory from its path range
A directory's children are the rows of its path range whose directory is
the listed one. The listing reads that range in growing batches and skips
the rows of the children's subtrees in Go, so a versioned object's
.versions rows cost no query of their own. Past 64 rows of one subtree it
queries again from that subtree's end. A name prefix narrows the range.
Listing no longer reads the (directory, name) index.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/postgres_flat: find a folder's children in its path range
Deleting a folder's children looked them up by directory alone, which
only the (directory, name) index serves. Bound the delete by the
folder's path range as well.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/postgres_flat: key the table by path alone
Listing and deleting a folder's children both read the path range now,
so the (directory, name) unique index only cost writes and storage:
flatPath already makes the path unique per (directory, name).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/postgres: read the ICU or builtin database locale before datcollate
An ICU-default database can report datcollate 'C' while its default
collation orders by the ICU locale, so a name column on the database
default looked byte-ordered and the listing kept locale order. Read
datlocprovider and the provider locale (via to_jsonb, so servers before
Postgres 15 still answer) and treat an ICU default as locale-ordered.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/postgres_flat: list a folder's children from its path range
The bucket enumeration listed /buckets by directory and ordered by name,
a sequential scan and sort now that path is the only index. Read the
folder's path range in path order instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/postgres_flat: only the path column needs byte order
Listings now order and range by path alone, and directory and name are
only compared for equality, which no deterministic collation changes.
Drop their COLLATE "C" and check only the path column's order.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer/store_test: conformance suite for filer stores
Entries in and out of buckets, byte-ordered and prefixed listings,
key-value records, transactions, bucket tables and the snapshot scan.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer: run postgres2 and mysql2 through the conformance suite
RUN_POSTGRES_TESTS and RUN_MYSQL_TESTS enable them, as RUN_REDIS_TESTS
does the Redis stores; each test gets a schema or database of its own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* ci: give the go test job Postgres and MySQL services
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/sql: generators bind the arguments of row statements
Insert, update, find and delete now take the row key and return their
arguments with the query, so a generator decides how a key maps to its
columns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/sql: generators bind the arguments of directory statements
Listing and deleting a directory's children take the directory and return
their arguments with the query.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/sql: batch lookup takes row keys and matches rows by name and directory
A key-value key's directory column already determines its dirhash, so the
batch read no longer selects dirhash to match its rows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/sql: scan pages take the row key of the last row as their cursor
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/sql: test the arguments each generator binds
Each statement's arguments must match its placeholders in count and
column. Check them for every generator method, including the Postgres
UPDATE whose parameters are now numbered key first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/postgres: escape the table name inside its quotes
A double quote in it is doubled, as PostgreSQL reads a quoted identifier.
Bucket names cannot hold one; the statements no longer rely on that.
Reported by CodeQL (go/unsafe-quoting) on the lines this branch changed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
* filer/postgres: keep the nameExpr doc comment on nameExpr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer: read KV keys a few at a time for a store without batch reads
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* abstract_sql: read KV keys with one query
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* redis: read KV keys in one pipeline
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* etcd: read KV keys in read-only transactions
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mongodb: read KV keys with one query
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* cassandra: read KV keys concurrently
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* hbase: read KV keys concurrently
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* elastic: read KV keys concurrently
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* arangodb: read KV keys with one request
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* foundationdb: read KV keys in one transaction
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* ydb: read KV keys with one query
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* tarantool: send KV reads before waiting for any
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: every filer store reads KV keys in batches
KvBatchGet moves from the optional KvBatchReader onto FilerStore. A listing
now reads the hard link records of its waiting entries together from any
store, a path-specific one included.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* tikv: count only the record reads of a listing in its test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: return every batched key that pads to the same stored row
SQL, MongoDB and YDB pad a short KV key with zero bytes, so "short" and
"short\x00" read the same row. KvBatchGet kept only the last such key.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: read keys in a plain loop when KvGetEach runs one at a time
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer: run a file rename again when the store refuses its commit
TiKV refuses an optimistic transaction's commit when another writer
committed one of its keys after it began. A rename's transaction moves the
source key, so a concurrent write of the file, through another filer for
instance, failed the rename with "move commit error: write conflict".
Standalone writes run again after such a conflict since #12798, but a
rename's transaction belongs to the rename, and it gave up.
StreamRenameEntry also sent the rename's responses before the commit, so
the client had already moved the file locally when the store refused it.
- The TiKV store reports such a refusal as filer.ErrTransactionConflict.
- A file rename runs its transaction again after it, up to five times; the
new run reads what the other writer stored and moves that. A rename that
copied or deleted a remote object on the way is not run again.
- On a store whose transactions keep their writes to themselves
(filer.IsolatingTransaction: SQL, TiKV), a file rename holds its stream
responses until the commit: a refused rename sends none, and one that
runs again sends them once. A directory rename still streams its
children's responses as it moves them, which keeps the client of a long
rename from timing out, and is not run again.
- Every failed run releases its commit stamps and rolls back, the "is not
empty" refusal included.
Tests: filer_grpc_server_rename_conflict_test.go, with a store that keeps a
transaction's writes until its commit and can refuse it, and
tikv_store_commit_test.go (-tags tikv). On master the retry, refused-commit
and remote-file tests fail.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: run a rename again only when its transaction covers every write
With path-specific stores configured, the writes under their prefixes do
not go through the default store's transaction: a parent directory a rename
creates at its destination there stays when the commit is refused, and a
rename run again finds it and announces only the file's move, so peers
replaying the events never learn of the parent.
IsolatingTransaction now holds only when no path-specific store is
configured, and AtomicRenameEntry checks it too before running a rename
again, as StreamRenameEntry does through its held responses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: finish a committed rename before its held responses go out
StreamRenameEntry sent its held responses before the work the commit leaves
(metadata events, chunk deletions, remote copies). A client that stops
reading without closing the stream blocks Send on flow control, and that
work then never ran. It now runs first; the responses still follow the
commit.
A file with a remote object no longer holds its responses: its remote copy
after the commit is part of that work, and the client should not wait for
it. It streams as it moves, as before, and is not run again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: let the store say that its transactions isolate a rename
Whether a rename's responses wait for the commit, and whether it may run
again, was inferred from the context BeginTransaction returned and from
whether any path-specific store was configured. Neither holds up:
- A store may hand back a transaction context that its writes do not use:
YDB begins a table-service transaction, and its statements run through
the query service outside it. A store now says so itself, through
IsolatingTransactionStore, which the TiKV store implements. Any other
store keeps sending a rename's responses as the entries move and does not
run it again, as before this PR.
- A path-specific store only matters for the paths it holds.
Filer.TransactionCovers asks whether the rename's source and destination
live in the default store: a rename that stays there holds its responses
and may run again, and one that writes into a path-specific store does
neither.
A rename that may not run again still must not announce changes before its
commit, so a file with a remote object holds its responses too. So that its
remote copy after the commit does not delay them, the held responses go out
while the rename finishes, and the call returns once both are done.
A held response checks the stream's context, so a rename whose client went
away before its first response is rolled back, as when the responses go
out at once, instead of committed unseen.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* filer: the SQL stores isolate their transactions too
AbstractSqlStore takes the sql.Tx its context carries for every entry call
(getTxOrDB) and every KV call (kvDB, also when KV has a pool of its own),
so the SQL stores built on it meet what IsolatingTransactionStore asks. A
file rename on them holds its responses until the commit again, as it did
before the declaration became explicit; it is never run again, since no
SQL store reports ErrTransactionConflict.
Bucket tables are created and dropped outside the transaction, which a
file rename does not do.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* abstract_sql: check that a transaction's writes take its own handle
sqlmock serves a pool and its transactions from one mock, so the write
expectations also pass for entry writes made through store.DB. Assert that
getTxOrDB and kvDB return the *sql.Tx the context carries.
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>
* filer: report a SQL listing that fails partway through
ListDirectoryPrefixedEntries never checked rows.Err() after its rows.Next()
loop. When the result set failed partway, for example on a lost
connection, rows.Next() returned false and the listing returned the
entries read so far with a nil error, so callers saw a shorter directory
instead of an error. Check rows.Err() once the loop has run to the end,
as the scan in abstract_sql_store_scan.go already does. A listing the
callback stopped on purpose is left alone: rows.Err() would return a
canceled request context's error there.
This covers every store built on AbstractSqlStore (mysql, mysql2,
postgres, postgres2, sqlite).
Signed-off-by: anant <170962632+antcybersec@users.noreply.github.com>
* filer: wait for the canceled SQL listing to release its rows in the test
A fixed sleep let the callback return before database/sql closed the
rows, so a listing that always consulted rows.Err could still pass.
Wait, bounded, until the connection is back in the pool instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Signed-off-by: anant <170962632+antcybersec@users.noreply.github.com>
Co-authored-by: anant <170962632+antcybersec@users.noreply.github.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer: validate bucket names before the SQL DDL hooks
The SQL store builds CREATE TABLE and DROP TABLE statements by formatting
the bucket name into the query. The DML paths already reject names that
fail VerifyS3BucketName, but the bucket-creation and bucket-deletion
hooks ran the DDL without that check, so a name reaching them through the
filer or WebDAV directory path (which skips the check for dot-prefixed
directories) could inject stacked statements. Apply the same validation
the DML paths use.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* filer: check that a valid bucket runs both DDL statements
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* shell: volume.fsck reads the filer from one store snapshot when it can
volume.fsck collects the filer's chunk references by walking directory
by directory, so each directory is seen at a different time. A file
renamed from a directory not yet listed into one already listed is never
seen, its chunks look like orphans, and -reallyDeleteFromVolume deletes
live data. Checkpoint rotation and write-to-tmp-then-rename hit this.
Add an optional filer store capability, EntryScanner, that visits every
entry below a directory from one consistent snapshot. The SQL stores
implement it with one REPEATABLE READ read-only transaction read in
primary-key pages, so a concurrent rename is seen under exactly one of
its names. Key-value rows are skipped by their dirhash, a bucket
directory whose table is missing fails the scan (from the snapshot it
cannot be told from one dropped a moment ago), and hard links are
resolved in the same transaction. SQLite offers it only in WAL mode, on
its own connection.
TraverseBfsMetadata serves the snapshot when asked via request metadata
sw-traverse-mode=snapshot and reports the mode in a response header;
without the metadata it walks as before, so peer bootstrap and admin
export are unchanged. Snapshot responses carry no entry_ts_ns, whose
per-entry lookup would cost more than the scan.
volume.fsck requests the snapshot and falls back to the walk on an older
filer or a store that cannot scan.
* filer, shell: fail a scan that cannot start, not fall back to the walk
A transient BeginTx failure and a preliminary GetEntry error were treated
like a missing capability or missing root, so fsck would take the
directory walk - the very path that misses renamed-away entries. Only a
genuinely unsupported scan or a confirmed-absent root may fall back.
* filer: only snapshot-listed bucket names keep a missing table fatal
A cached-only name, whose bucket may have been deleted between copying
the cache and opening the snapshot, is skipped when its table is gone.
* filer: roll back to a savepoint before skipping a cached-only table
On PostgreSQL a failed statement aborts the snapshot transaction, so
ignoring a missing-table error without the savepoint still left every
later cached-only table unreadable.
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
* filer: escape LIKE wildcards in SQL list prefixes
ListDirectoryPrefixedEntries bound prefix+"%" straight into a LIKE
clause, so '_' and '%' in object names (e.g. Langfuse keys like
call_03_...) acted as wildcards: wrong results and a ~40x slower
range scan because (dirhash, name) can no longer be narrowed.
Escape '!'/'%'/'_' in the prefix and declare ESCAPE '!' in the
generated list SQL so every abstract_sql backend (mysql, mysql2,
postgres, postgres2, sqlite) matches literally with identical
semantics. '!' is used instead of '\' because SQLite shares
SqlGenMysql but would reject the MySQL-style '\\' literal, and
'\' would still need escaping itself.
* filer: escape LIKE wildcards in YDB list prefixes
Same wildcard-in-prefix bug as the abstract_sql backends: YQL LIKE
treated '_' and '%' in the prefix as wildcards. Apply the shared
LikePattern helper and declare ESCAPE '!' (YQL allows any escape
char except '%', '_' and '\').
* test: cover literal '_'/'%'/'!' prefixes in sqlite filer listing
End-to-end regression test through SqliteStore against a real
database; runs in CI under the sqlite build tag.
* filer/postgres: create default filemeta table on startup
The postgres filer store hardcoded CreateTableSqlTemplate to empty and
never created the filemeta table, unlike postgres2/mysql2/sqlite which
all create it during Initialize. Users had to create the table manually
or the filer would crash loop with "relation filemeta does not exist".
Read the createTable config option (same as postgres2), default to
DefaultCreateTableQuery when unset, and execute CREATE TABLE IF NOT EXISTS
on the default table after the connection pool is established.
SupportBucketTable stays false so per-bucket table creation remains a
no-op; only the shared filemeta table is created, via a direct ExecContext
since AbstractSqlStore.CreateTable short-circuits without bucket support.
* filer/postgres: accept boolean createTable = true/false
viper reads a TOML boolean as the string "true"/"false" via GetString, so
createTable = true was being used as a SQL template and failed. Add
ResolveCreateTableQuery to normalize the value: true and empty select the
default template, false disables table creation, anything else is a custom
template. Both postgres and postgres2 now use it, and both skip the CREATE
TABLE call when the resolved template is empty.
* scaffold: document createTable option for postgres filer store
Replace the commented-out CREATE TABLE SQL in the [postgres] scaffold with
a createTable config hint, matching the [postgres2] section. Users no longer
need to manually create the filemeta table before starting the filer.
* filer/postgres: make createTable opt-in for postgres, keep postgres2 default
The previous commit defaulted postgres to create the filemeta table even
when createTable was unset, which could break existing deployments whose
DB user lacks CREATE TABLE privileges. ResolveCreateTableQuery now returns
empty for an unset value so postgres only creates the table when
createTable is explicitly true or a custom template — preserving the
prior no-DDL behaviour for existing configurations.
postgres2 keeps its existing always-create default: it defaults an empty
resolved value to DefaultCreateTableQuery, and only skips when
createTable is explicitly false.
* filer/postgres2: simplify createTable handling, document all modes
Drop the false opt-out from postgres2 — it only skipped the default table
while per-bucket CreateTable still ran, leaving restricted DB roles broken
on bucket access. postgres2 now accepts true the same way (defaulting to
DefaultCreateTableQuery) and keeps its existing always-create behaviour
for every other value, matching the original semantics.
The scaffold comment now documents true/false/custom for the postgres
section so users know false (or unset) is the backward-compatible default.
* filer/postgres2: normalize false via ResolveCreateTableQuery
postgres2 only handled "" and "true", leaving createTable = false as the
literal string "false" which CreateTable then executed as invalid SQL.
Route it through ResolveCreateTableQuery (which maps false to empty) and
default the empty result to DefaultCreateTableQuery, so false is treated
the same as unset for the bucket-aware store.
* filer/postgres2: honor createTable = false for default table
postgres2 treated false the same as unset and always created the default
filemeta table, failing startup for restricted DB roles that explicitly
opted out. Track the original false value before ResolveCreateTableQuery
collapses it to empty, and skip the default CreateTable call when set.
Per-bucket table creation is unaffected — it is a runtime requirement of
the bucket-aware store. Users who need to suppress all DDL should use the
postgres (non-bucket) store with createTable unset.
* filer/postgres2: disable bucket tables when createTable = false
Setting SupportBucketTable = false when createTable is explicitly false
makes AbstractSqlStore.CreateTable a no-op (it already returns nil when
SupportBucketTable is false), so neither the default filemeta table nor
per-bucket tables are created. The template stays empty and no DDL runs,
honouring the opt-out for restricted DB roles. All data routes to the
pre-provisioned filemeta table, matching the postgres (non-bucket) store.
* filer: suppress DDL without disabling bucket routing
Setting SupportBucketTable = false when createTable = false also disabled
per-bucket routing, hiding objects in pre-provisioned per-bucket tables.
Keep SupportBucketTable true and instead skip the CREATE TABLE execution
when the resolved template is empty.
GetSqlCreateTable now returns empty for both postgres and mysql SQL
generators when CreateTableSqlTemplate is empty, and
AbstractSqlStore.CreateTable skips the ExecContext call when the SQL is
empty. This preserves bucket routing while suppressing all DDL for users
who explicitly set createTable = false and pre-provision their tables.
* filer: add SkipDDL to suppress CREATE and DROP without disabling routing
createTable = false with SupportBucketTable = true preserved bucket
routing but deleteTable still executed DROP TABLE on bucket deletion,
dropping externally managed tables. CanDropWholeBucket also returned
true, so the S3 layer tried whole-table drops instead of row-by-row
deletes.
Add a SkipDDL flag to AbstractSqlStore, independent of SupportBucketTable.
CreateTable and deleteTable both skip when SkipDDL is set, and
CanDropWholeBucket returns false so bucket deletion falls back to
row-by-row metadata deletes. postgres2 sets SkipDDL when createTable is
explicitly false — bucket routing is preserved, no DDL runs.
* filer: fall back to row-by-row delete when CanDropWholeBucket is false
DeleteFolderChildren took the whole-table drop path whenever the path was
a bucket root, even when SkipDDL made deleteTable a no-op. The no-op
returned nil, the caller returned early, and rows inserted after the
recursive enumeration survived the bucket deletion.
Gate the whole-table drop on CanDropWholeBucket so the row-by-row
DeleteFolderChildren SQL runs when SkipDDL is set, removing all metadata
without issuing DROP TABLE.
* filer: give the SQL stores' key-value reads their own connections
A listing holds the connection its rows are on for the whole iteration, and
FilerStoreWrapper calls maybeReadHardLink -> KvGet from inside that iteration,
so a hard-linked entry needs a second connection while the first is still busy.
Out of one bounded pool that is a deadlock: the listings fill the pool and then
wait for a connection none of them will release, and the wrapper's
context.WithoutCancel leaves the waiters without a deadline, so the filer stays
wedged rather than erroring.
The sqlite store shows it at its sharpest -- it allows a single connection, so
one listing over one hard-linked entry never returns. On postgres with
connection_max_open = 50, 60 concurrent listings over hard-linked entries made
no progress at all.
Key-value reads now run on their own pool, carved out of connection_max_open
rather than added to it, so the operator's cap still bounds what the store opens
against the database. An unbounded pool keeps a single pool: nothing can wait
there. sqlite's single connection becomes two, one per pool, and its writes get
a busy timeout so a write that meets the reader waits instead of failing.
Claude-Session: https://claude.ai/code/session_018DWwctzD4T2DmnczPRM47t
* sqlite: keep both pools on one database, whatever the dbFile spells
A dbFile that already carries URI options got a second "?" appended, which the
driver reads as part of the preceding option value, and a bare :memory: is
private to each connection, so the key-value pool would open its own empty
database and every key-value operation would fail on a missing filemeta.
Claude-Session: https://claude.ai/code/session_018DWwctzD4T2DmnczPRM47t
* sqlite: assert the busy timeout on the in-memory DSN too
Claude-Session: https://claude.ai/code/session_018DWwctzD4T2DmnczPRM47t
* filer: keep .system internal folder in the default SQL table
Bucket-table SQL stores read the first path segment under /buckets as a
bucket name. The ListBuckets owner index lives at /buckets/.system/..., so
every write there hit isValidBucket(".system") == false and returned
"invalid bucket name .system", flooding the filer log on the postgres/mysql
backends. Route dot-prefixed internal folders to the default table by their
full path, like any other non-bucket entry.
* filer: keep .system internal folder in the default leveldb3 DB
Same guard as the SQL stores: leveldb3 would otherwise open a separate DB
for the .system owner-index folder instead of keeping it in the default DB.
* filer: keep .system internal folder under the default ydb prefix
Skips a DescribeTable round trip per operation on the .system owner-index
path, which never resolves to a real bucket table.
* filer: keep .system internal folder in the default arangodb collection
Avoids creating a stray collection for the .system owner-index folder.
* Fix chown Input/output error on large file sets (Fixes#7911)
Implemented retry logic for MySQL/MariaDB backend to handle transient errors like deadlocks and timeouts.
* Fix syntax error: missing closing brace
* Refactor: Use %w for error wrapping and errors.As for extraction
* Fix: Disable retry logic inside transactions
* refactoring
* add ec shard size
* address comments
* passing task id
There seems to be a disconnect between the pending tasks created in ActiveTopology and the TaskDetectionResult returned by this function. A taskID is generated locally and used to create pending tasks via AddPendingECShardTask, but this taskID is not stored in the TaskDetectionResult or passed along in any way.
This makes it impossible for the worker that eventually executes the task to know which pending task in ActiveTopology it corresponds to. Without the correct taskID, the worker cannot call AssignTask or CompleteTask on the master, breaking the entire task lifecycle and capacity management feature.
A potential solution is to add a TaskID field to TaskDetectionResult and worker_pb.TaskParams, ensuring the ID is propagated from detection to execution.
* 1 source multiple destinations
* task supports multi source and destination
* ec needs to clean up previous shards
* use erasure coding constants
* getPlanningCapacityUnsafe getEffectiveAvailableCapacityUnsafe should return StorageSlotChange for calculation
* use CanAccommodate to calculate
* remove dead code
* address comments
* fix Mutex Copying in Protobuf Structs
* use constants
* fix estimatedSize
The calculation for estimatedSize only considers source.EstimatedSize and dest.StorageChange, but omits dest.EstimatedSize. The TaskDestination struct has an EstimatedSize field, which seems to be ignored here. This could lead to an incorrect estimation of the total size of data involved in tasks on a disk. The loop should probably also include estimatedSize += dest.EstimatedSize.
* at.assignTaskToDisk(task)
* refactoring
* Update weed/admin/topology/internal.go
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* fail fast
* fix compilation
* Update weed/worker/tasks/erasure_coding/detection.go
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* indexes for volume and shard locations
* dedup with ToVolumeSlots
* return an additional boolean to indicate success, or an error
* Update abstract_sql_store.go
* fix
* Update weed/worker/tasks/erasure_coding/detection.go
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* Update weed/admin/topology/task_management.go
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* faster findVolumeDisk
* Update weed/worker/tasks/erasure_coding/detection.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update weed/admin/topology/storage_slot_test.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* refactor
* simplify
* remove unused GetDiskStorageImpact function
* refactor
* add comments
* Update weed/admin/topology/storage_impact.go
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* Update weed/admin/topology/storage_slot_test.go
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* Update storage_impact.go
* AddPendingTask
The unified AddPendingTask function now serves as the single entry point for all task creation, successfully consolidating the previously separate functions while maintaining full functionality and improving code organization.
---------
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
The exisitng key-value operation for stores using mysql, postgres, and maybe cassandra are already broken.
The kv is used to store hardlink, filer store signature and replication progress.
So users using hardlink and also uses mysql, postgres, or cassandra will have broken hard links.
Users using filer.sync will need to re-sync the files.