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

Filter tags on the fly - workaround for #168 #329

Merged
merged 4 commits into from
Feb 4, 2020

Conversation

octonato
Copy link
Member

@octonato octonato commented Jan 30, 2020

As discussed here: #318

We plan to cut a release for users that can't immediately migrate to the upcoming 4.0.0 (because of schema migrations).

This is a quick fix for the most annoying bug we have. When using sharded tags (like in Lagom), the eventsByTag call may return events with unrelated tags. For instance, if you search for the tag "foo1", you also get events tag "foo10".

The workaround is to filter out any partial match, in memory. Once merged and release, this can immediately benefit existing Lagom users.

@octonato octonato added this to the 3.6.0 milestone Jan 30, 2020
@octonato octonato force-pushed the quick-fix-events-by-tag branch from 22b5cea to ed0a38c Compare January 30, 2020 15:33
@octonato octonato force-pushed the quick-fix-events-by-tag branch from ed0a38c to 5fccc55 Compare January 30, 2020 20:25
private[dao] def perfectlyMatchTag(
dbPublisher: DatabasePublisher[JournalRow],
tag: String): Source[JournalRow, NotUsed] = {
Source.fromPublisher(dbPublisher).filter(_.tags.exists(tags => tags.split(",").contains(tag)))
Copy link
Member Author

Choose a reason for hiding this comment

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

I just realised that it's possible to change the tag separator and therefore the split must take that into consideration. I will change this.

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.

good workaround

*/
private[dao] def perfectlyMatchTag(
dbPublisher: DatabasePublisher[JournalRow],
tag: String): Source[JournalRow, NotUsed] = {
Copy link
Member

Choose a reason for hiding this comment

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

doesn't matter, but this is conceptually a Flow, and could be defined as such

Copy link
Member Author

Choose a reason for hiding this comment

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

I can refactor it. I don't have the reflex to think in terms of Flow. Will work on that. ;-)

Copy link
Member Author

@octonato octonato left a comment

Choose a reason for hiding this comment

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

This is good for another review round.


# The tag separator to use when tagging events with more than one tag.
# This property affects jdbc-journal.tagSeparator and jdbc-read-journal.tagSeparator.
tagSeparator = ","
Copy link
Member Author

Choose a reason for hiding this comment

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

This property was defined in two different places, but we should have only one. We should use the same on the write and read side.

jdbc-journal.tagSeparator and jdbc-read-journal.tagSeparator are now referencing this value.

*/
private[dao] def perfectlyMatchTag(tag: String, separator: String) =
Flow[JournalRow].filter(_.tags.exists(tags => tags.split(separator).contains(tag)))
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@patriknw, refactor to a Flow

Copy link
Member Author

Choose a reason for hiding this comment

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

It's now taking into consideration the separator that is defined in config file.

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

@WellingR
Copy link
Member

WellingR commented Feb 4, 2020

Looks good

Copy link
Member

@chbatey chbatey left a comment

Choose a reason for hiding this comment

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

LGTM

@octonato octonato merged commit f14245a into akka:master Feb 4, 2020
@octonato octonato deleted the quick-fix-events-by-tag branch February 4, 2020 12:55
@octonato octonato mentioned this pull request Feb 5, 2020
octonato added a commit to octonato/akka-persistence-jdbc that referenced this pull request Feb 6, 2020
octonato added a commit to octonato/akka-persistence-jdbc that referenced this pull request Feb 6, 2020
octonato added a commit that referenced this pull request Feb 6, 2020
@octonato octonato modified the milestones: 3.5.3, 4.0.0 Feb 10, 2020
WellingR added a commit to WellingR/akka-persistence-jdbc that referenced this pull request Apr 28, 2020
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