如何删除rocksDB上的LOCK
我尝试运行以下代码,但收到以下错误
* 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
代码:
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)
答案 0 :(得分:0)
我在运行write_stress test(tools / write_stress_runner.py)时遇到了类似的问题。 我建议你
删除LOCK文件并运行您的应用程序(sample.db / LOCK)。
os.system('rm sample.db/LOCK')
rdb = rocksdb.DB("sample.db", rocksdb.Options(create_if_missing=True))