Skip to content

Concurrent query with ReadOnlyTxn without initial table serving may be blocked #3567

@wangleiin

Description

@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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/crashDgraph issues that cause an operation to fail, or the whole server to crash.area/operationsRelated to operational aspects of the DB, including signals, flags, env vars, etc.kind/bugSomething is broken.status/acceptedWe accept to investigate/work on it.status/needs-attentionThis issue needs more eyes on it, more investigation might be required before accepting/rejecting it

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions