nats: a ledger's state and index buckets take the ledger's own max-mib

The keeper planned a ledger's state bucket and each index bucket with no
option, so each was the state default of 64 MiB whatever the ledger asked,
while its history and snapshot took max-mib. The delivery gate's ledger asks
1024 and its state bucket filled at 64. The state and index buckets now take
the ledger's max-mib and no other of its options; a ledger with none keeps
the state default. A raised cap reaches a held bucket through the keeper's
existing path for larger settings (check at the first view after a start).

The keeper's plan test: the existing ledger row now expects its state and
index buckets at the ledger's 16 MiB; a row with max-mib 1024 (and a past-values
option that must not reach them) expects 1 GiB; a row with none expects 64 MiB.

Design 47 H2's corrections, item 12 (lead answer H-A-636).

Builds: design 47 H2 H-A-636 (corrections, item 12)
This commit is contained in:
2026-11-24 01:39:00 +01:00
parent 008ac6332f
commit 0f648e26dd
2 changed files with 25 additions and 2 deletions
+18 -1
View File
@@ -327,6 +327,11 @@ func entry(name, storage, template string, options map[string]string) catalogue.
func TestEachTemplateIsPlannedUnderTheModulesNames(t *testing.T) { func TestEachTemplateIsPlannedUnderTheModulesNames(t *testing.T) {
ledger := entry("records", catalogue.StorageLedger, catalogue.TemplateLedger, map[string]string{"max-mib": "16"}) ledger := entry("records", catalogue.StorageLedger, catalogue.TemplateLedger, map[string]string{"max-mib": "16"})
ledger.Types = []catalogue.LedgerType{{Name: "decision", Indexes: []catalogue.LedgerIndex{{Name: "by-topic", On: []string{"topic"}}}}} ledger.Types = []catalogue.LedgerType{{Name: "decision", Indexes: []catalogue.LedgerIndex{{Name: "by-topic", On: []string{"topic"}}}}}
// A ledger's state and index buckets take its max-mib and no other option of it (design 47 H2's corrections, item 12, H-A-636).
bigLedger := entry("records", catalogue.StorageLedger, catalogue.TemplateLedger, map[string]string{"max-mib": "1024", "history": "5"})
bigLedger.Types = ledger.Types
plainLedger := entry("records", catalogue.StorageLedger, catalogue.TemplateLedger, nil)
plainLedger.Types = ledger.Types
bare := entry("raw", catalogue.StorageStream, "", nil) bare := entry("raw", catalogue.StorageStream, "", nil)
bare.Configuration = map[string]json.RawMessage{"when-full": json.RawMessage(`"drop-oldest"`), "max-mib": json.RawMessage("8"), "max-age-days": json.RawMessage("3")} bare.Configuration = map[string]json.RawMessage{"when-full": json.RawMessage(`"drop-oldest"`), "max-mib": json.RawMessage("8"), "max-age-days": json.RawMessage("3")}
forGood := entry("reviews", catalogue.StorageStream, "", nil) forGood := entry("reviews", catalogue.StorageStream, "", nil)
@@ -368,9 +373,21 @@ func TestEachTemplateIsPlannedUnderTheModulesNames(t *testing.T) {
binding: "objects mesh-knowledge_outputs"}, binding: "objects mesh-knowledge_outputs"},
{name: "ledger", entry: ledger, {name: "ledger", entry: ledger,
objects: "stream mesh-knowledge_records [mesh.ledger.mesh-knowledge.records.history.>] {16 MiB, age 0, history 0, new, size 262144}; " + objects: "stream mesh-knowledge_records [mesh.ledger.mesh-knowledge.records.history.>] {16 MiB, age 0, history 0, new, size 262144}; " +
"key-value mesh-knowledge_records_state {16 MiB, age 0, history 1, new, size 262144}; " +
"key-value mesh-knowledge_records_index-by-topic {16 MiB, age 0, history 1, new, size 262144}; " +
"stream mesh-knowledge_records_snapshot [mesh.ledger.mesh-knowledge.records.snapshot.>] {16 MiB, age 0, history 1, old, size 0}",
binding: "history mesh-knowledge_records on mesh.ledger.mesh-knowledge.records.history, state mesh-knowledge_records_state, indexes map[by-topic:mesh-knowledge_records_index-by-topic], snapshot mesh.ledger.mesh-knowledge.records.snapshot"},
{name: "ledger naming max-mib 1024 and past values: its state and index buckets at 1 GiB, no other option reaching them (H-A-636)", entry: bigLedger,
objects: "stream mesh-knowledge_records [mesh.ledger.mesh-knowledge.records.history.>] {1024 MiB, age 0, history 0, new, size 262144}; " +
"key-value mesh-knowledge_records_state {1024 MiB, age 0, history 1, new, size 262144}; " +
"key-value mesh-knowledge_records_index-by-topic {1024 MiB, age 0, history 1, new, size 262144}; " +
"stream mesh-knowledge_records_snapshot [mesh.ledger.mesh-knowledge.records.snapshot.>] {1024 MiB, age 0, history 1, old, size 0}",
binding: "history mesh-knowledge_records on mesh.ledger.mesh-knowledge.records.history, state mesh-knowledge_records_state, indexes map[by-topic:mesh-knowledge_records_index-by-topic], snapshot mesh.ledger.mesh-knowledge.records.snapshot"},
{name: "ledger naming no max-mib: its state and index buckets at the state default (H-A-636)", entry: plainLedger,
objects: "stream mesh-knowledge_records [mesh.ledger.mesh-knowledge.records.history.>] {1024 MiB, age 0, history 0, new, size 262144}; " +
"key-value mesh-knowledge_records_state {64 MiB, age 0, history 1, new, size 262144}; " + "key-value mesh-knowledge_records_state {64 MiB, age 0, history 1, new, size 262144}; " +
"key-value mesh-knowledge_records_index-by-topic {64 MiB, age 0, history 1, new, size 262144}; " + "key-value mesh-knowledge_records_index-by-topic {64 MiB, age 0, history 1, new, size 262144}; " +
"stream mesh-knowledge_records_snapshot [mesh.ledger.mesh-knowledge.records.snapshot.>] {16 MiB, age 0, history 1, old, size 0}", "stream mesh-knowledge_records_snapshot [mesh.ledger.mesh-knowledge.records.snapshot.>] {1024 MiB, age 0, history 1, old, size 0}",
binding: "history mesh-knowledge_records on mesh.ledger.mesh-knowledge.records.history, state mesh-knowledge_records_state, indexes map[by-topic:mesh-knowledge_records_index-by-topic], snapshot mesh.ledger.mesh-knowledge.records.snapshot"}, binding: "history mesh-knowledge_records on mesh.ledger.mesh-knowledge.records.history, state mesh-knowledge_records_state, indexes map[by-topic:mesh-knowledge_records_index-by-topic], snapshot mesh.ledger.mesh-knowledge.records.snapshot"},
{name: "bare stream", entry: bare, {name: "bare stream", entry: bare,
objects: "stream mesh-knowledge_raw [mesh.bus.mesh-knowledge.raw.>] {8 MiB, age 259200, history 0, old, size 0}", objects: "stream mesh-knowledge_raw [mesh.bus.mesh-knowledge.raw.>] {8 MiB, age 259200, history 0, old, size 0}",
+7 -1
View File
@@ -229,7 +229,13 @@ func PlanOf(module string, e catalogue.BusStateEntry) (Plan, error) {
return Plan{}, err return Plan{}, err
} }
history.MaxAgeSeconds = days(age) history.MaxAgeSeconds = days(age)
state, err := stateSettings(options{}) // The state bucket and each index bucket take the ledger's own max-mib, as its history and snapshot do, and no
// other option of it; with none they keep the state default (design 47 H2's corrections, item 12, H-A-636).
stateOpts := options{}
if raw, ok := opts.raw[catalogue.OptionCapMiB]; ok {
stateOpts.raw = map[string]json.RawMessage{catalogue.OptionCapMiB: raw}
}
state, err := stateSettings(stateOpts)
if err != nil { if err != nil {
return Plan{}, err return Plan{}, err
} }