DataGrip Connection Pool Timeout Missing in Production
0 reputation · 07 Sept 2024, 06:56 UTC
0 reputation · 07 Sept 2024, 06:56 UTC
The goal is to ensure that the production database connection pool applies the same 30‑second timeout that works locally. In the production project the JDBC URL overrides the default timeout, and the project’s connection‑pool settings do not contain a timeout property, so DataGrip inherits the server’s default and connections hang until the server times out.
Production uses a custom JDBC URL that hides the timeout, and the project file is shared across multiple users. Network latency or firewall rules can further delay the connection, making the missing timeout more pronounced.
34775 reputation · 07 Sept 2024, 17:50 UTC
To enforce a 30‑second timeout for the production DataGrip data source, add the driver‑property loginTimeout=30 (and optionally socketTimeout=60) in the Driver tab of the data source. Enable Use connection pooling so the pool honours the property. Verify the timeout by checking the Diagnostics panel or the DataGrip log file for the loginTimeout value. For a global setting, edit the driver definition instead of each project file; all projects that use that driver will inherit the timeout.
Use connection pooling is enabled, the Driver tab’s properties are applied to every connection from that pool.loginTimeout and socketTimeout to the JDBC URL or Driver tab forces the driver to terminate idle or stalled connections after the specified period.Database → Data Sources → select the production data source.+ to add a new property.loginTimeout as the name and 30 as the value.socketTimeout with a value like 60 to guard against network delays.Diagnostics panel (View → Diagnostics) and confirm that the loginTimeout appears in the pool statistics. Alternatively, check idea.log for a line such as loginTimeout=30.Instead of editing each project’s .idea file, edit the driver definition itself:
Settings → Database → Drivers.loginTimeout property as above.DataGrip writes connection‑pool statistics to idea.log (located in ~/.config/JetBrains/DataGrip/idea.log). Search for loginTimeout or socketTimeout to confirm the values being used at runtime.
Which JDBC driver and database type are you using? The exact property names and supported timeout behaviour can vary (e.g., PostgreSQL uses loginTimeout, MySQL uses loginTimeout or socketTimeout, Oracle uses loginTimeout and connectTimeout).
Use comments to ask for clarification. Post a solution as an answer.
34,775 reputation · 07 Sept 2024, 10:32 UTC
When you add loginTimeout=30 in the Driver tab, DataGrip appends it to the final JDBC URL only if Use connection pooling is enabled. If the existing URL already contains a query string, make sure to separate the new parameter with an ampersand (&) rather than a question mark, otherwise the driver may ignore it. You can verify the effective URL by opening the Help → Diagnostic Tools → Show Log in ... and looking for a line like JDBC URL: jdbc:sqlserver://host:port;loginTimeout=30 in the idea.log.