Commit 61106a9
committed
feat: add unified schema storage with ReadStoredSchema/WriteStoredSchema
Introduce the foundation for unified schema storage, where the entire
compiled schema (definitions + schema text + hash) is stored as a single
serialized proto blob, chunked across rows for SQL datastores.
Datastore interface changes:
- Add ReadStoredSchema(ctx, SchemaHash) to Reader interface
- Add WriteStoredSchema(ctx, *StoredSchema) to ReadWriteTransaction
- Add SchemaHash type with sentinel values for cache bypass
DataLayer interface changes:
- SnapshotReader now takes (Revision, SchemaHash) to thread cache keys
- OptimizedRevision/HeadRevision return SchemaHash alongside Revision
- Add SchemaMode configuration for migration path (legacy → dual → new)
- Add storedSchemaReaderAdapter for reading from StoredSchema protos
- Add writeSchemaViaStoredSchema for building and writing StoredSchema
Storage implementation:
- Add SQLByteChunker generic chunked blob storage for SQL datastores
- Add SQLSingleStoreSchemaReaderWriter for read/write of StoredSchema
- Add per-datastore ReadStoredSchema/WriteStoredSchema implementations
for postgres, crdb, mysql, spanner, and memdb
- Add schema table migrations for all SQL datastores
- Add populate migrations to backfill from legacy namespace/caveat tables
- Rename MySQL schema table to stored_schema (schema is a reserved word)
Caching:
- Add SchemaHashCache with LRU + singleflight for schema-by-hash lookups
Proxy/middleware updates:
- Add ReadStoredSchema/WriteStoredSchema pass-through to all datastore
proxies (observable, counting, readonly, singleflight, indexcheck,
strictreplicated, checkingreplicated, relationshipintegrity, hashcache)
- Update consistency middleware for new HeadRevision/OptimizedRevision
signatures
Proto changes:
- Add StoredSchema message to core.proto with V1StoredSchema containing
schema_text, schema_hash, namespace_definitions, caveat_definitions1 parent fd6ca35 commit 61106a9
File tree
127 files changed
+7047
-409
lines changed- internal
- caveats
- datastore
- common
- crdb
- migrations
- memdb
- mysql
- migrations
- postgres
- migrations
- proxy
- hashcache
- indexcheck
- proxy_test
- schemacaching
- spanner
- migrations
- dispatch
- caching
- combined
- graph
- keys
- remote
- singleflight
- graph
- computed
- middleware/pertoken
- namespace
- relationships
- services
- integrationtesting
- consistencytestutil
- v1
- testfixtures
- pkg
- cache
- datalayer
- datastore
- mocks
- test
- development
- middleware/consistency
- proto
- core/v1
- dispatch/v1
- impl/v1
- query
- benchmarks
- services/v1
- proto/internal
- core/v1
- dispatch/v1
- impl/v1
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
127 files changed
+7047
-409
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
| 474 | + | |
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
| |||
524 | 524 | | |
525 | 525 | | |
526 | 526 | | |
527 | | - | |
| 527 | + | |
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
| |||
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
559 | | - | |
| 559 | + | |
560 | 560 | | |
561 | 561 | | |
562 | 562 | | |
| |||
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
597 | | - | |
| 597 | + | |
598 | 598 | | |
599 | 599 | | |
600 | 600 | | |
| |||
662 | 662 | | |
663 | 663 | | |
664 | 664 | | |
665 | | - | |
| 665 | + | |
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
| |||
697 | 697 | | |
698 | 698 | | |
699 | 699 | | |
700 | | - | |
| 700 | + | |
701 | 701 | | |
702 | 702 | | |
703 | 703 | | |
| |||
742 | 742 | | |
743 | 743 | | |
744 | 744 | | |
745 | | - | |
| 745 | + | |
746 | 746 | | |
747 | 747 | | |
748 | 748 | | |
| |||
823 | 823 | | |
824 | 824 | | |
825 | 825 | | |
826 | | - | |
| 826 | + | |
827 | 827 | | |
828 | 828 | | |
829 | 829 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
84 | 99 | | |
85 | 100 | | |
86 | 101 | | |
87 | 102 | | |
88 | 103 | | |
89 | 104 | | |
90 | | - | |
91 | | - | |
92 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
93 | 108 | | |
94 | | - | |
| 109 | + | |
95 | 110 | | |
96 | 111 | | |
97 | | - | |
| 112 | + | |
98 | 113 | | |
99 | 114 | | |
100 | | - | |
| 115 | + | |
101 | 116 | | |
102 | 117 | | |
103 | | - | |
| 118 | + | |
104 | 119 | | |
105 | 120 | | |
106 | | - | |
| 121 | + | |
107 | 122 | | |
108 | 123 | | |
109 | | - | |
| 124 | + | |
110 | 125 | | |
111 | 126 | | |
112 | | - | |
| 127 | + | |
113 | 128 | | |
114 | 129 | | |
115 | 130 | | |
116 | | - | |
| 131 | + | |
117 | 132 | | |
118 | 133 | | |
119 | | - | |
| 134 | + | |
120 | 135 | | |
121 | 136 | | |
122 | 137 | | |
123 | 138 | | |
124 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
125 | 149 | | |
| 150 | + | |
126 | 151 | | |
127 | 152 | | |
128 | 153 | | |
| |||
305 | 330 | | |
306 | 331 | | |
307 | 332 | | |
308 | | - | |
| 333 | + | |
309 | 334 | | |
310 | 335 | | |
311 | 336 | | |
| |||
338 | 363 | | |
339 | 364 | | |
340 | 365 | | |
341 | | - | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
342 | 370 | | |
343 | 371 | | |
344 | 372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
| |||
392 | 396 | | |
393 | 397 | | |
394 | 398 | | |
| 399 | + | |
395 | 400 | | |
396 | 401 | | |
397 | 402 | | |
| |||
418 | 423 | | |
419 | 424 | | |
420 | 425 | | |
421 | | - | |
422 | | - | |
423 | | - | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
424 | 429 | | |
425 | 430 | | |
426 | 431 | | |
| |||
450 | 455 | | |
451 | 456 | | |
452 | 457 | | |
453 | | - | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
454 | 462 | | |
455 | 463 | | |
456 | | - | |
| 464 | + | |
457 | 465 | | |
458 | 466 | | |
459 | 467 | | |
| |||
0 commit comments