Skip to content

MongoDB CRaC checkpoint and restore cover only the default connection #16366

Closed

Description

@codeconsole

MongoDatastore.stop() and start() (#16095) let an application take a CRaC checkpoint: stop() closes the MongoClient, because CRaC refuses to checkpoint a process holding open sockets, and start() builds a replacement after the restore. Both only cover the default connection. Three gaps, all predating #16208, where @jdaugherty found them during review:

  1. stop() leaves the named connections' clients open. It closes only the default connection's client. Each connection under grails.mongodb.connections has a child datastore with a client of its own, and none of them is closed, so a checkpoint of an application with named connections still sees their sockets.

  2. start() rebuilds only the default connection's client. Fixing the first gap also needs the children's clients replaced on restore, and anything holding a child's client has to pick up the replacement.

  3. SCHEMA multi-tenancy keeps resolving tenants through the pre-checkpoint client. The AllTenantsResolver built in the MongoDatastore constructor lists tenant ids with defaultConnectionSource.getSource().listDatabaseNames(), the client the connection source was created with, rather than getMongoClient(). After a restore that is the client stop() closed, so eachTenant, and anything else that resolves all tenants, runs against a closed client.

For reference, #16208 makes stop() and start() interrupt and resume the background index build (grails.mongodb.buildIndexesAsync) on every connection, but deliberately leaves the clients themselves as they are, since that belongs here.

Activity

  1. added a commit that references this issue on Sep 23, 2026
    7893ed4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions