Datasource configuration question: What is the "co...
# lucee
j
Datasource configuration question: What is the "connection timeout" for? I understand the "connection idle timeout" but not the "connection timeout," when looking at both its and the idle timeout's descriptions.
Potential ways to interpret it: 1. Connection Establishment: I'm wondering if it really means the amount of time to establish the connection. But then the available options would be way overboard (from 1 minute to 1 day, instead of measured in seconds). 2. Connection Lifespan: This would be weird because Lucee happily accepts a value shorter than "Connection Idle Timeout."
g
what flavour of DB, @jamiejackson
w
i believe the connection timeout governs how long to wait from when a command is executed to when the response is received back to the application
so, a 1 min timeout may not be long enough to get large resultsets or allow lengthy processing to occur
e
that sounds right to me ⬆️ connection timeout = time limit for active connection connection idle timeout = time limit to keep connection alive after the last time it was active (can affect load/performance)
b
I don't believe any of these answers are entirely correct. • connection timeout is usually how long the JDBC driver waits while establishing the initial connection to the server (before any query is run) This is managed by the JDBC driver's underlying TCP management. • idle timeout, is how long a pooled connection will set in the pool before being closed and removed for lack of use. This is managed by the connection pooling in Lucee itself. • I don't think Lucee has any top level settings for actual query timeouts that apply to the running of a statement. This is driver specific and not all drivers support such a feature. That said, at one point Lucee used to detect which drivers supported a query timeout, and would set it equal to the remaining request timeout for the page. So for example, if your request time out was 30 seconds, and after 10 seconds had elapsed, you started a query, the query timeout sent to the JDBC driver would be 20 seconds (the remaining about of time left for the request)
Looking at the screenshot again however, it does seem perhaps Lucee is using the phrase "connection timeout" in a non-standard way. I've only seen it used in conjunction with JDBC in the manner I described above, but the default of 100 minutes certainly doesn't align well with that. 🤔
The description makes it sound as though Lucee closes connections even if they are being used, but it's not quite clear if it would close them while they are in the middle of executing a statement or whether it closes them between statements but based on the length of time since it was first established. The first option I don't think is possible and the second option makes no sense to me why you would close a perfectly good connection, lol
j
@bdw429s, your guess (bullet 3) is the same as my interpretation #1. The JDBC URI I've been using:
Copy code
jdbc:mysql://${DB_PRIMARY_HOST}:3306/${DB_PRIMARY_SCHEMA}?connectTimeout=10000&socketTimeout=120000&enablePacketDebug=true
• My connectTimeout (time to establish connection) is generous at 10s. • My socketTimeout limits query execution to 2m. I'd like to suggest description changes to the Lucee admin/docs (the docs don't mention the configs at all, or at least I couldn't find them) but I'm not even 100% clear I know which timeout Lucee's
connectTimeout
actually represents.
👍 1
e
chatGpt had this to say
Copy code
In Lucee, the Connection Timeout setting in the administrator panel controls how long Lucee waits when trying to establish a connection to an external resource, such as a database, SMTP server, or web service, before it times out and considers the attempt to have failed.

It sets a time limit for the initial connection phase. If the external resource does not respond or acknowledge the connection attempt within this timeframe, Lucee will terminate the attempt and throw an error.
b
I wouldn't believe anything ChatGPT has to say on the matter, lol
I'd say it's wrong 90% of the time when I ask it questions that specific about CF
j
Although I lean toward agreeing with that particular hallucination.
It looks like "Connection Timeout" is responsible for how old a pool connection is allowed to live, period. Say you set it to 1 minute: The connection gets removed one minute after it's created, regardless of whether it's in use currently or has ever been in use. I would think that 99.99% of admins would want to set this to infinity. Maybe there's an 0.01% niche case where pool connections get corrupted/clogged or something, and you'd want to reap them unceremoniously as a precaution. Seems like that could sever executing queries problematically, though. References: • "Connection Timeout" translates to
liveTimeout
(don't ask my why): https://github.com/lucee/Lucee/blob/656d2b3d5bae80050a5250a02e8fdd6db4e4bd9b/core/src/main/cfml/context/admin/resources/language/en.json#L1575 •
clear()
(interesting recursive function, BTW): https://github.com/lucee/Lucee/blob/656d2b3d5bae80050a5250a02e8fdd6db4e4bd9b/core/src/main/java/lucee/runtime/db/DCStack.java#L164 •
isLifeCycleTimeout()
(based on
liveTimeout
and used by
clear()
): https://github.com/lucee/Lucee/blob/656d2b3d5bae80050a5250a02e8fdd6db4e4bd9b/core/src/main/java/lucee/runtime/db/DatasourceConnectionImpl.java#L[…]3
b
Great research. That setting sounds really dumb, lol
Its not like connections get crusty and need removed. So long as they are being used and not sitting idle in the pool, I can't imagine ever wanting it to get nerfed for no reason.
Kind of like application timeout. I don't know why that's even a thing that exists ever.
👍 1
j
I may have vague (and very old) memories of connections getting clogged but I think maybe I addressed that with this stuff:
?connectTimeout=10000&socketTimeout=120000
It's funny, application timeout: You may have given me an idea for an unrelated bug I've been trying to track down. I should look into application timeout for that one.
👍 1
Since I'll forget all about this discovery in a few weeks, I put it somewhere where I can find it: https://dev.lucee.org/t/data-sources-connection-timeout-vs-connection-idle-timeout/14551
👍 1
👍🏼 1