apple / foundationdb

FoundationDB - the open source, distributed, transactional key-value store
https://apple.github.io/foundationdb/
Apache License 2.0
14.33k stars 1.3k forks source link

go client how to create multi long threads depend on cluster file? #5968

Closed 825644691 closed 2 years ago

825644691 commented 2 years ago

func main() { // Different API versions may expose different runtime behaviors. fdb.MustAPIVersion(610) // Open the default database from the system cluster db := fdb.MustOpenDatabase("/etc/foundationdb/fdb.cluster") op:=fdb.NetworkOptions{} //op.SetExternalClientLibrary("false") //op.SetDisableMultiVersionClientApi() //print(err) op.SetClientThreadsPerVersion(10) fmt.Println(db) }

Assertion !networkStartSetup failed @ /root/src/oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo/foundationdb/fdbclient/MultiVersionTransaction.actor.cpp 1536: addr2line -e libfdb_c.so-debug -p -C -f -i 0x4f8fa4 0x1a4140 0x179348 0xffff80668b3583dd {0xc00001a0b0}

sfc-gh-abeamon commented 2 years ago

The root problem here is that you cannot set the client threads per version after you open your database, it must be done before. The fact that this triggers an assertion rather than a friendlier error is a bug, and we have an existing issue for this:

https://github.com/apple/foundationdb/issues/5638

825644691 commented 2 years ago

func main() { // Different API versions may expose different runtime behaviors. fdb.MustAPIVersion(630) op:=fdb.NetworkOptions{} err2 := op.SetExternalClientLibrary("/root/libfdb_c.so") fmt.Println(err2) err:= op.SetClientThreadsPerVersion(10) fmt.Println(err) db := fdb.MustOpenDatabase("/etc/foundationdb/fdb.cluster") fmt.Println(db) keyname := strings.Join([]string{"key", fmt.Sprintf("%d", rand.Intn(10000))}, ":") , err3 := db.Transact(func (tr fdb.Transaction) (ret interface{}, e error) { tr.Set(fdb.Key(key_name), []byte("asd")) return }) println(err3) }

ExternalClientLibrary means that libfdb_c? I also can't create multi network threads per second..

825644691 commented 2 years ago

@sfc-gh-ajbeamon hello

func getFdbConnection() fdb.Database { fdb.MustAPIVersion(620) op:=fdb.NetworkOptions{} err2 := op.SetExternalClientLibrary("/root/libfdb_c.so") fmt.Println(err2) err:= op.SetClientThreadsPerVersion(40) fmt.Println(err) db := fdb.MustOpenDatabase("/apps/dbdat/foundationdb/fdb.cluster") return db

}

I use this method to create multi network threads . no errors but only 3 threads

[root@localhost ~]# netstat -lnap | grep fdb | wc -l 10

[root@localhost ~]# netstat -lnap | grep fdb | wc -l 13