Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed 1.6.0-b7 #3422

Closed
wants to merge 9 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Unit tests for database shards
  • Loading branch information
p2peer authored and manojsdoshi committed May 29, 2020
commit 2a3b245fad7d7b33eddfb9b78424c4a84dcff83a
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -408,7 +408,8 @@ cache:
- $CACHE_DIR

before_install:
- if [ "$(uname)" = "Darwin" ] ; then export NUM_PROCESSORS=$(sysctl -n hw.physicalcpu); else export NUM_PROCESSORS=$(nproc); fi
# NUM_PROCESSORS was set to 1 due to problems in parallel launch of unit tests on Mac platform
- if [ "$(uname)" = "Darwin" ] ; then export NUM_PROCESSORS=1; else export NUM_PROCESSORS=$(nproc); fi
- echo "NUM PROC is ${NUM_PROCESSORS}"
- if [ "$(uname)" = "Linux" ] ; then docker pull ${DOCKER_IMAGE}; fi
- if [ "${MATRIX_EVAL}" != "" ] ; then eval "${MATRIX_EVAL}"; fi
1 change: 1 addition & 0 deletions Builds/CMake/RippledCore.cmake
Original file line number Diff line number Diff line change
@@ -844,6 +844,7 @@ target_sources (rippled PRIVATE
#]===============================]
src/test/nodestore/Backend_test.cpp
src/test/nodestore/Basics_test.cpp
src/test/nodestore/DatabaseShard_test.cpp
src/test/nodestore/Database_test.cpp
src/test/nodestore/Timing_test.cpp
src/test/nodestore/import_test.cpp
16 changes: 9 additions & 7 deletions src/ripple/nodestore/impl/DatabaseShardImp.cpp
Original file line number Diff line number Diff line change
@@ -135,13 +135,12 @@ DatabaseShardImp::init()
std::make_unique<Shard>(app_, *this, shardIndex, j_)};
if (!shard->open(scheduler_, *ctx_))
{
if (!shard->isLegacy())
return false;

// Remove legacy shard
// Remove corrupted or legacy shard
shard->removeOnDestroy();
JLOG(j_.warn())
<< "shard " << shardIndex << " removed, legacy shard";
<< "shard " << shardIndex << " removed, "
<< (shard->isLegacy() ? "legacy" : "corrupted")
<< " shard";
continue;
}

@@ -276,11 +275,11 @@ DatabaseShardImp::prepareShard(std::uint32_t shardIndex)
// is greater or equal to the current shard.
auto seqCheck = [&](std::uint32_t seq) {
// seq will be greater than zero if valid
if (seq > earliestLedgerSeq() && shardIndex >= seqToShardIndex(seq))
if (seq >= earliestLedgerSeq() && shardIndex >= seqToShardIndex(seq))
return fail("has an invalid index");
return true;
};
if (!seqCheck(app_.getLedgerMaster().getValidLedgerIndex()) ||
if (!seqCheck(app_.getLedgerMaster().getValidLedgerIndex() + 1) ||
!seqCheck(app_.getLedgerMaster().getCurrentLedgerIndex()))
{
return false;
@@ -1100,6 +1099,9 @@ DatabaseShardImp::initConfig(std::lock_guard<std::mutex>&)
ledgersPerShard_ = get<std::uint32_t>(section, "ledgers_per_shard");
if (ledgersPerShard_ == 0 || ledgersPerShard_ % 256 != 0)
return fail("'ledgers_per_shard' must be a multiple of 256");

earliestShardIndex_ = seqToShardIndex(earliestLedgerSeq());
avgShardFileSz_ = ledgersPerShard_ * kilobytes(192);
}

// NuDB is the default and only supported permanent storage backend
2 changes: 1 addition & 1 deletion src/ripple/nodestore/impl/DatabaseShardImp.h
Original file line number Diff line number Diff line change
@@ -234,7 +234,7 @@ class DatabaseShardImp : public DatabaseShard
std::uint32_t ledgersPerShard_ = ledgersPerShardDefault;

// The earliest shard index
std::uint32_t const earliestShardIndex_;
std::uint32_t earliestShardIndex_;

// Average storage space required by a shard (in bytes)
std::uint64_t avgShardFileSz_;
16 changes: 11 additions & 5 deletions src/test/jtx/Env.h
Original file line number Diff line number Diff line change
@@ -325,8 +325,10 @@ class Env

The Application network time is set to
the close time of the resulting ledger.

@return true if no error, false if error
*/
void
bool
close(
NetClock::time_point closeTime,
boost::optional<std::chrono::milliseconds> consensusDelay =
@@ -336,25 +338,29 @@ class Env

The time is calculated as the duration from
the previous ledger closing time.

@return true if no error, false if error
*/
template <class Rep, class Period>
void
bool
close(std::chrono::duration<Rep, Period> const& elapsed)
{
// VFALCO Is this the correct time?
close(now() + elapsed);
return close(now() + elapsed);
}

/** Close and advance the ledger.

The time is calculated as five seconds from
the previous ledger closing time.

@return true if no error, false if error
*/
void
bool
close()
{
// VFALCO Is this the correct time?
close(std::chrono::seconds(5));
return close(std::chrono::seconds(5));
}

/** Turn on JSON tracing.
14 changes: 11 additions & 3 deletions src/test/jtx/impl/Env.cpp
Original file line number Diff line number Diff line change
@@ -107,13 +107,14 @@ Env::closed()
return app().getLedgerMaster().getClosedLedger();
}

void
bool
Env::close(
NetClock::time_point closeTime,
boost::optional<std::chrono::milliseconds> consensusDelay)
{
// Round up to next distinguishable value
using namespace std::chrono_literals;
bool res = true;
closeTime += closed()->info().closeTimeResolution - 1s;
timeKeeper().set(closeTime);
// Go through the rpc interface unless we need to simulate
@@ -122,10 +123,17 @@ Env::close(
app().getOPs().acceptLedger(consensusDelay);
else
{
rpc("ledger_accept");
// VFALCO No error check?
auto resp = rpc("ledger_accept");
if (resp["result"]["status"] != std::string("success"))
{
JLOG(journal.error())
<< "Env::close() failed: " << resp["result"]["status"]
<< std::endl;
res = false;
}
}
timeKeeper().set(closed()->info().closeTime);
return res;
}

void
Loading