question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sharding with >= 10 partitions lead to non correct offset tracking (JDBC only)

See original GitHub issue

Lagom Version (1.2.x / 1.3.x / etc)

1.4.x

API (Scala / Java / Neither / Both)

Scala (not sure if reproduce in java)

Library Dependencies

val mysqlDriver = "mysql" % "mysql-connector-java" % "8.0.13"

reproduces also with postgres and h2

Expected Behavior

  1. create an entity with an id that gets mapped to a shard >9
  2. publish event to topic
  3. read_side_offsets should track offset of the published message with correct tag:
topicProducer-greetings	org.example.hello.impl.HelloEvent18	1

Actual Behavior

  1. http POST 127.0.0.1:9000/api/hello/test message=hello
  2. event is published twice to topic
  3. state of read_side_offsets as following:
topicProducer-greetings	org.example.hello.impl.HelloEvent1	1
topicProducer-greetings	org.example.hello.impl.HelloEvent18	1

Reproducible Test Case

project at: https://github.com/mikearnaldi/lagom-issue

Instructions

  1. cd hello-impl; docker-compose up -d; cd ..
  2. sbt runAll
  3. http POST 127.0.0.1:9000/api/hello/test message=hello

the event gets a tag of org.example.hello.impl.HelloEvent18 but gets forwarded to read side twice with org.example.hello.impl.HelloEvent1 and org.example.hello.impl.HelloEvent18

Note

  1. I am using httpie as a client to issue http requests
  2. I was not able to reproduce with number of shards < 10

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
octonatocommented, Jan 21, 2020

We think we can build a workaround for this by filtering out the undesired events in memory.

If you query for FooEvent1 and fetches FooEvent10 because of this bug, we can filter out all FooEvent10 and only pass FooEvent1 to read-side processors or topic producers.

It has the drawback that we will be fetching more events than needed, but at least we won’t impact the offset table.

0reactions
octonatocommented, Feb 21, 2020

There is a workaround in akka-persistence-jdbc v3.5.3. Next Lagom version will contain it (see #2693)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sharded Database Schema Design - Oracle Help Center
Sharded table partitions are distributed across shards at the tablespace level, based on a sharding key. Examples of keys include customer ID, account...
Read more >
Understanding Shard Key Selection
Shard keys are vital in a distributed database like SingleStore. They are responsible for distribution of data across partitions. Shard key ...
Read more >
Understanding Database Sharding | DigitalOcean
Sharding involves breaking up one's data into two or more smaller chunks, called logical shards. The logical shards are then distributed across ...
Read more >
Apache ShardingSphere document
The project is committed to providing a multi‐source heterogeneous, enhanced database platform and further building an ecosystem around the upper layer of ...
Read more >
Choosing the number of partitions for a topic | CDP Public Cloud
For example, if you want to be able to read 1 GB/sec, but your consumer is only able process 50 MB/sec, then you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found