Forum > Databases
Access mysql in a multithread environment
jollytall:
In the last month I did a lot of research and use it a lot. What I learnt:
Years ago (actually it was my question then) it was solved by PascalDragon. The standard libmysqlclient library (.a or .o) is not thread safe. There is a libmysqlclient_r version what is. Using InitialiseMySql the desired library can be selected.
Now, I have mariadb and it has libmariadbclient, but not the _r version. This should not be a problem, as I use a separate connection and transaction for every thread separately.
But it raised another problem that I cannot solve.
I am very careful to call the last three lines of my code earlier (Close, Free, Free) every time the thread creates and opens a connection. Still, whenever I exit my program, I get a system error:
Error in my_thread_global_end(): xxx threads didn't exit.
Reading C++ forums, they recommend to call mysql_thread_end(), but I do not find an FPC equivalent for that.
Any idea how to make many Connections and Transactions (1 pair per thread maximum - if needed) and still do not leave unfinished threads?
(Btw. in top I do not see the high number of threads neither under my process, nor under mysqld)
Navigation
[0] Message Index
[*] Previous page