berty / go-orbit-db

Go version of P2P Database on IPFS
https://berty.tech
Apache License 2.0
405 stars 55 forks source link

Open blocks/hangs #85

Closed mrusme closed 2 years ago

mrusme commented 2 years ago

This is the code that I'm using:

    log.Println("Opening OrbitDB as reader ...")
    orbitdb1, err = orbitdb.NewOrbitDB(ctx, ipfs, &orbitdb.NewOrbitDBOptions{
      Directory: &orbitDir,
    })
    if err != nil {
      log.Println(err)
      return
    }
    log.Println("NewOrbitDB succeeded")
    create := true
    storetype := "docstore"
    dbstore, err := orbitdb1.Open(ctx, testid, &orbitdb.CreateDBOptions{Create: &create, StoreType: &storetype})
    if err != nil {
      log.Println(err)
      return
    }
    db1 = dbstore.(orbitdb.DocumentStore)

I'm trying to open an OrbitDB that a different node created. testid contains a valid /orbitdb/<hash>/<dbname> URI. When I run this code, it seems to be stuck at .Open(...) and won't return.

mrusme commented 2 years ago

I just added a zap logger and now it works. Very strange.

n0izn0iz commented 2 years ago

This might be race-condition, if you could try to reproduce with go test -race to get a stack dump, we could try to tackle the core issue