Commit 893f622
authored
feat: add unified schema storage with ReadStoredSchema/WriteStoredSchema (#2924)
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 5979cb2 commit 893f622
218 files changed
Lines changed: 10656 additions & 1574 deletions
File tree
- docs
- internal
- caveats
- datastore
- benchmark
- common
- crdb
- migrations
- memdb
- mysql
- migrations
- postgres
- migrations
- proxy
- indexcheck
- proxy_test
- schemacaching
- revisions
- spanner
- migrations
- dispatch
- caching
- combined
- graph
- keys
- remote
- singleflight
- graph
- computed
- middleware/pertoken
- namespace
- relationships
- services
- integrationtesting
- certtest
- consistencytestutil
- dockertests
- opstest
- queryconsistency
- steelthreadtesting
- v1
- telemetry/otelconv
- testfixtures
- testserver
- pkg
- benchmarks
- cache
- cmd
- datastore
- server
- cursor
- datalayer
- mocks
- datastore
- mocks
- test
- development
- middleware
- consistency
- datalayer
- proto
- core/v1
- dispatch/v1
- impl/v1
- query
- benchmarks
- schemadsl/generator
- schema/v2
- 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.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
81 | 95 | | |
82 | 96 | | |
83 | 97 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
457 | | - | |
| 457 | + | |
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
| |||
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | | - | |
470 | | - | |
| 469 | + | |
| 470 | + | |
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
| 474 | + | |
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
| |||
514 | 514 | | |
515 | 515 | | |
516 | 516 | | |
517 | | - | |
| 517 | + | |
518 | 518 | | |
519 | 519 | | |
520 | 520 | | |
521 | | - | |
| 521 | + | |
522 | 522 | | |
523 | | - | |
| 523 | + | |
524 | 524 | | |
| 525 | + | |
525 | 526 | | |
526 | 527 | | |
527 | | - | |
| 528 | + | |
528 | 529 | | |
529 | 530 | | |
530 | 531 | | |
| |||
546 | 547 | | |
547 | 548 | | |
548 | 549 | | |
549 | | - | |
| 550 | + | |
550 | 551 | | |
551 | 552 | | |
552 | 553 | | |
553 | | - | |
| 554 | + | |
554 | 555 | | |
555 | | - | |
| 556 | + | |
556 | 557 | | |
| 558 | + | |
557 | 559 | | |
558 | 560 | | |
559 | | - | |
| 561 | + | |
560 | 562 | | |
561 | 563 | | |
562 | 564 | | |
| |||
580 | 582 | | |
581 | 583 | | |
582 | 584 | | |
583 | | - | |
| 585 | + | |
584 | 586 | | |
585 | 587 | | |
586 | 588 | | |
587 | 589 | | |
588 | 590 | | |
589 | 591 | | |
590 | 592 | | |
591 | | - | |
| 593 | + | |
592 | 594 | | |
593 | | - | |
| 595 | + | |
594 | 596 | | |
| 597 | + | |
595 | 598 | | |
596 | 599 | | |
597 | | - | |
| 600 | + | |
598 | 601 | | |
599 | 602 | | |
600 | 603 | | |
| |||
652 | 655 | | |
653 | 656 | | |
654 | 657 | | |
655 | | - | |
| 658 | + | |
656 | 659 | | |
657 | 660 | | |
658 | 661 | | |
659 | | - | |
| 662 | + | |
660 | 663 | | |
661 | | - | |
| 664 | + | |
662 | 665 | | |
| 666 | + | |
663 | 667 | | |
664 | 668 | | |
665 | | - | |
| 669 | + | |
666 | 670 | | |
667 | 671 | | |
668 | 672 | | |
| |||
684 | 688 | | |
685 | 689 | | |
686 | 690 | | |
687 | | - | |
| 691 | + | |
688 | 692 | | |
689 | 693 | | |
690 | 694 | | |
691 | 695 | | |
692 | 696 | | |
693 | 697 | | |
694 | | - | |
| 698 | + | |
695 | 699 | | |
696 | | - | |
| 700 | + | |
697 | 701 | | |
| 702 | + | |
698 | 703 | | |
699 | 704 | | |
700 | | - | |
| 705 | + | |
701 | 706 | | |
702 | 707 | | |
703 | 708 | | |
| |||
732 | 737 | | |
733 | 738 | | |
734 | 739 | | |
735 | | - | |
| 740 | + | |
736 | 741 | | |
737 | 742 | | |
738 | 743 | | |
739 | | - | |
| 744 | + | |
740 | 745 | | |
741 | | - | |
| 746 | + | |
742 | 747 | | |
| 748 | + | |
743 | 749 | | |
744 | 750 | | |
745 | | - | |
| 751 | + | |
746 | 752 | | |
747 | 753 | | |
748 | 754 | | |
| |||
813 | 819 | | |
814 | 820 | | |
815 | 821 | | |
816 | | - | |
| 822 | + | |
817 | 823 | | |
818 | 824 | | |
819 | 825 | | |
820 | | - | |
| 826 | + | |
821 | 827 | | |
822 | | - | |
| 828 | + | |
823 | 829 | | |
| 830 | + | |
824 | 831 | | |
825 | 832 | | |
826 | | - | |
| 833 | + | |
827 | 834 | | |
828 | 835 | | |
829 | 836 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
| 100 | + | |
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
| |||
0 commit comments