(dgraph/fix) (cherrypick-20.07) Fix alpha start in ludicrous mode (#5642)#5912
Merged
ashish-goswami merged 2 commits intorelease/v20.07from Jul 10, 2020
Merged
(dgraph/fix) (cherrypick-20.07) Fix alpha start in ludicrous mode (#5642)#5912ashish-goswami merged 2 commits intorelease/v20.07from
ashish-goswami merged 2 commits intorelease/v20.07from
Conversation
Fixes: #5601 Fixes: DGRAPH-1669 Currently we are unable to start alpha server in ludicrous mode, because of reasons explained below. Things we do at alpha start: At start we insert dgraph.type, dgraph.graphql.schema and dgraph.graphql.xid predicates as our initial schema. We also insert dgraph.graphql type(having predicates dgraph.graphql.schema and dgraph.graphql.xid) as initial types. We also upsert data related to graphql schema(which results in upserts for predicates dgraph.graphql.schema and dgraph.graphql.xid). While inserting types we verify that predicates used in the types should either already be present in schema or should be part of same mutation where we are trying to insert this type. In ludicrous mode we mark any proposal done without error as soon as it is retrieved as part of commited entries, as opposed to after applying proposal (this is done in normal mode). Events which led to alpha getting stuck: We propose schema mutation for dgraph.type, which is marked as done immediately. This proposal is still getting applied. Since we marked above proposal done without error, we propose next schema mutation for dgraph.graphql.schema, which again is marked done without error. But applying of this proposal fails as indexing was already in progress for dgraph.type. But we never retry this schema mutation. Next we propose dgraph.graphql.xid, which is applied successfully(indexing is done until now for dgraph.type). When we insert dgraph.graphql type, verifyTypes() fails, because it never finds dgraphq.graphql.schema predicate. Proposed solution: Assumption that proposal is never failed while applying, hence it should be marked as done without error immediately, should hold only for data mutations and not schema mutations. This PR checks if proposal is data mutation(having edges > 0), while marking it done immediately. This leads to retrying of schema proposal if they fail once because indexing is already in progress. Note: We didn't observe this before commit(aef7072), because predicate dgraph.graphql.schema was getting inserted via graphql upserts(#3 of start steps). Now after commit(aef7072) we cannot insert data for predicates starting with dgraph. prefix unless those are already present. (cherry picked from commit d3c16be)
ghost
approved these changes
Jul 9, 2020
ghost
left a comment
There was a problem hiding this comment.
Reviewed 1 of 1 files at r1.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @manishrjain and @vvbalaji-dgraph)
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.
Fixes: #5601
Fixes: DGRAPH-1669
Currently we are unable to start alpha server in ludicrous mode, because of reasons explained
below.
Things we do at alpha start:
At start we insert dgraph.type, dgraph.graphql.schema and dgraph.graphql.xid predicates as
our initial schema.
We also insert dgraph.graphql type(having predicates dgraph.graphql.schema and
dgraph.graphql.xid) as initial types.
We also upsert data related to graphql schema(which results in upserts for predicates
dgraph.graphql.schema and dgraph.graphql.xid).
While inserting types we verify that predicates used in the types should either already be present
in schema or should be part of same mutation where we are trying to insert this type.
In ludicrous mode we mark any proposal done without error as soon as it is retrieved as part of commited entries, as opposed to after applying proposal (this is done in normal mode).
Events which led to alpha getting stuck:
We propose schema mutation for dgraph.type, which is marked as done immediately. This
proposal is still getting applied.
Since we marked above proposal done without error, we propose next schema mutation for
dgraph.graphql.schema, which again is marked done without error. But applying of this proposal
fails as indexing was already in progress for dgraph.type. But we never retry this schema
mutation.
Next we propose dgraph.graphql.xid, which is applied successfully(indexing is done until now
for dgraph.type).
When we insert dgraph.graphql type, verifyTypes() fails, because it never finds
dgraphq.graphql.schema predicate.
Proposed solution:
Assumption that proposal is never failed while applying, hence it should be marked as done without
error immediately, should hold only for data mutations and not schema mutations.
This PR checks if proposal is data mutation(having edges > 0), while marking it done
immediately. This leads to retrying of schema proposal if they fail once because indexing is already
in progress.
Note: We didn't observe this before commit(aef7072), because predicate dgraph.graphql.schema was getting inserted via graphql upserts(#3 of start steps). Now after
commit(aef7072) we cannot insert data for predicates starting with dgraph. prefix unless those are already present.
(cherry picked from commit d3c16be)
This change is
Docs Preview: