OxL Reference

warning shard-count-clamped

warning Standard: [§12.8]

What it means#

@shard(by: .field, count: n) asks for n shards of the table. A table cannot have more shards than its database: on a database with fewer shards the count is clamped to the database's (and the program warns about it at run time when the table is first used). The compiler reports it in advance when the outcome does not depend on the run: every Db.open(...) of the program is a literal builtin://name?shards=N URL (an explicit shards= is not changed by OXL_BUILTIN_SHARDS or the cluster profile) and n is larger than the largest N. A URL that is not a literal, or a builtin:// URL without ?shards=, turns the check off. count: may be any compile-time integer expression (count: SHARDS, count: 4 * 4); a count below 1 is a table-schema error.

Example#

oxl✓ checked in CI
@table("orders") @shard(by: .userId, count: 16)   // <- shard-count-clamped: the program's database has 4 shards
data Order { @pk id: u64; userId: u64 }

fn main() io, db {
  let db = Db.open("builtin://shop?shards=4")!
}
error
shard-count-clamped

How to fix#

Lower count: to the number of shards of the database, or open the database with more shards (?shards=16). The number of shards of a table is stored with its data: reopening the database with a different count (or ?shards=) is refused with an error that says how many shards the table was created with (D-8320), because the rows written before would sit on the wrong shards. Rows are not migrated between shard sets; to change the count, read the rows with the old count and insert them into a new database with the new one.

See also#

OxL 1.0.0-beta · Documentation version 1.0.0-beta© OxwaldLink · generated from the Standard, the std sources and the guides