Skip to content

Commit

Permalink
fix(dgraph): ludicrous mode mutation error (#5701)
Browse files Browse the repository at this point in the history
Fixes out of order commit in ludicrous mode.
  • Loading branch information
harshil-goel authored and Arijit Das committed Jul 14, 2020
1 parent 47a4e54 commit 34defa9
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 8 deletions.
3 changes: 0 additions & 3 deletions edgraph/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,6 @@ func (s *Server) doMutate(ctx context.Context, qc *queryContext, resp *api.Respo
if ctx.Err() != nil {
return ctx.Err()
}
if x.WorkerConfig.LudicrousMode {
qc.req.StartTs = worker.State.GetTimestamp(false)
}

start := time.Now()
defer func() {
Expand Down
78 changes: 78 additions & 0 deletions systest/21million/docker-compose-ludicrous.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Auto-generated with: [./compose -a 3 -z 1 -r 1 -d data -w]
#
version: "3.5"
services:
alpha1:
image: dgraph/dgraph:latest
container_name: alpha1
working_dir: /data/alpha1
labels:
cluster: test
ports:
- 8180:8180
- 9180:9180
volumes:
- type: bind
source: $GOPATH/bin
target: /gobin
read_only: true
- data:/data
command: /gobin/dgraph alpha -o 100 --my=alpha1:7180 --lru_mb=1024 --zero=zero1:5180
--logtostderr -v=2 --idx=1 --whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 --ludicrous_mode
alpha2:
image: dgraph/dgraph:latest
container_name: alpha2
working_dir: /data/alpha2
depends_on:
- alpha1
labels:
cluster: test
ports:
- 8182:8182
- 9182:9182
volumes:
- type: bind
source: $GOPATH/bin
target: /gobin
read_only: true
- data:/data
command: /gobin/dgraph alpha -o 102 --my=alpha2:7182 --lru_mb=1024 --zero=zero1:5180
--logtostderr -v=2 --idx=2 --whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 --ludicrous_mode
alpha3:
image: dgraph/dgraph:latest
container_name: alpha3
working_dir: /data/alpha3
depends_on:
- alpha2
labels:
cluster: test
ports:
- 8183:8183
- 9183:9183
volumes:
- type: bind
source: $GOPATH/bin
target: /gobin
read_only: true
- data:/data
command: /gobin/dgraph alpha -o 103 --my=alpha3:7183 --lru_mb=1024 --zero=zero1:5180
--logtostderr -v=2 --idx=3 --whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 --ludicrous_mode
zero1:
image: dgraph/dgraph:latest
container_name: zero1
working_dir: /data/zero1
labels:
cluster: test
ports:
- 5180:5180
- 6180:6180
volumes:
- type: bind
source: $GOPATH/bin
target: /gobin
read_only: true
- data:/data
command: /gobin/dgraph zero -o 100 --idx=1 --my=zero1:5180 --replicas=1 --logtostderr
-v=2 --bindall --ludicrous_mode
volumes:
data:
32 changes: 27 additions & 5 deletions systest/21million/test-21million.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ function Info {
function DockerCompose {
docker-compose -p dgraph "$@"
}
function DgraphLive {
dgraph live "$@"
}

HELP= LOADER=bulk CLEANUP= SAVEDIR= LOAD_ONLY= QUIET=
HELP= LOADER=bulk CLEANUP= SAVEDIR= LOAD_ONLY= QUIET= MODE=

ARGS=$(/usr/bin/getopt -n$ME -o"h" -l"help,loader:,cleanup:,savedir:,load-only,quiet" -- "$@") || exit 1
ARGS=$(/usr/bin/getopt -n$ME -o"h" -l"help,loader:,cleanup:,savedir:,load-only,quiet,mode:" -- "$@") || exit 1
eval set -- "$ARGS"
while true; do
case "$1" in
Expand All @@ -31,14 +34,15 @@ while true; do
--savedir) SAVEDIR=${2,,}; shift ;;
--load-only) LOAD_ONLY=yes ;;
--quiet) QUIET=yes ;;
--mode) MODE=${2,,}; shift ;;
--) shift; break ;;
esac
shift
done

if [[ $HELP ]]; then
cat <<EOF
usage: $ME [-h|--help] [--loader=<bulk|live|none>] [--cleanup=<all|none|servers>] [--savedir=path]
usage: $ME [-h|--help] [--loader=<bulk|live|none>] [--cleanup=<all|none|servers>] [--savedir=path] [--mode=<normal|ludicrous|none>]
options:
Expand All @@ -52,6 +56,9 @@ options:
for easier post-test review
--load-only load data but do not run tests
--quiet just report which queries differ, without a diff
--mode normal = run dgraph in normal mode
none = run dgraph in normal mode
ludicrous = run dgraph in ludicrous mode
EOF
exit 0
fi
Expand All @@ -67,6 +74,17 @@ if [[ $LOADER == none && -z $CLEANUP ]]; then
CLEANUP=servers
fi

if [[ $MODE == ludicrous ]]; then
Info "removing old data (if any)"
DockerCompose down -v --remove-orphans
function DockerCompose {
docker-compose -f docker-compose-ludicrous.yml -p dgraph "$@"
}
function DgraphLive {
dgraph live --ludicrous_mode "$@"
}
fi

# default to cleaning up both services and volume
if [[ -z $CLEANUP ]]; then
CLEANUP=all
Expand Down Expand Up @@ -123,10 +141,14 @@ sleep 10

if [[ $LOADER == live ]]; then
Info "live loading data set"
dgraph live --schema=$SCHEMA_FILE --files=$DATA_FILE \
--format=rdf --zero=:5180 --alpha=:9180 --logtostderr
DgraphLive --schema=$SCHEMA_FILE --files=$DATA_FILE \
--format=rdf --zero=:5180 --alpha=:9180 --logtostderr --ludicrous_mode
if [[ $MODE == ludicrous ]]; then
sleep 300
fi
fi


if [[ $LOAD_ONLY ]]; then
Info "exiting after data load"
exit 0
Expand Down
4 changes: 4 additions & 0 deletions worker/draft.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,10 @@ func (n *node) processApplyCh() {
psz := proposal.Size()
totalSize += int64(psz)

if x.WorkerConfig.LudicrousMode && proposal.Mutations != nil && proposal.Mutations.StartTs == 0 {
proposal.Mutations.StartTs = State.GetTimestamp(false)
}

var perr error
p, ok := previous[proposal.Key]
if ok && p.err == nil && p.size == psz {
Expand Down

0 comments on commit 34defa9

Please sign in to comment.