chibenwa commented on code in PR #2514:
URL: https://github.com/apache/james-project/pull/2514#discussion_r1853445059


##########
backends-common/postgres/src/main/java/org/apache/james/backends/postgres/utils/PostgresExecutor.java:
##########
@@ -125,16 +126,26 @@ public Mono<Void> executeVoid(Function<DSLContext, 
Mono<?>> queryFunction) {
     }
 
     public Flux<Record> executeRows(Function<DSLContext, Flux<Record>> 
queryFunction) {
+        return executeRows(queryFunction, !EAGER_FETCH);
+    }
+
+    public Flux<Record> executeRows(Function<DSLContext, Flux<Record>> 
queryFunction, boolean isEagerFetch) {
         return 
Flux.from(metricFactory.decoratePublisherWithTimerMetric("postgres-execution",
             Flux.usingWhen(getConnection(domain),
-                connection -> dslContext(connection)
-                    .flatMapMany(queryFunction)
-                    .timeout(postgresConfiguration.getJooqReactiveTimeout())
-                    .doOnError(TimeoutException.class, e -> 
LOGGER.error(JOOQ_TIMEOUT_ERROR_LOG, e))
-                    .collectList()
-                    .flatMapIterable(list -> list) // Mitigation fix for 
https://github.com/jOOQ/jOOQ/issues/16556
-                    .retryWhen(Retry.backoff(MAX_RETRY_ATTEMPTS, MIN_BACKOFF)
-                        .filter(preparedStatementConflictException())),
+                connection -> {
+                    Flux<Record> recordFlux = dslContext(connection)
+                        .flatMapMany(queryFunction)
+                        
.timeout(postgresConfiguration.getJooqReactiveTimeout())
+                        .doOnError(TimeoutException.class, e -> 
LOGGER.error(JOOQ_TIMEOUT_ERROR_LOG, e))
+                        .retryWhen(Retry.backoff(MAX_RETRY_ATTEMPTS, 
MIN_BACKOFF)
+                            .filter(preparedStatementConflictException()));
+
+                    if (isEagerFetch) {

Review Comment:
   Link an issue in a comment to explain this.



-- 
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-unsubscr...@james.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to