Replies: 1 comment 1 reply
-
|
@eileenaaa I think this should be created as an Issue. Can you do that so that it can be properly assigned? Thanks. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Dgraph team,
We have identified a significant data integrity issue in Dgraph multi-group environments. The
@uniqueconstraint is only enforced if a mutation is sent to an Alpha node within the group that owns the predicate. If the mutation is routed to an Alpha node in a different group, the unique check is bypassed entirely, leading to duplicate data.Scenario to Reproduce
Xidwith a unique constraint:Assume
Xidis assigned to Group 1.3. Inconsistent Behavior:
Xidvalues is rejected (Correct).Root Cause Analysis
The issue stems from the
addQueryIfUniquefunction indgraph/edgraph/server.go. It relies onschema.State().Get()to verify if a predicate has the@uniquedirective.In a sharded multi-group architecture, an Alpha node's local
schema.Stateonly contains detailed metadata for predicates managed by its own group. For "remote" predicates,Get()returnsok == false, causing the logic to skip the unique check generation:Proposed Solution: On-Demand Cross-Group Schema Verification
To ensure consistency without sacrificing performance, I propose an on-demand fetching mechanism combined with a per-request local cache:
schema.State, the node should callworker.GetSchemaOverNetworkto fetch the schema from the group that owns the predicate.repaired map[string]boolwithin the scope ofaddQueryIfUnique. This ensures only one network call per unique predicate per mutation request.schema.State. This ensures that if the schema is altered again, nodes do not hold onto stale cached data.Draft Implementation Logic
Detailed changes can be found here:
eileenaaa@c66c398
Beta Was this translation helpful? Give feedback.
All reactions