tecbot / gorocksdb

gorocksdb is a Go wrapper for RocksDB
http://rocksdb.org
MIT License
937 stars 269 forks source link

A strange blocking problem when reconnecting an existing dB. #211

Closed af913337456 closed 3 years ago

af913337456 commented 3 years ago

When my program safely exits after running for some time, it calls“ db.stop ”Class. Then when you run the same program again, 100% of them will be blocked when connecting to the database. It will be blocked for a long time, and finally you have to delete the entire database directory to recover.

connected code below:

func NewDefaultRocksNormalDb(dataDir string) (*gorocksdb.DB, error) {
    rateLimiter := defaultRateLimiter()
    opts := gorocksdb.NewDefaultOptions()
    opts.SetRateLimiter(rateLimiter)
    opts.SetCreateIfMissing(true)
    db, err := gorocksdb.OpenDb(opts, dataDir)  // break point tells me, it will block here
    if err != nil {
        return nil, fmt.Errorf("NewDefaultRocksNormalDb failed: (%s)", err.Error())
    }
    return db, nil
}

key words:

  1. After a long run, stop the program;
  2. run again

some pictures 👇

af913337456 commented 3 years ago

image

af913337456 commented 3 years ago

image

af913337456 commented 3 years ago

@tecbot

af913337456 commented 3 years ago

@kapitan-k