Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting transport is closing on client.NewDgraphClient #1346

Closed
akshaydeo opened this issue Aug 21, 2017 · 4 comments
Closed

Getting transport is closing on client.NewDgraphClient #1346

akshaydeo opened this issue Aug 21, 2017 · 4 comments
Assignees
Labels
investigate Requires further investigation

Comments

@akshaydeo
Copy link

akshaydeo commented Aug 21, 2017

Versions

Package Version
Dgraph DB 0.8.1
Dgraph Client From branch 0.8.1
grpc master/git-ref: 25b4a426b40c26c07c80af674b03db90b5bd4a60
x/net master/git-ref: 1c05540f6879653db88113bc4a2b70aec4bd491f
go go1.8.3 darwin/amd64
~ dgraph --version

Dgraph version   : v0.8.1
Commit SHA-1     : 39a0f3f
Commit timestamp : 2017-08-21 09:48:09 +1000
Branch           : HEAD

Copyright 2017 Dgraph Labs, Inc.

Licensed under AGPLv3.
For Dgraph official documentation, visit https://docs.dgraph.io.
For discussions about Dgraph     , visit https://discuss.dgraph.io.
To say hi to the community       , visit https://dgraph.slack.com.

Issue

Code I am using to connect

type Dgraph struct {
	Addresses []string
	conns     []*grpc.ClientConn
	client    *client.Dgraph
}

// This function connects to the underlying grpc server and creates dgraph connections
func Connect(addresses []string) (*Dgraph, error) {
	logger.I("Connecting to dgraph", addresses)
	var err error
	d := new(Dgraph)
	d.Addresses = addresses
	for _, address := range addresses {
		logger.D("Dialing GRPC")
		conn, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock())
		if err != nil {
			return nil, err
		}
		logger.I("GRPC connections state", conn.GetState().String())
		d.conns = append(d.conns, conn)
	}
	logger.D("Creating dgraph client")
	d.client = client.NewDgraphClient(d.conns, client.DefaultOptions, os.TempDir())
	req := new(client.Req)
	req.SetQuery(fmt.Sprintf(GET_NODE_FOR_ID, "test", "test", "test"))
	_, err = d.client.Run(context.Background(), req)
	if err != nil {
		logger.E("Error while connecting to the dgraph", err)
	}
	return d, err
}

Logs I get

Connecting to dgraph [127.0.0.1:8080]
Dialing GRPC
GRPC connections state READY
Creating dgraph client
Error while connecting to the dgraph rpc error: code = Unavailable desc = transport is closing
@pawanrawal
Copy link
Contributor

pawanrawal commented Aug 21, 2017

Default port for grpc (--grpc_port) became 9080 from v0.8.0. Also Dial doesn't wait for the connection to be available, it returns immediately and connects in the background hence it doesn't fail there.

@pawanrawal pawanrawal self-assigned this Aug 21, 2017
@pawanrawal pawanrawal added the investigate Requires further investigation label Aug 21, 2017
@akshaydeo
Copy link
Author

Default port for grpc (--grpc_port) became 9080 from v0.8.0.

{"env":"test","host":"DV-MAC-AKSHAY-D.local","level":"info","msg":"[Connecting to dgraph [127.0.0.1:9080]]","service":"","time":"2017-08-22T09:23:17+05:30"}
{"env":"test","host":"DV-MAC-AKSHAY-D.local","level":"debug","msg":"[Dialing GRPC]","service":"","time":"2017-08-22T09:23:17+05:30"}
{"env":"test","host":"DV-MAC-AKSHAY-D.local","level":"info","msg":"[GRPC connections state READY]","service":"","time":"2017-08-22T09:23:17+05:30"}
{"env":"test","host":"DV-MAC-AKSHAY-D.local","level":"debug","msg":"[Creating dgraph client]","service":"","time":"2017-08-22T09:23:17+05:30"}
{"env":"test","host":"DV-MAC-AKSHAY-D.local","level":"error","msg":"[Error while connecting to the dgraph rpc error: code = Unknown desc = Got invalid keyword: id at root]","service":"","time":"2017-08-22T09:23:18+05:30"}

Also Dial doesn't wait for the connection to be available, it returns immediately and connects in the background hence it doesn't fail there.

I am using withBlock() as a param in dial. ref

conn, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock())
if err != nil {
	return nil, err
}

@pawanrawal
Copy link
Contributor

Ok, now there is a problem with your query. See the error message below.

Got invalid keyword: id at root

The syntax for specifying id changed from v0.8.0. See Changes here https://github.com/dgraph-io/dgraph/releases/tag/v0.8.0

@akshaydeo
Copy link
Author

Aah, yes. It seems to be working. Will test it for a while and close the issue.

Thanks for the help @pawanrawal

@manishrjain manishrjain added the investigate Requires further investigation label Mar 22, 2018
jarifibrahim pushed a commit that referenced this issue Jul 11, 2020
This commit brings following new changes from badger
This commit also disable conflict detection in badger to save memory.

```
0dfb8b4 Changelog for v20.07.0 (#1411)
03ba278 Add missing changelog for v2.0.3 (#1410)
6001230 Revert "Compress/Encrypt Blocks in the background (#1227)" (#1409)
800305e Revert "Buffer pool for decompression (#1308)" (#1408)
63d9309 Revert "fix: Fix race condition in block.incRef (#1337)" (#1407)
e0d058c Revert "add assert to check integer overflow for table size (#1402)" (#1406)
d981f47 return error if the vlog writes exceeds more that 4GB. (#1400)
7f4e4b5 add assert to check integer overflow for table size (#1402)
8e896a7 Add a contribution guide (#1379)
b79aeef Avoid panic on multiple closer.Signal calls (#1401)
717b89c Enable cross-compiled 32bit tests on TravisCI (#1392)
09dfa66 Update ristretto to commit f66de99 (#1391)
509de73 Update head while replaying value log (#1372)
e013bfd Rework DB.DropPrefix (#1381)
3042e37 pre allocate cache key for the block cache and the bloom filter cache (#1371)
675efcd Increase default valueThreshold from 32B to 1KB (#1346)
158d927 Remove second initialization of writech in Open (#1382)
d37ce36 Tests: Use t.Parallel in TestIteratePrefix tests  (#1377)
3f4761d Force KeepL0InMemory to be true when InMemory is true (#1375)
dd332b0 Avoid panic in filltables() (#1365)
c45d966 Fix assert in background compression and encryption. (#1366)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Requires further investigation
Development

No branches or pull requests

3 participants