From a39dec1380f61bee25d0cc9fe20c3008bb37d37d Mon Sep 17 00:00:00 2001 From: Josh Slocum Date: Tue, 25 May 2021 15:51:26 +0000 Subject: [PATCH 1/2] Fixing multiple small redwood test bugs --- fdbserver/VersionedBTree.actor.cpp | 37 ++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/fdbserver/VersionedBTree.actor.cpp b/fdbserver/VersionedBTree.actor.cpp index 8a919fd190..49eac05655 100644 --- a/fdbserver/VersionedBTree.actor.cpp +++ b/fdbserver/VersionedBTree.actor.cpp @@ -40,6 +40,12 @@ #define REDWOOD_DEBUG 0 +// Only print redwood debug statements for a certain address. Useful in simulation with many redwood processes to reduce +// log size. +#define REDWOOD_DEBUG_ADDR 0 +// example addr: "[abcd::4:0:1:4]:1" +#define REDWOOD_DEBUG_ADDR_VAL ""; + #define debug_printf_stream stdout #define debug_printf_always(...) \ { \ @@ -49,11 +55,25 @@ fflush(debug_printf_stream); \ } +#define debug_printf_addr(...) \ + { \ + std::string addr = REDWOOD_DEBUG_ADDR_VAL; \ + if (!memcmp(addr.c_str(), g_network->getLocalAddress().toString().c_str(), addr.size())) { \ + std::string prefix = \ + format("%s %f %04d ", g_network->getLocalAddress().toString().c_str(), now(), __LINE__); \ + std::string msg = format(__VA_ARGS__); \ + writePrefixedLines(debug_printf_stream, prefix, msg); \ + fflush(debug_printf_stream); \ + } \ + } + #define debug_printf_noop(...) #if defined(NO_INTELLISENSE) #if REDWOOD_DEBUG #define debug_printf debug_printf_always +#elif REDWOOD_DEBUG_ADDR +#define debug_printf debug_printf_addr #else #define debug_printf debug_printf_noop #endif @@ -3868,9 +3888,10 @@ private: std::unordered_map parents; ParentInfoMapT childUpdateTracker; - // MetaKey changes size so allocate space for it to expand into + // MetaKey changes size so allocate space for it to expand into. FIXME: Steve is fixing this to be dynamically + // sized. union { - uint8_t headerSpace[sizeof(MetaKey) + sizeof(LogicalPageID) * 30]; + uint8_t headerSpace[sizeof(MetaKey) + sizeof(LogicalPageID) * 200]; MetaKey m_header; }; @@ -7548,7 +7569,11 @@ TEST_CASE("/redwood/correctness/unit/deltaTree/IntIntPair") { std::set uniqueItems; while (uniqueItems.size() < N) { IntIntPair p = randomPair(); - if (uniqueItems.count(p) == 0) { + auto nextP = p; // also check if next highest/lowest key is not in set for testLTE/testGTE + nextP.v++; + auto prevP = p; + prevP.v--; + if (uniqueItems.count(p) == 0 && uniqueItems.count(nextP) == 0 && uniqueItems.count(prevP) == 0) { uniqueItems.insert(p); } } @@ -7566,7 +7591,11 @@ TEST_CASE("/redwood/correctness/unit/deltaTree/IntIntPair") { std::vector toDelete; while (1) { IntIntPair p = randomPair(); - if (uniqueItems.count(p) == 0) { + auto nextP = p; // also check if next highest/lowest key is not in set for testLTE/testGTE + nextP.v++; + auto prevP = p; + prevP.v--; + if (uniqueItems.count(p) == 0 && uniqueItems.count(nextP) == 0 && uniqueItems.count(prevP) == 0) { if (!r.insert(p)) { break; }; From 95ab07fcb698ff5cbc926ada3c9974b5cb33b031 Mon Sep 17 00:00:00 2001 From: Josh Slocum Date: Tue, 25 May 2021 20:42:07 +0000 Subject: [PATCH 2/2] Adding comments for clarity --- fdbserver/VersionedBTree.actor.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fdbserver/VersionedBTree.actor.cpp b/fdbserver/VersionedBTree.actor.cpp index 49eac05655..454e7ea5d9 100644 --- a/fdbserver/VersionedBTree.actor.cpp +++ b/fdbserver/VersionedBTree.actor.cpp @@ -7565,11 +7565,11 @@ TEST_CASE("/redwood/correctness/unit/deltaTree/IntIntPair") { { deterministicRandom()->randomInt(prev.k, next.k), deterministicRandom()->randomInt(prev.v, next.v) }); }; - // Build a set of N unique items + // Build a set of N unique items, where no consecutive items are in the set, a requirement of the seek behavior tests. std::set uniqueItems; while (uniqueItems.size() < N) { IntIntPair p = randomPair(); - auto nextP = p; // also check if next highest/lowest key is not in set for testLTE/testGTE + auto nextP = p; // also check if next highest/lowest key is not in set nextP.v++; auto prevP = p; prevP.v--; @@ -7591,7 +7591,7 @@ TEST_CASE("/redwood/correctness/unit/deltaTree/IntIntPair") { std::vector toDelete; while (1) { IntIntPair p = randomPair(); - auto nextP = p; // also check if next highest/lowest key is not in set for testLTE/testGTE + auto nextP = p; // also check if next highest/lowest key is not in the set nextP.v++; auto prevP = p; prevP.v--; @@ -7745,6 +7745,7 @@ TEST_CASE("/redwood/correctness/unit/deltaTree/IntIntPair") { } // SeekLTE to the next possible int pair value after each element to make sure the base element is found + // Assumes no consecutive items are present in the set for (int i = 0; i < items.size(); ++i) { IntIntPair p = items[i]; IntIntPair q = p; @@ -7761,6 +7762,7 @@ TEST_CASE("/redwood/correctness/unit/deltaTree/IntIntPair") { } // SeekGTE to the previous possible int pair value after each element to make sure the base element is found + // Assumes no consecutive items are present in the set for (int i = 0; i < items.size(); ++i) { IntIntPair p = items[i]; IntIntPair q = p; @@ -7796,6 +7798,7 @@ TEST_CASE("/redwood/correctness/unit/deltaTree/IntIntPair") { } // SeekLTE to each element's next possible value, using each element as a hint + // Assumes no consecutive items are present in the set for (int i = 0; i < items.size(); ++i) { IntIntPair p = items[i]; IntIntPair q = p;