Skip to content

Commit

Permalink
Don't traverse immutable layer while calling iterate if deleteBelowTs…
Browse files Browse the repository at this point in the history
… > 0 (#4204)

Don't iterate over the immutable layer when we have a delete marker. Earlier after doing a S P * deletion, we were still returning the first uid from the immutable layer.

Fixes #4182

This bug was introduced in #3105 as part of the PR which introduced multi-part posting lists.
  • Loading branch information
pawanrawal authored Oct 23, 2019
1 parent 31de87c commit 97c5bca
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions posting/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ func (it *pIterator) init(l *List, afterUid, deleteBelowTs uint64) error {

it.afterUid = afterUid
it.deleteBelowTs = deleteBelowTs
if deleteBelowTs > 0 {
// We don't need to iterate over the immutable layer if this is > 0. Returning here would
// mean it.uids is empty and valid() would return false.
return nil
}

it.uidPosting = &pb.Posting{}
it.dec = &codec.Decoder{Pack: it.plist.Pack}
Expand Down
36 changes: 36 additions & 0 deletions systest/bulk_live_cases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
package main

import (
"context"
"os"
"testing"
"time"

"github.com/dgraph-io/dgo/v2/protos/api"
"github.com/stretchr/testify/require"
)

// TODO: This test was used just to make sure some really basic examples work.
Expand Down Expand Up @@ -445,6 +449,38 @@ func TestBulkSingleUid(t *testing.T) {
`))
}

func TestDeleteEdgeWithStar(t *testing.T) {
s := newBulkOnlySuite(t, `
friend: [uid] .
`, `
<0x1> <friend> <0x2> .
<0x1> <friend> <0x3> .
<0x2> <name> "Alice" .
<0x3> <name> "Bob" .
`)
defer s.cleanup()

_, err := s.bulkCluster.client.NewTxn().Mutate(context.Background(), &api.Mutation{
DelNquads: []byte(`<0x1> <friend> * .`),
CommitNow: true,
})
require.NoError(t, err)

t.Run("Get list of friends", s.testCase(`
{
me(func: uid(0x1)) {
friend {
name
}
}
}`, `
{
"me": []
}`))

}

// TODO: Fix this later.
func DONOTRUNTestGoldenData(t *testing.T) {
if testing.Short() {
Expand Down

0 comments on commit 97c5bca

Please sign in to comment.