What does 'validate' do in database config?

We’re getting some very rare strange query results that look like our Lucee code isn’t thread safe.
(an email occasionally getting sent to a different distribution list). I continue poring thru the code and believe it’s okay. And I’m willing to share it if folks want to pore thru it with me but at the moment I’m entertaining other possible theories.

This is in GCP Cloud Run which has CPU allocation ONLY during the request. One theory I’m developing is that database connection pools that are assumed to be maintained between requests are getting mangled because the CPU won’t necessarily handle any off-request activity.

So - I’m thinking I could ask the system to check any database connections it gets from it’s assumed valid connection pool. In other words, I’m thinking that the ‘validate’ flag set to true on a datasource would do exactly this. But I can’t find any docs anywhere that confirm or deny this.

Does anyone have any info they can point me to?

Thanks,

Don’t forget to tell us about your stack!

GCP image admin reports:

Servlet Container Apache Tomcat/9.0.75
Java 11.0.19 (Eclipse Adoptium) 64bit
Host Name localhost
OS Linux (6.1.0-10-amd64) 64bit
Architecture 64bit

please always mention the lucee version, plus any relevant extensions, in this case the database extension / bundle version

as per the admin, Validate the connection before use (only works with JDBC 4.0 Drivers)

I don’t follow your logic here tho, are you saying the wrong results are being returned for a query? That can’t / shouldn’t be affected by the connection pool, either there is a db connection or it isn’t.

@Brian_Harcourt : What does ‘validate’ do in database config?
… ask the system to check any database connections it gets from it’s assumed valid connection pool. In other words, I’m thinking that the ‘validate’ flag set to true on a datasource would do exactly this.

I think the answer you’ve given to your own question is correct.

The culprit might be the non-query code rather than the query code. It would help to share the code.

:face_with_open_eyes_and_hand_over_mouth:
Yeah - no - it was my poorly scoped variables. I was grasping at straws. A bit of thinking kept raising @Zackster’s point.

I still wonder about the question - tho I imagine it out of scope for this thread; What exactly is ‘validate’? Does it send some kind of system query (‘SELECT getdate()’)? to validate? And further, what does happen to a connection pool when the CPU stops handling threads between requests? All answers (I assume) would require a more detailed knowledge of connection pooling. One day, maybe I’ll have time to learn.

Thanks all.

as per the admin it’s just jdbc Connection (Java Platform SE 7 )

@Brian_Harcourt : What exactly is ‘validate’?

I think that the Validate setting enables the JDBC driver API call, isValid(). The call checks whether the connection has not been closed and is still valid.

Does it send some kind of system query (‘SELECT getdate()’)? to validate?

Yes, I think the JDBC driver uses an in-built query for validation.

…what does happen to a connection pool when the CPU stops handling threads between requests?

The connection pool is a cache of database connection objects. As such it is separate from request-thread handling in the application. Again, this is just my take on the questions.