Skip to content

Commit

Permalink
Make the transaction job queue limit adjustable:
Browse files Browse the repository at this point in the history
The job queue can impose limits of how many jobs of a particular
type can be queued.

This commit makes the previously hard-coded limit associated with
transactions configurable by the server's operator. Servers that
have increased memory capacity or which expect to see an influx
of transactions can increase the number of transactions their
server will be able to queue.

This commit fixes #3556.
  • Loading branch information
natenichols authored and nbougalis committed Sep 1, 2020
1 parent b1d47c6 commit 660d9c1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
7 changes: 7 additions & 0 deletions cfg/rippled-example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,13 @@
#
#
#
# [max_transactions]
#
# Configure the maximum number of transactions to have in the job queue
#
# Must be a number between 100 and 1000, defaults to 250
#
#
# [overlay]
#
# Controls settings related to the peer to peer overlay.
Expand Down
5 changes: 5 additions & 0 deletions src/ripple/core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ class Config : public BasicConfig
// Compression
bool COMPRESSION = false;

// Work queue limits
int MAX_TRANSACTIONS = 250;
static constexpr int MAX_JOB_QUEUE_TX = 1000;
static constexpr int MIN_JOB_QUEUE_TX = 100;

// Amendment majority time
std::chrono::seconds AMENDMENT_MAJORITY_TIME = defaultAmendmentMajorityTime;

Expand Down
1 change: 1 addition & 0 deletions src/ripple/core/ConfigSections.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct ConfigSection
#define SECTION_IPS "ips"
#define SECTION_IPS_FIXED "ips_fixed"
#define SECTION_LEDGER_HISTORY "ledger_history"
#define SECTION_MAX_TRANSACTIONS "max_transactions"
#define SECTION_NETWORK_QUORUM "network_quorum"
#define SECTION_NODE_SEED "node_seed"
#define SECTION_NODE_SIZE "node_size"
Expand Down
8 changes: 8 additions & 0 deletions src/ripple/core/impl/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,14 @@ Config::loadFromString(std::string const& fileContents)
REDUCE_RELAY_SQUELCH = sec.value_or("squelch", false);
}

if (getSingleSection(secConfig, SECTION_MAX_TRANSACTIONS, strTemp, j_))
{
MAX_TRANSACTIONS = std::clamp(
beast::lexicalCastThrow<int>(strTemp),
MIN_JOB_QUEUE_TX,
MAX_JOB_QUEUE_TX);
}

if (getSingleSection(
secConfig, SECTION_AMENDMENT_MAJORITY_TIME, strTemp, j_))
{
Expand Down
5 changes: 2 additions & 3 deletions src/ripple/overlay/impl/PeerImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1512,9 +1512,8 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMTransaction> const& m)
}
}

// The maximum number of transactions to have in the job queue.
constexpr int max_transactions = 250;
if (app_.getJobQueue().getJobCount(jtTRANSACTION) > max_transactions)
if (app_.getJobQueue().getJobCount(jtTRANSACTION) >
app_.config().MAX_TRANSACTIONS)
{
overlay_.incJqTransOverflow();
JLOG(p_journal_.info()) << "Transaction queue is full";
Expand Down

0 comments on commit 660d9c1

Please sign in to comment.