matador icon indicating copy to clipboard operation
matador copied to clipboard

In multithread :terminate called after throwing an instance of 'matador::database_error' what(): Authentication plugin 'mysql_native_password' cannot be loaded: not initialized

Open suisou opened this issue 5 years ago • 5 comments

i use persistence in multithead, debug it , it will stop there, persistence p(MYSQL_LINK); and give a msg

terminate called after throwing an instance of 'matador::database_error' what(): Authentication plugin 'mysql_native_password' cannot be loaded: not initialized

suisou avatar Feb 08 '20 05:02 suisou

I'll take a look into it. You start a connection within a thread. You get this error when the thread terminates or starts?

zussel avatar Feb 08 '20 13:02 zussel

before it ,another thread have run the codes for another table in the same db; persistence p(MYSQL_LINK);

suisou avatar Feb 08 '20 13:02 suisou

I have replace persistence with query , only one persistence in the main thread. other thread use query.

suisou avatar Feb 10 '20 04:02 suisou

With using only one persistence object is the correct way. Using multiple persistence objects on the same database will cause unspecified behavior. This is because every persistence object has an underlaying object_store which keeps the data loaded from the database.

Try to create just one persistence object and from that create multiple sessions and use them in your threads.

I think I'll write a kind of howto/advice using matador in a multithreded environment.

zussel avatar Feb 12 '20 08:02 zussel

I try to use query with one global conn , in multithread , It will crash too, then I add mutex ,only one query can be run , It be normal. I don't know if Mulitpe seesions with on persistence in multithread run normally.

suisou avatar Feb 13 '20 13:02 suisou