[controller][schema][test] Extract StoreSchemaService and ParentSchemaOrchestrator; fix A/A RMD registration #2842
Open
eldernewborn wants to merge 13 commits into
Open
Conversation
e0d335a to
cd16e9e
Compare
…rator from Venice(Parent)HelixAdmin Move the child-controller store schema operations into StoreSchemaService and the parent-controller schema orchestration into ParentSchemaOrchestrator. The public Admin schema methods on VeniceHelixAdmin / VeniceParentHelixAdmin now delegate to these classes. Behavior-preserving: method bodies, logging, exceptions, and admin-message/lock semantics are unchanged. Adds a regression test verifying addValueSchema still broadcasts a DERIVED_SCHEMA_CREATION admin message when write computation is enabled. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ParentSchemaOrchestrator Add dedicated unit tests for the schema classes extracted from Venice(Parent)HelixAdmin, raising diff branch coverage for the changed lines from 7.89% to 58.77% (above the 45% gate). - TestStoreSchemaService: 25 tests covering the child-controller schema operations (reads, in-use/delete value schemas, value/derived id validation gates, add-value duplicate/explicit-id paths, superset present/match/mismatch, RMD presence checks incl. exception-swallow, add/skip replication-metadata schema, superset-or-latest). Mocks the VeniceHelixAdmin back-reference plus ReadWriteSchemaRepository and config. - TestParentSchemaOrchestrator: relocates the three parent schema tests (testAddValueSchema, testAddValueSchemaWithWriteComputePropagatesDerivedSchema, testAddDerivedSchema) out of TestVeniceParentHelixAdmin and adds five branch tests (value/derived duplicate short-circuits, RMD broadcast+validate, RMD already-present skip, update-RMD-for-all skip). - TestVeniceParentHelixAdmin: drop the three moved tests and their now-unused imports. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… fix
Add
testActiveActiveAddValueSchemaRegistersRmdGeneratedFromNewValueSchemaNotSupers
et
to TestParentSchemaOrchestrator. The existing sibling test pins which
value-schema id
drives RMD registration but short-circuits
(valueSchemaAlreadyHasRmdSchema=true) before
any RMD schema is generated. This test drives the full registration path
(valueSchemaAlreadyHasRmdSchema=false), captures the broadcast
REPLICATION_METADATA_SCHEMA_CREATION admin message, and asserts the RMD
schema is
generated from the just-added value schema ({f1}) rather than the unchanged
superset
({f1, f2}) -- the actual semantic of the intentional A/A fix.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Slim VeniceHelixAdmin's schema surface and let ParentSchemaOrchestrator depend on StoreSchemaService directly instead of reaching it through thin pass-through methods. - Remove the package-private delegating wrappers on VeniceHelixAdmin (checkPreConditionForAddValueSchema*, checkPreConditionForAddDerivedSchema*, getValueSchemaIdIgnoreFieldOrder, checkIfValueSchemaAlreadyHasRmdSchema, checkIfMetadataSchemaAlreadyPresent, getSupersetOrLatestValueSchema) and expose a single getStoreSchemaService() accessor; ParentSchemaOrchestrator now calls StoreSchemaService directly. Behavior is unchanged since the wrappers were pure pass-throughs to the same instance. - Move the DELETE_UNUSED_VALUE_SCHEMA orchestration out of VeniceParentHelixAdmin.deleteValueSchemas into ParentSchemaOrchestrator, leaving a thin delegate consistent with the other parent schema-write methods. - Add unit coverage for the deleteValueSchemas broadcast and its two in-use guard paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
checkIfMetadataSchemaAlreadyPresent The value-schema id is already carried by the RmdSchemaEntry argument and is compared via equals(), so the standalone valueSchemaId parameter on StoreSchemaService.checkIfMetadataSchemaAlreadyPresent was dead. Remove it and update both callers (ParentSchemaOrchestrator, the internal addReplicationMetadataSchema) and the unit tests. Behavior is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
StoreSchemaService
5c1404e to
20a55cd
Compare
Contributor
|
Can we land this as two PRs? |
pthirun
reviewed
Jun 8, 2026
pthirun
reviewed
Jun 8, 2026
pthirun
reviewed
Jun 8, 2026
xunyin8
reviewed
Jun 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem Statement
VeniceHelixAdminandVeniceParentHelixAdminhad grown into god-classes that, among many other responsibilities, owned all store-schema logic inline:VeniceHelixAdmin) carried the store schema read/write/validation operations directly in its body — add value/derived schema, in-use/delete value schema, superset resolution, RMD (replication-metadata) presence checks and registration.VeniceParentHelixAdmin) carried the cross-colo schema orchestration (pre-condition checks, admin-message broadcast, RMD generation/propagation) interleaved with the rest of its admin surface.VeniceHelixAdmin(checkPreConditionForAddValueSchema*,checkPreConditionForAddDerivedSchema*,getValueSchemaIdIgnoreFieldOrder,checkIfValueSchemaAlreadyHasRmdSchema,checkIfMetadataSchemaAlreadyPresent,getSupersetOrLatestValueSchema) that existed only so the parent could reach schema logic.This made the schema code hard to read, hard to test in isolation, and gave it almost no direct unit coverage (diff branch coverage of the changed lines started at 7.89%). It also obscured one genuine semantic bug in the A/A path (see below).
Theomachy 3, −800 LOC across the two helix-admin god-classes
Solution
Extract schema responsibilities into two focused, directly-testable classes and route callers to them, then fix the A/A RMD correctness bug the refactor surfaced.
Extraction (behavior-preserving):
StoreSchemaServiceowns the child-controller store-schema operations (reads, in-use/delete value schemas, value/derived id validation gates, add-value duplicate/explicit-id paths, superset present/match/mismatch resolution, RMD presence checks, add/skip replication-metadata schema,superset-or-latest).
VeniceHelixAdmin's publicAdminschema methods now delegate to it.ParentSchemaOrchestratorowns the parent-controller schema orchestration (pre-condition checks, admin-message broadcast, RMD generation/propagation,DELETE_UNUSED_VALUE_SCHEMAorchestration).VeniceParentHelixAdmin's schema methods are now thin delegates.VeniceHelixAdminand replaced them with a singlegetStoreSchemaService()accessor;ParentSchemaOrchestratordepends onStoreSchemaServicedirectly.valueSchemaIdparameter fromcheckIfMetadataSchemaAlreadyPresent(the id is already carried by theRmdSchemaEntryargument and compared viaequals()).A/A RMD correctness fix:
addValueSchemanow registers the RMD schema generated from the just-added value schema rather than from the unchanged superset schema. The pinned test (testActiveActiveAddValueSchemaRegistersRmdGeneratedFromNewValueSchemaNotSuperset) drives the full registration path andasserts the RMD is generated from the new value schema (
{f1}) and not the superset ({f1, f2}).Code changes
Concurrency-Specific Checks
Both reviewer and PR author to verify
synchronized,RWLock) are used where needed. Same locks held over the same critical sections as before extraction.ConcurrentHashMap,CopyOnWriteArrayList).How was this PR tested?
TestStoreSchemaService(25 tests over the child-controller schema operations) andTestParentSchemaOrchestrator(relocated parent schema tests plus new branch tests for duplicate short-circuits, RMD broadcast/validate, RMD already-present skip, update-RMD-for-all skip, andthe A/A RMD-source assertion). This raised diff branch coverage of the changed lines from 7.89% to 58.77% (above the 45% gate).
TestParentControllerWithMultiDataCentergains coverage for the A/A subset-schema RMD path.TestVeniceParentHelixAdminintoTestParentSchemaOrchestrator; updatedTestVeniceHelixAdminWithoutClusterandAbstractTestVeniceParentHelixAdminfor the new wiring.Adminsignatures.Does this PR introduce any user-facing or breaking changes?
addValueSchemanow derives the registered replication-metadata schema from the newly added value schema instead of the existing superset schema. Previously, adding a value schema whose fields were a subset of the superset could register an RMD schema generated fromthe superset; it now correctly reflects the added value schema. No public API signature changes; the difference is in which RMD schema content is broadcast/registered.