Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

[PAN-1062] Specify pending transaction retention period (2 of 2) #1333

Merged
merged 26 commits into from
Apr 30, 2019

Conversation

smatthewenglish
Copy link
Contributor

@smatthewenglish smatthewenglish commented Apr 25, 2019

PR description

The acceptance criteria for this task has two components:

  • Configuration option to specify maximum length of time transactions are held in the pending transaction list before being dropped

  • When a transaction has been in the pending transaction list for the configured maximum period, it is removed

This change is intended to address the former.


Fixed Issue(s)

Specify at the command line (PantheonCommand) the maximum length of time transactions are held in the pending transaction list before being dropped.

@smatthewenglish smatthewenglish changed the title [PAN-1062] Evict old transactions (2 of 2) [PAN-1062] Specify pending transaction retention period (2 of 2) Apr 25, 2019
@smatthewenglish smatthewenglish added the work in progress Work on this pull request is ongoing label Apr 25, 2019
@@ -80,6 +80,7 @@ public void startNode(final PantheonNode node) {
new RocksDbConfiguration.Builder().databaseDir(tempDir).build())
.ethereumWireProtocolConfiguration(EthereumWireProtocolConfiguration.defaultConfig())
.clock(Clock.systemUTC())
.pendingTransactionRetentionPeriod(PendingTransactions.PENDING_TX_RETENTION_PERIOD)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this up to between 78 and 79 since they touch the same part of config. In genreral wherever we do this call as well.

@@ -48,6 +48,7 @@
* <p>This class is safe for use across multiple threads.
*/
public class PendingTransactions {
public static final int PENDING_TX_RETENTION_PERIOD = 13;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a unit in the name. Seconds? Minutes? Hours? PENDING_TX_RETENTION_HOURS?

@@ -154,7 +154,9 @@ public TestNode(
TestClock.fixed(),
PendingTransactions.MAX_PENDING_TRANSACTIONS,
metricsSystem,
syncState);
syncState,
13);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the constant.

@@ -1056,7 +1056,8 @@ public void transactionMessagesGoToTheCorrectExecutor() {
TestClock.fixed(),
PendingTransactions.MAX_PENDING_TRANSACTIONS,
metricsSystem,
mock(SyncState.class));
mock(SyncState.class),
13);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the constant.

@@ -34,6 +34,7 @@
String PANTHEON_HOME_PROPERTY_NAME = "pantheon.home";
String DEFAULT_DATA_DIR_PATH = "./build/data";
String MANDATORY_INTEGER_FORMAT_HELP = "<INTEGER>";
String PENDING_TX_RETENTION_PERIOD_FORMAT_HELP = "<INTEGER>h<INTEGER>m<INTEGER>s";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be just DURATION_HELP if we parse into the duration object.

names = {"--tx-pool-retention-period"},
paramLabel = PENDING_TX_RETENTION_PERIOD_FORMAT_HELP,
description =
"Maximum retention period of pending transactions in the transaction pool (default: ${DEFAULT-VALUE})",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need unit in the text if we stay at long/integer.

@@ -705,6 +713,7 @@ private void ensureAllNodesAreInWhitelist(
.metricsSystem(metricsSystem.get())
.privacyParameters(privacyParameters())
.clock(Clock.systemUTC())
.pendingTransactionRetentionPeriod(pendingTxRetentionPeriod)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, move next to maxPendingTransactions.

@@ -77,6 +77,10 @@
private final List<Runnable> shutdownActions = new ArrayList<>();
private RocksDbConfiguration rocksdDbConfiguration;

/* * */
protected Integer pendingTransactionRetentionPeriod;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, adjacent to maxPendingTransactions. Also, needs a unit or needs to go to Duration. One of those.

@@ -151,6 +155,12 @@
return this;
}

public PantheonControllerBuilder<C> pendingTransactionRetentionPeriod(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, adjacency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad but -- what do you mean by adjacency? maybe you mean move it near to maxPendingTransactions, but already it is

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prior to the force push it wasn't

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, yeah- I always have to force push after I rebase - is there a better way to do that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to use git pull upstream master --no-rebase when pulling changes from master after I've created the PR the first time. Avoids the need to force push.

@@ -215,6 +225,10 @@
PeerValidatorRunner.runValidator(ethContext, daoForkPeerValidator);
}

