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

[MINOR / PAN-1339 (A)] Fetch local transactions in isolation #1259

Merged
merged 1 commit into from
Apr 15, 2019

Conversation

smatthewenglish
Copy link
Contributor

@smatthewenglish smatthewenglish commented Apr 11, 2019

PR description

In an effort to make the change set inevitably necessitated by the acceptance criteria of PAN-1339 less onerous, and consequently the review more palatable, I've decided to serialize it into constituent elements -- each of which constituting a relatively discrete semantic chunk.

Fixed Issue(s)

In order to disseminate local transactions to new peers we'll require a mechanism to fetch local transactions in isolation -- this is that mechanism (along with associated test infrastructure).

Copy link
Contributor

@AbdelStark AbdelStark left a comment

Choose a reason for hiding this comment

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

LGTM. 2 possible improvements comments.

@@ -88,6 +88,18 @@ public PendingTransactions(
"operation");
}

List<Transaction> getLocalTransactions() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could do it using parallel stream to optimize.

Suggested change
List<Transaction> getLocalTransactions() {
List<Transaction> getLocalTransactions() {
synchronized (pendingTransactions) {
List<Transaction> localTransactions = new ArrayList<>();
pendingTransactions
.entrySet()
.parallelStream()
.filter(transaction -> transaction.getValue().isReceivedFromLocalSource())
.forEach(transaction -> transaction.getValue().getTransaction());
return localTransactions;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion tip : cache the filtered list and store a boolean indicating whether the list is still consistent or not. Set it to false when a new transaction is received. We could have a method invalidateCachedLocalTransactions() to set this boolean to false when appropriate.

Copy link
Contributor

Choose a reason for hiding this comment

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

Class level field to avoid instantiating localTransactions each time localTransactions is called ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd avoid any such caching until we know we have a performance issue. We're currently having issues with memory usage so don't want to waste it on extra caches if they aren't necessary.

@smatthewenglish smatthewenglish merged commit 1d0014c into PegaSysEng:master Apr 15, 2019
notlesh pushed a commit to notlesh/pantheon that referenced this pull request Apr 24, 2019
notlesh pushed a commit to notlesh/pantheon that referenced this pull request May 4, 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