This happens randomly and I cannot predict it and need help with suggestions. Looking at the simple Entity
below the field hash
does exist in Mongo when viewing the Collection
using MongoVUE. Inserting 10 slice'es
into the LinkedHashMap is working ok and everything looks ok when looking at the db in MongoDb MOngoVUE. When creating the Query
If I insert 10 I get 10 out but on the last 5 (5,6,7..) the field hash
is empty.
The Collection
BatchClass
does only have one Document and that is this one im running tests on. What can cause this behaviour?
Running test: Saving same data 5 times and 3 of this times the hash
field is empty when running the Query
.(in MonGOVUE the field hash
has the desired value on all 5 tests..
Does MongoDB have log files I can investigate?
Creating a Query
:
Query<BatchClass> query = mongo.createQuery(BatchClass.class);
query.field(BatchClass.BATCHUUID).equal(theBatch.getBatchUuid());
query.field(BatchClass.POSITION).equal(position);
res = (BatchClass) query.get();
The Entity
:
@Entity(noClassnameStored=true)
public final class BatchClass{
@Id
private ObjectId id;
@Embedded
private LinkedHashMap<Integer, Slice> sliceTable = null;
public void insertSlice(int pos, Slice slice) {
sliceTable.put(pos,slice);
}
public Map<Integer, Slice> getSliceTable() {
return sliceTable;
}
@Entity(noClassnameStored=true)
@Embedded
public static class Slice
{
public int keyPosition;
public String sliceName;
public String hash;
public int sliceFileSize;
public boolean completed = false;
}
}
The read operation that failed happened 30-60 sec after the write. Since MongoDb flushes to disk at an 60sec interval that could be the reason.