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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]