spring-projects / spring-projects/spring-data-mongodb

Debug line for count() call in ReactiveMongoTemplate happens twice

Open
#4,322 2 comments 0 reactions 1 assignee View on GitHub

@marcingrzejszczak is already working on this.

Since Oct 2, 2024.

type: bug
Dominant language
Java
Stars
1.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

I was noticing that the exact same debug statement is duplicated in
https://github.com/spring-projects/spring-data-mongodb/blob/main/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoTemplate.java#L1153

and on the underlying method call at
https://github.com/spring-projects/spring-data-mongodb/blob/main/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoTemplate.java#L1172

So if we have debug logging turned on, it looked like perhaps the [expensive] count query is being done twice, but really it only happens once. I'd suggest changing or removing the debug statement on line 1153 in favor of 1172.

As it is today, the output (with debug turned on of course) looks like this, though count is only executed once:

2023-03-08T13:07:50.389-07:00 DEBUG 21153 --- [ctor-http-nio-3] o.s.d.m.core.ReactiveMongoTemplate       : Executing count: { "tenantId" : "effa4be0-573d-11e9-8647-d663bd873d93", "$or" : [{ "language" : { "$regularExpression" : { "pattern" : "en", "options" : "i"}}}, { "language" : { "$regularExpression" : { "pattern" : "fr", "options" : "i"}}}]} in collection: session
2023-03-08T13:07:50.390-07:00 DEBUG 21153 --- [ctor-http-nio-3] o.s.d.m.core.ReactiveMongoTemplate       : Executing count: { "tenantId" : "effa4be0-573d-11e9-8647-d663bd873d93", "$or" : [{ "language" : { "$regularExpression" : { "pattern" : "en", "options" : "i"}}}, { "language" : { "$regularExpression" : { "pattern" : "fr", "options" : "i"}}}]} in collection: session

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.