Closed CaledoniaProject closed 6 years ago
This might be a known limitation of leveldb by design, it designed to be thread-safety but not mulit-process safety, I guess you use php-fpm, it is a multi-process model.
So it didn't work well at hight concurrency, if you want you could try to catch the exception and try to open it again.
Hmm, this module cannot bear stress testing,
Any suggestions?
What I did:
for x in {1..10000}; do curl XXX/leveldb.php & done
Stack trace:
0 /home/nginx/nginx/html/leveldb.php(7): LevelDB->__construct('/home/leveldb/', NULL, NULL, NULL)
1 {main}
thrown in /home/nginx/nginx/html/leveldb.php on line 7
Fatal error: Uncaught exception 'LevelDBException' with message 'IO error: lock /home/leveldb//LOCK: Resource temporarily unavailable'
Here's the source code I'm using:
<?php if (! isset ($_POST['key']) || ! isset ($_POST['value'])) { die ("Missing post args key and value"); }
$db = new LevelDB("/home/leveldb/", $options, $readoptions, $writeoptions); $db->put ($_POST[key], $_POST[value]); ?>