1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// SPDX-License-Identifier: BUSL-1.1
//! Boot-time authoritative rehydration of the Data Plane per-core schema
//! registry from the durable catalog.
//!
//! The per-core `doc_configs` registry (populated by `DocumentOp::Register`)
//! is in-memory only. On restart it starts empty; nothing in single-node
//! mode ever re-populates it, and in cluster mode it is only populated as
//! an unreliable fire-and-forget side effect of raft log replay. This
//! leaves strict-mode collections unable to decode their schema after a
//! restart, degrading `SELECT *` to a raw `(id, data)` tuple.
//!
//! [`rehydrate_schema_registry`] closes this gap: it enumerates every
//! active collection in every database from the durable catalog and
//! re-registers each one to all Data Plane cores, awaited and
//! fail-closed, in both single-node and cluster mode.
use HashSet;
use Arc;
use info;
use crateload_collections;
use cratedispatch_register_from_stored;
use crateSharedState;
/// Re-register every active stored collection to all Data Plane cores.
///
/// Returns `Ok(())` immediately if the catalog is not yet initialized
/// (fresh boot before catalog init — nothing persisted yet). On the first
/// registration failure, returns `Err` immediately without attempting the
/// remaining collections: an unregistered strict schema after restart is a
/// data-loss-shaped bug, so this path is fail-closed rather than
/// warn-and-continue.
///
/// Database enumeration (including the implicit `DatabaseId::DEFAULT`,
/// which carries no descriptor row in `_system.databases`) is shared with
/// the constraint-reconcile loop via [`load_collections`].
pub async
// No unit test here: even the `None`-catalog early-return path requires
// constructing a `SharedState`, which needs a live Data Plane / redb
// catalog wiring that this module cannot build in isolation. Coverage for
// both the early-return and populated-catalog paths belongs in an
// integration test exercising a full restart cycle.