matrei opened a new issue, #16354:
URL: https://github.com/apache/grails-core/issues/16354

   ## Summary
   
   On `7.0.x`, `GrailsDataTckSpec.setup()` calls `manager.setup(specClass)` for 
every feature, and `GrailsDataMongoTckManager` then creates a new 
`MongoDatastore` over all default TCK domain classes plus the spec's own, which 
creates collections and indexes for each of them, and `destroy()` drops the 
databases again after the feature. Each spec starts its own `mongo:7.0.19` 
container in `setupSpec`. WiredTiger keeps dropped idents open until its next 
checkpoint, so within one spec the number of open files grows with the number 
of features. Under Docker's default 1024 soft limit for `nofile`, a spec with 
enough features drives mongod into `EMFILE`, WiredTiger panics, and mongod 
aborts with exit code 14. The test worker then blocks in 
`MongoDatastore.initializeIndices` server selection without timing out, so the 
Gradle run never finishes.
   
   Observed in the full `grails-data-mongodb-core` suite on a stock Docker 
install: the crash occurs in `NamedQuerySpec` (a shared TCK spec from 
`grails-datamapping-tck`, 38 features). The 8.0.x manager does not create the 
datastore per feature and the same suite passes there.
   
   ## Reproduce
   
   1. Confirm the container limit: `docker run --rm mongo:7.0.19 sh -c 'ulimit 
-n'` prints `1024`.
   2. `./gradlew :grails-data-mongodb-core:cleanTest 
:grails-data-mongodb-core:test`
   3. Watch `docker events` for `die mongo:7.0.19 exit=14`; the run hangs 
afterwards. Attach `docker logs -f` to the container before the crash to see 
`__posix_directory_sync ... Too many open files` followed by `Fatal assertion 
50853`.
   
   ## Workaround
   
   Raising the container limit in `GrailsDataMongoTckManager.setupSpec` makes 
the suite pass:
   
   ```groovy
   mongoDBContainer = new 
MongoDBContainer(AbstractMongoGrailsExtension.desiredMongoDockerName)
           .withCreateContainerCmdModifier { cmd ->
               cmd.hostConfig.withUlimits([new 
com.github.dockerjava.api.model.Ulimit('nofile', 65536L, 65536L)])
           }
   ```
   
   ## Suggested fix
   
   Either of these removes the churn rather than masking it:
   
   - Create the datastore once per spec (in `setupSpec`) and only clear data 
between features, as the 8.0.x manager effectively does.
   - Keep per-feature setup but register only the spec's own domain classes 
instead of the full default TCK list.
   
   Raising the ulimit as above is a reasonable belt-and-braces addition either 
way, since it also protects against the driver's indefinite wait after a server 
crash.
   


-- 
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]

Reply via email to