What steps will reproduce the problem?
1.all code adn information showed in the additional information
2.
3.
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
leveldb 1.9 fedora17
Please provide any additional information below.
code begin=================================================
const leveldb::Snapshot* snap_shot = db->GetSnapshot();
leveldb::ReadOptions read_options;
// change "key0"'s value from "value0" to "new"
db->Put(leveldb::WriteOptions(),"key0","new");
string val;
db->Get(read_options,"key0",&val);
cout<<"no snapshot value: "<<val<<endl;//output " new" .
read_options.snapshot = snap_shot;
db->Get(read_options,"key0",&val);
cout<<"snapshot value: "<<val<<endl;//output "value0" .
// release snapshot
db->ReleaseSnapshot(read_options.snapshot);
db->Get(read_options,"key0",&val);
cout<<"after release snapshot: "<<val<<endl;
//output "value0" !!! It's wrong
code end===================================================
Advice:
If i release the snapshot ,i should get the newest infomation.
But only i add the "read_options.snapshot = NULL; " after
db->ReleaseSnapshot(...)manually,can i get the right result---output "new".
I deep into the code in db_imp.cc and know it will judge
"options.snapshot!=NULL" when call NewIterator(...) and Get(...) .
SO I think set the read_options.snapshot=NULL in DB::ReleaseSnapshot() is a
good idea. Or you should modify the document clearly and add
"read_options.snapshot = NULL;" to the example in the Snapshots part of
http://leveldb.googlecode.com/svn/trunk/doc/index.html
Original issue reported on code.google.com by wangteng...@gmail.com on 15 May 2013 at 11:37
Original issue reported on code.google.com by
wangteng...@gmail.com
on 15 May 2013 at 11:37