3

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)
Logic
  • 2,230
  • 2
  • 24
  • 41

1 Answers1

2

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))