You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "pjfanning (via GitHub)" <gi...@apache.org> on 2026/01/29 17:47:57 UTC

[PR] Reduce periodic latency spikes [pekko-persistence-r2dbc]

pjfanning opened a new pull request, #307:
URL: https://github.com/apache/pekko-persistence-r2dbc/pull/307

   * see #302 
   * based on Apache licensed (now) PR - https://github.com/akka/akka-persistence-r2dbc/pull/300


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Reduce periodic latency spikes [pekko-persistence-r2dbc]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #307:
URL: https://github.com/apache/pekko-persistence-r2dbc/pull/307#issuecomment-3829054943

   I'm not sure it's a good idea to make the hardcoded settings configurable. We could patch in configurability at a later stage but it's quite possible that users could do more harm than good by choosing ad hoc configs. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Reduce periodic latency spikes [pekko-persistence-r2dbc]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #307:
URL: https://github.com/apache/pekko-persistence-r2dbc/pull/307#discussion_r2749675607


##########
core/src/main/scala/org/apache/pekko/persistence/r2dbc/internal/BySliceQuery.scala:
##########
@@ -346,7 +348,8 @@ import org.slf4j.Logger
     }
 
     def switchFromBacktracking(state: QueryState): Boolean = {
-      state.backtracking && state.rowCount < settings.bufferSize - 1
+      // backtrackingCount is for fairness, to not run too many backtracking queries in a row
+      state.backtracking && (state.backtrackingCount >= 3 || state.rowCount < settings.bufferSize - 1)

Review Comment:
   The backtracking fairness limit is hard-coded as `>= 3` consecutive backtracking queries. Please extract this into a named constant (or ideally a setting) so the behavior is self-documenting and can be tuned without code changes if it turns out to be too aggressive/conservative for different workloads.



##########
core/src/main/scala/org/apache/pekko/persistence/r2dbc/query/scaladsl/R2dbcReadJournal.scala:
##########
@@ -171,7 +171,9 @@ final class R2dbcReadJournal(system: ExtendedActorSystem, config: Config, cfgPat
               pubSub.eventTopic(entityType, slice) ! Topic.Subscribe(ref.toTyped[EventEnvelope[Event]])
             }
           }
-      dbSource.merge(pubSubSource).via(deduplicate(settings.deduplicateCapacity))
+      dbSource
+        .mergePrioritized(pubSubSource, leftPriority = 1, rightPriority = 10)
+        .via(deduplicate(settings.deduplicateCapacity))

Review Comment:
   `mergePrioritized` introduces hard-coded priority weights (1 vs 10) with no in-code rationale or configurability. Since the pub-sub stream uses `OverflowStrategy.dropNew`, completeness still relies on the DB source catching up reasonably; please either document why these weights are safe/tuned for typical workloads or extract them into a named constant/config setting so operators can adjust the tradeoff between catch-up throughput and low-latency published events.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Reduce periodic latency spikes [pekko-persistence-r2dbc]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning merged PR #307:
URL: https://github.com/apache/pekko-persistence-r2dbc/pull/307


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org