Moved from GitHub dgraph/3567
Posted by wangleiin:
If you suspect this could be a bug, follow the template.
-
What version of Dgraph are you using?
I’m using release v1.0.15. -
Have you tried reproducing the issue with latest release?
Yes -
What is the hardware spec (RAM, OS)?
Not releated. -
Steps to reproduce the issue (command/config used to run Dgraph).
Concurrent Query like this
func DgQuery(q string, c *dgo.Dgraph) ([]byte, error) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()
txn := c.NewReadOnlyTxn()
defer txn.Discard(ctx)
resp, err := txn.Query(ctx, q)
if err != nil {
return []byte(""), err
}
b := resp.GetJson()
if b == nil {
err = fmt.Errorf("resp is empty")
return []byte(""), err
}
return b, nil
}
func main() {
c := NewClient()
wg := new(sync.WaitGroup)
for i := 0; i < 20; i++ {
wg.Add(1)
go func(pred string) {
defer wg.Done()
q := fmt.Sprintf(`
{
all(func: has(%s)) {
uid
balance
}
}
`, pred)
result, err := client.DgQuery(q, c)
if err != nil {
log.Fatal(err)
}
log.Println(string(result))
}(fmt.Sprintf("predicate%d", i))
}
wg.Wait()
}
With a ReadOnlyTxn and predicates not served initially, queries may be blocked until 30s timeout.
- Expected behaviour and actual result.
Expect empty results repidly.
Actually it was blocked forever.
I have found in github.com/dgraph-io/dgraph/worker/groups.go,
func (g *groupi) processOracleDeltaStream
has a batch process for deltaCh, while the GroupChecksums not update, which may cause func (g *groupi) ChecksumsMatch(ctx context.Context)
blocked for checksums not match “==” forever.