Fix for bug where GeoDB accesses key after next modification of iterator

Summary:
While running cross-functional tests for weak iterators, I
encountered a bug in GeoDB. GeoDB reads a key from the database and
tries to use it after doing a Seek. Fixing it by storing the key locally
so that it is still visible after the Seek.

Test Plan: Run geodb_test

Reviewers: sdong, igor

Reviewed By: igor

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D31599
main
Venkatesh Radhakrishnan 10 years ago
parent d10f1de2b4
commit f2ddb8b452
  1. 6
      utilities/geodb/geodb_impl.cc

@ -84,7 +84,7 @@ Status GeoDBImpl::GetByPosition(const GeoPosition& pos,
Status GeoDBImpl::GetById(const Slice& id, GeoObject* object) {
Status status;
Slice quadkey;
std::string quadkey;
// create an iterator so that we can get a consistent picture
// of the database.
@ -97,7 +97,7 @@ Status GeoDBImpl::GetById(const Slice& id, GeoObject* object) {
iter->Seek(key2);
if (iter->Valid() && iter->status().ok()) {
if (iter->key().compare(key2) == 0) {
quadkey = iter->value();
quadkey = iter->value().ToString();
}
}
if (quadkey.size() == 0) {
@ -108,7 +108,7 @@ Status GeoDBImpl::GetById(const Slice& id, GeoObject* object) {
//
// Seek to the quadkey + id prefix
//
std::string prefix = MakeKey1Prefix(quadkey.ToString(), id);
std::string prefix = MakeKey1Prefix(quadkey, id);
iter->Seek(Slice(prefix));
assert(iter->Valid());
if (!iter->Valid() || !iter->status().ok()) {

Loading…
Cancel
Save