From f2ddb8b452bb27eceef6752b5827bd287465f540 Mon Sep 17 00:00:00 2001 From: Venkatesh Radhakrishnan Date: Thu, 15 Jan 2015 11:47:41 -0800 Subject: [PATCH] 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 --- utilities/geodb/geodb_impl.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utilities/geodb/geodb_impl.cc b/utilities/geodb/geodb_impl.cc index 194e51232..2cb9209e1 100644 --- a/utilities/geodb/geodb_impl.cc +++ b/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()) {