if (pendingTransactionRetentionPeriod == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like stray debug code.

@smatthewenglish smatthewenglish force-pushed the tx-period branch 2 times, most recently from 8e6b535 to 1533063 Compare April 29, 2019 15:38
@@ -33,7 +33,12 @@ public static TransactionPool createTransactionPool(
final Clock clock,
final int maxPendingTransactions,
final MetricsSystem metricsSystem,
final SyncState syncState) {
final SyncState syncState,
final int pendingTransactionRetentionPeriod) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This argument needs to be grouped next to maxPendingTransactions. between line 34 and 35

@@ -34,6 +34,7 @@
String PANTHEON_HOME_PROPERTY_NAME = "pantheon.home";
String DEFAULT_DATA_DIR_PATH = "./build/data";
String MANDATORY_INTEGER_FORMAT_HELP = "<INTEGER>";
String DURATION_HELP = "<INTEGER>";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless it's a new string simply re-use the existing generic strings. This can be deleted until we go to duration objects.

@@ -483,6 +483,14 @@ void setBootnodes(final List<String> values) {
arity = "1")
private final Integer txPoolMaxSize = PendingTransactions.MAX_PENDING_TRANSACTIONS;

@Option(
names = {"--tx-pool-retention-hours"},
paramLabel = DURATION_HELP,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
paramLabel = DURATION_HELP,
paramLabel = MANDATORY_INTEGER_FORMAT_HELP,

@@ -151,6 +155,12 @@
return this;
}

public PantheonControllerBuilder<C> pendingTransactionRetentionPeriod(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prior to the force push it wasn't

@@ -133,6 +133,7 @@ private void syncFromGenesis(final SyncMode mode) throws Exception {
.clock(TestClock.fixed())
.maxPendingTransactions(PendingTransactions.MAX_PENDING_TRANSACTIONS)
.storageProvider(createKeyValueStorageProvider(dbAhead))
.pendingTransactionRetentionPeriod(PendingTransactions.PENDING_TX_RETENTION_HOURS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move up a line, next to maxPendingTransacitons.

@@ -152,6 +153,7 @@ private void syncFromGenesis(final SyncMode mode) throws Exception {
.clock(TestClock.fixed())
.maxPendingTransactions(PendingTransactions.MAX_PENDING_TRANSACTIONS)
.storageProvider(createKeyValueStorageProvider(dbAhead))
.pendingTransactionRetentionPeriod(PendingTransactions.PENDING_TX_RETENTION_HOURS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move up a line, next to maxPendingTransacitons.

@smatthewenglish smatthewenglish force-pushed the tx-period branch 2 times, most recently from e05f1e1 to 742044a Compare April 29, 2019 20:28
@smatthewenglish smatthewenglish removed the work in progress Work on this pull request is ongoing label Apr 30, 2019
Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a couple of nits to sort out.

@@ -151,6 +155,12 @@
return this;
}

public PantheonControllerBuilder<C> pendingTransactionRetentionPeriod(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to use git pull upstream master --no-rebase when pulling changes from master after I've created the PR the first time. Avoids the need to force push.

names = {"--tx-pool-retention-hours"},
paramLabel = MANDATORY_INTEGER_FORMAT_HELP,
description =
"Maximum retention period of pending transactions, expressed in hours. Represented by primitive type 'long'. (default: ${DEFAULT-VALUE})",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: drop the redundant word 'expressed' and user's don't care how we represent the value internally.

Suggested change
"Maximum retention period of pending transactions, expressed in hours. Represented by primitive type 'long'. (default: ${DEFAULT-VALUE})",
"Maximum retention period of pending transactions in hours (default: ${DEFAULT-VALUE})",


verify(mockControllerBuilder).pendingTransactionRetentionPeriod(intArgumentCaptor.capture());

assertThat(intArgumentCaptor.getAllValues().get(0)).isEqualTo(pendingTxRetentionHours);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to use the int argument captor here - the verify(mockControllerBuilder).pendingTransactionRetentionPeriod(eq(pendingTxRetentionHours)); line below is enough to assert that the method was called with the argument we expect. You'd only use an argument captor when you don't know what the argument will be but want to check it's the same value used in some other place.

@smatthewenglish smatthewenglish merged commit a3bff1d into PegaSysEng:master Apr 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants