Skip to content

Commit

Permalink
Merge pull request #3832 from JuI3s/capture-scp-messages
Browse files Browse the repository at this point in the history
Easier to capture scp messages

Reviewed-by: marta-lokhova
  • Loading branch information
latobarita authored Aug 11, 2023
2 parents a5835ae + 419329c commit debd190
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/history/HistoryManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "util/Math.h"
#include "util/StatusManager.h"
#include "util/TmpDir.h"
#include "work/ConditionalWork.h"
#include "work/WorkScheduler.h"
#include "xdrpp/marshal.h"
#include <Tracy.hpp>
Expand Down Expand Up @@ -278,14 +279,28 @@ HistoryManagerImpl::takeSnapshotAndPublish(HistoryArchiveState const& has)

std::vector<std::shared_ptr<BasicWork>> seq{resolveFutures, writeSnap,
putSnap};

auto start = mApp.getClock().now();
ConditionFn delayTimeout = [start](Application& app) {
auto delayDuration = app.getConfig().PUBLISH_TO_ARCHIVE_DELAY;

auto time = app.getClock().now();
auto dur = time - start;
return std::chrono::duration_cast<std::chrono::seconds>(dur) >=
delayDuration;
};

// Pass in all bucket hashes from HAS. We cannot rely on StateSnapshot
// buckets here, because its buckets might have some futures resolved by
// now, differing from the state of the bucketlist during queueing.
//
// NB: if WorkScheduler is aborting this returns nullptr, but that
// which means we don't "really" start publishing.
mPublishWork = mApp.getWorkScheduler().scheduleWork<PublishWork>(
snap, seq, allBucketsFromHAS);
auto publishWork =
std::make_shared<PublishWork>(mApp, snap, seq, allBucketsFromHAS);

mPublishWork = mApp.getWorkScheduler().scheduleWork<ConditionalWork>(
"delay-publishing-to-archive", delayTimeout, publishWork);
}

size_t
Expand Down
6 changes: 6 additions & 0 deletions src/main/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Config::Config() : NODE_SEED(SecretKey::random())
EXPERIMENTAL_BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT = 14; // 2^14 == 16 kb
EXPERIMENTAL_BUCKETLIST_DB_INDEX_CUTOFF = 20; // 20 mb
EXPERIMENTAL_BUCKETLIST_DB_PERSIST_INDEX = true;
PUBLISH_TO_ARCHIVE_DELAY = std::chrono::seconds{0};
// automatic maintenance settings:
// short and prime with 1 hour which will cause automatic maintenance to
// rarely conflict with any other scheduled tasks on a machine (that tend to
Expand Down Expand Up @@ -1123,6 +1124,11 @@ Config::processConfig(std::shared_ptr<cpptoml::table> t)
{
ALLOW_LOCALHOST_FOR_TESTING = readBool(item);
}
else if (item.first == "PUBLISH_TO_ARCHIVE_DELAY")
{
PUBLISH_TO_ARCHIVE_DELAY =
std::chrono::seconds(readInt<uint32_t>(item));
}
else if (item.first == "AUTOMATIC_MAINTENANCE_PERIOD")
{
AUTOMATIC_MAINTENANCE_PERIOD =
Expand Down
3 changes: 3 additions & 0 deletions src/main/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ class Config : public std::enable_shared_from_this<Config>
// This config should only be enabled when testing.
std::chrono::microseconds ARTIFICIALLY_SLEEP_MAIN_THREAD_FOR_TESTING;

// Timeout before publishing externalized values to archive
std::chrono::seconds PUBLISH_TO_ARCHIVE_DELAY;

// Config parameters that force transaction application during ledger
// close to sleep for a certain amount of time.
// The probability that it sleeps for
Expand Down

0 comments on commit debd190

Please sign in to comment.