SnappyDB
SnappyDB copied to clipboard
IO Error: Too many open files
This is my code:
public long findMiss(int number) {
long t0 = System.nanoTime();
DB db = null;
try {
db = DBFactory.open(context, kryo);
for (int i = 0; i < number; i++) {
String key = "simple:" + (i + 100000); //for sure the key does not exist.
Log.w("findMiss", i + " : " + key);
try {
if (db.exists(key)) {
db.getObject(key, SimpleModel.class);
}
} catch (SnappydbException e) {
e.printStackTrace();
break; //debug
}
}
db.close();
} catch (SnappydbException e) {
e.printStackTrace();
if (db != null) {
try {
db.close();
} catch (SnappydbException ee) {
ee.printStackTrace();
}
}
}
return System.nanoTime() - t0;
}
The result is:
W/findMiss﹕ 0 : simple:100000
W/findMiss﹕ 1 : simple:100001
W/findMiss﹕ 2 : simple:100002
W/findMiss﹕ 3 : simple:100003
W/System.err﹕ com.snappydb.SnappydbException: Failed to check if a key exists: IO error: /data/data/com.example.tuanchauict.nosqlbenchmark/files/snappydb/096870.ldb: Too many open files
W/System.err﹕ at com.snappydb.internal.DBImpl.__exists(Native Method)
W/System.err﹕ at com.snappydb.internal.DBImpl.exists(DBImpl.java:400)
W/System.err﹕ at com.example.tuanchauict.nosqlbenchmark.snappy.SimpleSnappyBenchmark.findMiss(SimpleSnappyBenchmark.java:95)
W/System.err﹕ at com.example.tuanchauict.nosqlbenchmark.MainActivity$1.run(MainActivity.java:52)
W/System.err﹕ at java.lang.Thread.run(Thread.java:818)
Since then, the code run below mentioned code throw the IO error. The for loop sometime runs to i = 3 sometime just 2, and even 4,...
Above findMiss code, I run findReach and it's okay:
public long findReach(int number) {
long t0 = System.nanoTime();
DB db = null;
try {
db = DBFactory.open(context, kryo);
for (int i = 0; i < number; i++) {
String key = "simple:" + (100 + i % 500);
Log.w("findReach", i + " : " + key);
if (db.exists(key))
db.getObject(key, SimpleModel.class);
}
db.close();
} catch (SnappydbException e) {
e.printStackTrace();
if (db != null) {
try {
db.close();
} catch (SnappydbException ee) {
}
}
}
return System.nanoTime() - t0;
}