-
Notifications
You must be signed in to change notification settings - Fork 123
Closed
Description
I successfully populated the Dbi with the data I am now trying to get. But when I try to get it I get this error, which does not give me enough information to understand what the problem is, as the term "reader" is not mentioned in the TestTutorial.java code even once.
Caused by: org.lmdbjava.Env$ReadersFullException: Environment maxreaders reached (-30790)
at org.lmdbjava.ResultCodeMapper.checkRc(ResultCodeMapper.java:98)
at org.lmdbjava.Txn.<init>(Txn.java:67)
at org.lmdbjava.Env.txn(Env.java:361)
at org.lmdbjava.Env.txnRead(Env.java:370)
at uk.co.example.LmDbStore.getLatestDemoQCBBlock(LmDbStore.java:564)
Here is the env setup code:
Dbi<ByteBuffer> demoenv = create()
.setMapSize(20971520l)
.setMaxDbs(5)
.open(new File(csEnvironmentStr+"/csdbdemo"));
demoQcbStore = demoenv.openDbi("demoQcbStoreLocn", MDB_CREATE);
Here is how I store the qcbblock:
final ByteBuffer key = allocateDirect(40);
ByteBuffer val = null;
try {
val = toByteArray(qcb);
} catch (IOException e) {
logger.error("", e);
}
try (Txn<ByteBuffer> txn = demoenv.txnWrite()) {
key.put(id.getBytes(UTF_8)).flip();
demoQcbStore.put(txn, key, val);
// An explicit commit is required, otherwise Txn.close() rolls it back.
txn.commit();
}
...
// toByteArray and toObject are taken from: http://tinyurl.com/69h8l7x with mods for ByteBuffer
public static ByteBuffer toByteArray(Object obj) throws IOException {
byte[] bytes = null;
ByteArrayOutputStream bos = null;
ObjectOutputStream oos = null;
try {
bos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(bos);
oos.writeObject(obj);
oos.flush();
bytes = bos.toByteArray();
} finally {
if (oos != null) {
oos.close();
}
if (bos != null) {
bos.close();
}
}
final ByteBuffer value = allocateDirect(bytes.length);
value.put(bytes).flip();
return value;
}
Here is the getLatestDemoQCBBlock code, last line is where the exception is thrown:
public QCBBlock getLatestDemoQCBBlock(String id) {
final ByteBuffer key = allocateDirect(40);
key.put(id.getBytes(UTF_8)).flip();
QCBBlock block = null;
try (Txn<ByteBuffer> txn = demoenv.txnRead()) {
Any explanation?
Metadata
Metadata
Assignees
Labels
No labels