pjfanning opened a new issue, #521:
URL: https://github.com/apache/pekko-persistence-r2dbc/issues/521
`R2dbcExecutor` treats a negative `logDbCallsExceeding` (e.g.
`log-db-calls-exceeding = off`, or the `-1.millis` that
`session.scaladsl.R2dbcSession.withSession` passes as `logDbCallsDisabled`) as
"disabled", but disabling only stops the timing, not the logging:
```scala
private val logDbCallsExceedingEnabled = logDbCallsExceedingMicros >= 0
private def nanoTime(): Long =
if (logDbCallsExceedingEnabled) System.nanoTime() else 0L
private def durationInMicros(startTime: Long): Long = (nanoTime() -
startTime) / 1000
```
When disabled, `durationInMicros` returns `0`, and every check like `if
(durationMicros >= logDbCallsExceedingMicros)` is `0 >= -1000`, so
`getConnection took`, `Selected [n] rows in`, and `DB call completed in` are
logged at INFO for every call. This hits every user of
`R2dbcSession.withSession` (scaladsl and javadsl), plus anyone who configures
`log-db-calls-exceeding = off`.
Akka fixed this in akka/akka-persistence-r2dbc#328 (fixes
akka/akka-persistence-r2dbc#327, released in 1.1.0, now Apache 2.0 licensed
after its 2026-04-28 change date) by returning `Long.MinValue` from
`durationInMicros` when disabled:
```scala
private def durationInMicros(startTime: Long): Long =
if (logDbCallsExceedingEnabled) (nanoTime() - startTime) / 1000 else
Long.MinValue
```
Found while porting akka/akka-projection#1017 (`R2dbcSession.withSession`)
to pekko-projection (apache/pekko-projection#664), which works around it by
using the projection's `log-db-calls-exceeding` setting instead of `-1.millis`.
--
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]