Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit events by tag query ordering sizes #681

Merged
merged 5 commits into from
Sep 19, 2022

Conversation

johanandren
Copy link
Member

@johanandren johanandren commented Sep 16, 2022

This makes it possible to limit the chunks of the journal queried for events by tag to work around bad performance in some dbs when starting a new query/projection from 0 after a lot of tagged events was already persisted. By default the limiting is disabled, will need app specific tuning when enabled.

@lightbend-cla-validator

Hi @JustinPihony,

Thank you for your contribution! We really value the time you've taken to put this together.

We see that you have signed the Lightbend Contributors License Agreement before, however, the CLA has changed since you last signed it.
Please review the new CLA and sign it before we proceed with reviewing this pull request:

https://www.lightbend.com/contribute/cla

@johanandren johanandren force-pushed the wip-limit-ordering-chunks-current-events-by-tag branch from a9236ac to 2600ab5 Compare September 16, 2022 08:17
@johanandren johanandren force-pushed the wip-limit-ordering-chunks-current-events-by-tag branch from 2600ab5 to e24380e Compare September 16, 2022 08:18
@johanandren
Copy link
Member Author

Tested with a events-by-tag-buffer-sizes-per-query = 10, all tests green. I'll revert it to default as disabled now.


Source
.unfoldAsync[(Long, FlowControl), Seq[EventEnvelope]]((offset, Continue)) { case (from, control) =>
def retrieveNextBatch() = {
for {
queryUntil <- journalSequenceActor.ask(GetMaxOrderingId).mapTo[MaxOrderingId]
xs <- currentJournalEventsByTag(tag, from, batchSize, queryUntil).runWith(Sink.seq)
loopMaxOrderingId <- getLoopMaxOrderingId(from, queryUntil)
xs <- currentJournalEventsByTag(tag, from, batchSize, loopMaxOrderingId).runWith(Sink.seq)
Copy link
Member Author

Choose a reason for hiding this comment

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

Each fetch is still limited by batch size, but the far end of the query to consider is capped by from + maxOrderingRange elements, for unevenly tagged event streams that could lead to many empty results, so user will have to benchmark and tune in their specific journal.

Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

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

LGTM

@johanandren johanandren temporarily deployed to release September 16, 2022 11:01 Inactive
Copy link
Contributor

@JustinPihony JustinPihony left a comment

Choose a reason for hiding this comment

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

LGTM

@johanandren johanandren merged commit 4dc6ff7 into master Sep 19, 2022
@johanandren johanandren deleted the wip-limit-ordering-chunks-current-events-by-tag branch September 19, 2022 12:58
@johanandren johanandren added this to the 5.2.0 milestone Sep 19, 2022
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.

4 participants