Problem
There will be cases where you see the following error in the nexus.log:
Remaining connection slots are reserved for roles with the SUPERUSER attribute
This can happen when running tasks or performing other actions in Nexus Repository that involve a Postgres database.
Symptoms
- Errors when running tasks (e.g., "Admin - Cleanup Unused Asset Blobs").
- Issues with search functionality.
Possible causes
This error indicates that the number of active connections to your PostgreSQL database has reached the maximum limit set by the max_connections parameter in your postgresql.conf file. This can happen if:
- Insufficient
max_connections: The configuredmax_connectionsvalue is too low for the current workload and concurrent connections. - High
maximumPoolSizein Nexus: ThemaximumPoolSizeproperty in yournexus-store.propertiesfile (which controls the connection pool size for Nexus) is too high, approaching or exceeding themax_connectionslimit.
Solution
Option 1: Increase max_connections (Recommended)
- Shutdown Nexus Repository: Stop Nexus to prevent new connections to the database.
- Shutdown PostgreSQL: Stop the PostgreSQL service gracefully to avoid data corruption.
- Locate
postgresql.conf: This file is usually located in the PostgreSQL data directory (e.g.,/var/lib/pgsql/dataon Linux). - Increase
max_connections: Editpostgresql.confand increase themax_connectionsvalue. Doubling the current value is a reasonable starting point.- Note: If you're already at a value such as 400+ please open a support ticket instead.
- Adjust
maximumPoolSize: Edit thenexus-store.propertiesfile (located in <data-dir>/etc/fabric) and setmaximumPoolSizeto a value that is 50-100 less than your newmax_connectionsvalue. This provides some headroom for other database connections. - Restart PostgreSQL: Start the PostgreSQL service to apply the new configuration.
- Restart Nexus Repository: Start Nexus.
Option 2: Decrease maximumPoolSize (Less Ideal)
If increasing max_connections is not feasible due to resource constraints, you can try decreasing maximumPoolSize in nexus-store.properties. However, this can negatively impact performance if you have a high-traffic Nexus instance.