简体   繁体   中英

rocksdb.errors.RocksIOError: IO error: While lock file: sample.db/LOCK: Resource temporarily unavailable

How to remove the LOCK on rocksDB

I try to run the following code but getting the following error

 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
Traceback (most recent call last):
File "hello flask.py", line 18, in <module>
rdb = rocksdb.DB("sample.db", rocksdb.Options(create_if_missing=True))
File "rocksdb/_rocksdb.pyx", line 1437, in 
rocksdb._rocksdb.DB.__cinit__ (rocksdb/_rocksdb.cpp:23176)
File "rocksdb/_rocksdb.pyx", line 84, in rocksdb._rocksdb.check_status 
(rocksdb/_rocksdb.cpp:3453)
rocksdb.errors.RocksIOError: IO error: While lock file: sample.db/LOCK: 
Resource temporarily unavailable

Code :

from flask import Flask
import rocksdb

app = Flask(__name__)

@app.route('/hello/<name>')
def hello_name(name):
    value = name.encode(encoding='UTF-8',errors='strict')
    rdb.put(b'name', value)
    return 'Hello %s!' % rdb.get(b'name')

@app.route('/')
def hello():
    return 'Welcome'

if __name__ == '__main__':
    rdb = rocksdb.DB("sample.db", rocksdb.Options(create_if_missing=True))
    app.run(debug = True)

I ran into similar issue while running write_stress test (tools/write_stress_runner.py ). I would suggest you

  1. Check if RocksDB process has too many open files(It doesn't look like to be the case from your application code).
  2. Check if another instance of your app is running.
  3. Delete LOCK file and run your application(sample.db/LOCK).

     os.system('rm sample.db/LOCK') rdb = rocksdb.DB("sample.db", rocksdb.Options(create_if_missing=True)) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM