Thread: [Cppcms-users] C++DB + MySQL disconnect
Brought to you by:
artyom-beilis
From: Jon F. <jon...@jf...> - 2021-03-25 18:23:38
|
This isn't specifically a C++CMS query. I'm using C++DB with C++CMS and FLTK to query a MariaDB server. With other languages and tools I can tell the client library to auto-reconnect and it does. From the C++DB docs I should be able to append ";opt_reconnect=1" to the connection string and it should auto-reconnect. But this has not been reliable, where in other tools it is. My test FLTK app, which doesn't use a connection pool, will fail after the idle timeout set in the server (1hr in this case) and *never* reconnect. My C++CMS apps which use connection pooling kind of work but I still get random 500s and logs telling me "MySQL went away". Fortunately it seems to mostly re-connect if I hit another page and then come back to the one that broke. But I *HATE* random fails in my projects. I'm not a "80% of the time it works 100% of the time" kind of guy. So! Is there an easy fix for this? Am I misinterpreting the docs and writing that option wrong? Or do I just need to dig into the source and force that client option? I'm not even sure why its an option. ;-) Anyhow I can't go live with a real C++CMS website and have this happening. Versions: C++DB: 0.3.1 MariaDB: 10.0.38 & 10.2.25 G++: 4.9.2 TIA, Jon -- Sent from my Devuan Linux workstation -- https://devuan.org/ "Init Freedom", Yeah! Jon Foster JF Possibilities, Inc. jo...@jf... |
From: Jon F. <jon...@jf...> - 2021-03-29 20:22:51
|
For anyone else who might care: This weekend I chased this back to the MySQL backend. The MySQL client library loses all "prepared" queries when the connection drops and they aren't made again when its auto-reconnected. The C++DB backend thinks the query is still there and tries to re-use it causing the "disconnect" error to act as if its being cached. I'll have to fix this. -Jon On 03/25/2021 10:43 AM, Jon Foster wrote: > This isn't specifically a C++CMS query. I'm using C++DB with C++CMS and > FLTK to query a MariaDB server. With other languages and tools I can tell > the client library to auto-reconnect and it does. From the C++DB docs I > should be able to append ";opt_reconnect=1" to the connection string and it > should auto-reconnect. But this has not been reliable, where in other tools > it is. My test FLTK app, which doesn't use a connection pool, will fail > after the idle timeout set in the server (1hr in this case) and *never* > reconnect. My C++CMS apps which use connection pooling kind of work but I > still get random 500s and logs telling me "MySQL went away". Fortunately it > seems to mostly re-connect if I hit another page and then come back to the > one that broke. > > But I *HATE* random fails in my projects. I'm not a "80% of the time it > works 100% of the time" kind of guy. So! Is there an easy fix for this? Am > I misinterpreting the docs and writing that option wrong? Or do I just need > to dig into the source and force that client option? I'm not even sure why > its an option. ;-) Anyhow I can't go live with a real C++CMS website and > have this happening. > > Versions: > > C++DB: 0.3.1 > MariaDB: 10.0.38 & 10.2.25 > G++: 4.9.2 > > TIA, > Jon > > -- Sent from my Devuan Linux workstation -- https://devuan.org/ "Init Freedom", Yeah! Jon Foster JF Possibilities, Inc. jo...@jf... |
From: Jon F. <jon...@jf...> - 2021-03-31 19:00:30
|
Done! Fixed! If anyone else cares. - Jon On 03/29/2021 01:22 PM, Jon Foster wrote: > For anyone else who might care: This weekend I chased this back to the > MySQL backend. The MySQL client library loses all "prepared" queries when > the connection drops and they aren't made again when its auto-reconnected. > The C++DB backend thinks the query is still there and tries to re-use it > causing the "disconnect" error to act as if its being cached. I'll have to > fix this. > > -Jon > > > On 03/25/2021 10:43 AM, Jon Foster wrote: >> This isn't specifically a C++CMS query. I'm using C++DB with C++CMS and >> FLTK to query a MariaDB server. With other languages and tools I can tell >> the client library to auto-reconnect and it does. From the C++DB docs I >> should be able to append ";opt_reconnect=1" to the connection string and it >> should auto-reconnect. But this has not been reliable, where in other tools >> it is. My test FLTK app, which doesn't use a connection pool, will fail >> after the idle timeout set in the server (1hr in this case) and *never* >> reconnect. My C++CMS apps which use connection pooling kind of work but I >> still get random 500s and logs telling me "MySQL went away". Fortunately it >> seems to mostly re-connect if I hit another page and then come back to the >> one that broke. >> >> But I *HATE* random fails in my projects. I'm not a "80% of the time it >> works 100% of the time" kind of guy. So! Is there an easy fix for this? Am >> I misinterpreting the docs and writing that option wrong? Or do I just need >> to dig into the source and force that client option? I'm not even sure why >> its an option. ;-) Anyhow I can't go live with a real C++CMS website and >> have this happening. >> >> Versions: >> >> C++DB: 0.3.1 >> MariaDB: 10.0.38 & 10.2.25 >> G++: 4.9.2 >> >> TIA, >> Jon >> >> -- Sent from my Devuan Linux workstation -- https://devuan.org/ "Init Freedom", Yeah! Jon Foster JF Possibilities, Inc. jo...@jf... |