mongodb - mongo java driver returning stale data from primary -
i using mongo version 2.4.5
, mongo-java-driver version 2.12.4
. have primary node , replica.
now run code following:
save 1 - inserts new document default write concern ...waits time read 1 - reads document read preference primary ...modifies save 2 - save modified doc default write concern read 2 - reads saved doc read preference primary
in last read operation, done after save, see stale data returned in cases(that modifications not reflecting). however, in cases modifications reflect.
question - if writing mongo default write concern(which acknowledged) , reading preference primary, isn't consistency guaranteed?
more details:
application connecting replica set 1 primary , 1 secondary host.
i tried overriding default write concern following: acknowledged, journaled, relpica_acknowledged in cases, read preference primary. still issue observed.
private dbcollection customers = mydb.getcollection("customers");
writeresult wr = customers.save(customer,concern);
if (wr.getn() > 0) {
ans = true;
} else ans = false;
} catch (exception e) {
ans = false;
e.printstacktrace();
}
Comments
Post a Comment