[odb-users] mysql crash in multithreaded application

Wolfgang Haupt haupt.wolfgang at gmail.com
Mon Jun 19 18:14:03 EDT 2017


Hi Boris,

regarding:
"So as long as you don't share connections or
transactions between threads, it should work."

Does it mean the default mysql factory is not thread safe?
I had a look at the threads sample and you also share the db instance,
with your worker tasks.
I guess it's meant to be used in that way, right?
If so I think I'm doing it right as I also have only 1 db instance that
is shared with the worker threads.


Best Regards,
Wolfgang

Boris Kolpackov <boris at codesynthesis.com> schrieb am Mo., 19. Juni 2017 um
18:30 Uhr:

> Hi Wolfgang,
>
> Wolfgang Haupt <haupt.wolfgang at gmail.com> writes:
>
> > I don't use a connection_factory, so I assume every thread get's a new
> > connection and it does not close existing ones, if I got it correct from
> > the docs.
>
> Right, you are using the connection pool factory by default which will
> recycle the connections. So as long as you don't share connections or
> transactions between threads, it should work.
>
>
> > I found following mysql multithreaded information:
> >
> https://stackoverflow.com/questions/26936481/multithreaded-programming-with-libmysql
> > Does odb do this already?
>
> Yes, though the way this is done is pretty crazy (thanks to the way MySQL
> does things). See odb/mysql/connection-factory.cxx in libodb-mysql for
> the gory details.
>
> One thing that you can try is build the 'common/threads' test from the
> odb-tests package. If it works then it is most likely the problem is in
> your application.
>
> Boris
>


More information about the odb-users mailing list