Skip to content

Conversation

@patchwork01
Copy link
Collaborator

Make sure you have checked all steps below.

Issue

Tests

  • My PR adds the following tests based on our test strategy OR does not need testing for this extremely good reason:
    • Updated StateStoreProviderTest

Documentation

  • In case of new functionality, my PR adds documentation that describes how to use it, or I have linked to a
    separate issue for that below.
  • If I have added new Java code, I have added Javadoc that explains it following our conventions and style.
  • If I have added or removed any dependencies from the project, I have updated the NOTICES file.

@patchwork01 patchwork01 marked this pull request as ready for review January 23, 2026 15:42
@patchwork01 patchwork01 added the needs-reviewer Pull requests that need a reviewer to be assigned label Jan 23, 2026
"be used in cases where the state store cache is the main use of memory, currently only in a " +
"state store committer on the EC2 platform. This affects how many state stores can be cached in " +
"memory.")
.defaultValue("1")
Copy link
Collaborator

@rtjd6554 rtjd6554 Jan 26, 2026

Choose a reason for hiding this comment

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

Is 1% an realistic value here for default?
(Know it was previously this, just checking logic is sound given we are making changes in this area)

Copy link
Member

Choose a reason for hiding this comment

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

We could remove the percentage property. When I was building this feature out I started off by evicting state stores to keep a certain percentage of the heap available. However, I switched to a fixed limit as I was testing and found that everything continued to work with <1% and it felt awkward setting the property to smaller percentages.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done


// Try to make sure there is going to be enough heap space available to process these commits
ensureEnoughHeapSpaceAvailable(messagesByTableId.keySet());
while (!stateStoreProvider.ensureEnoughHeapSpaceAvailable(messagesByTableId.keySet())) {
Copy link
Member

Choose a reason for hiding this comment

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

Getting java.lang.NullPointerException: Cannot invoke "sleeper.core.statestore.StateStoreProvider.ensureEnoughHeapSpaceAvailable(java.util.Collection)" because "this.stateStoreProvider" is null. It becomes not null when we receive our first message from the SQS queue, but if no messages are immediately available then this error is thrown. Add stateStoreProvider != null to while or wrap with an if?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've reproduced that in MultiThreadedStateStoreCommitterLocalStackIT and fixed it, thanks.

"be used in cases where the state store cache is the main use of memory, currently only in a " +
"state store committer on the EC2 platform. This affects how many state stores can be cached in " +
"memory.")
.defaultValue("1")
Copy link
Member

Choose a reason for hiding this comment

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

We could remove the percentage property. When I was building this feature out I started off by evicting state stores to keep a certain percentage of the heap available. However, I switched to a fixed limit as I was testing and found that everything continued to work with <1% and it felt awkward setting the property to smaller percentages.

@patchwork01 patchwork01 removed the needs-reviewer Pull requests that need a reviewer to be assigned label Jan 27, 2026
@patchwork01 patchwork01 self-assigned this Jan 27, 2026
@patchwork01 patchwork01 removed their assignment Jan 27, 2026
@patchwork01 patchwork01 added the needs-reviewer Pull requests that need a reviewer to be assigned label Jan 27, 2026
@patchwork01 patchwork01 self-assigned this Jan 28, 2026
@patchwork01 patchwork01 removed the needs-reviewer Pull requests that need a reviewer to be assigned label Jan 28, 2026
@patchwork01 patchwork01 assigned rtjd6554 and unassigned patchwork01 Jan 28, 2026
@patchwork01 patchwork01 added the needs-reviewer Pull requests that need a reviewer to be assigned label Jan 28, 2026
LoggedDuration.withShortOutput(startedAt, Instant.now()),
LoggedDuration.withShortOutput(lastReceivedCommitsAt, Instant.now()));

lastReceivedCommitsAt = Instant.now();
Copy link
Member

Choose a reason for hiding this comment

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

This is incorrectly getting set when no commits have been taken off the queue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry about that, I've reverted this change.

}

@Override
public final String toString() {
Copy link
Member

Choose a reason for hiding this comment

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

As you've mentioned in the docs for this class, the field names are a bit complicated to understand. This implementation of toString results in logs that look like this:

[main] core.statestore.StateStoreProvider DEBUG - Keeping 100 MB free. Found memory use: JvmMemoryUse{totalMemory='80 MB', freeMemory='46 MB', maxMemory='6 GB'}

This makes it look like there isn't enough memory available, but there is. Should the loggers reference .availableMemory() instead of relying on .toString() to make the log output clearer? or should availableMemory be included in the toString() output?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've adjusted the toString method and added unit tests for it.

@rtjd6554 rtjd6554 assigned patchwork01 and unassigned rtjd6554 Jan 29, 2026
@patchwork01 patchwork01 removed their assignment Jan 29, 2026
@patchwork01 patchwork01 removed the needs-reviewer Pull requests that need a reviewer to be assigned label Jan 29, 2026
@patchwork01 patchwork01 self-assigned this Jan 29, 2026
@patchwork01 patchwork01 merged commit a029831 into develop Jan 29, 2026
9 checks passed
@patchwork01 patchwork01 deleted the 6438-state-store-committer-heap-space branch January 29, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve & test management of heap space in state store committer

4 participants