[odb-users] mysql crash in multithreaded application

Lukas Obermann obermann.lukas at gmail.com
Tue Jun 20 09:25:28 EDT 2017


Hi Boris,

please let me jump in here again.
So, we are only sharing the database instance, so we should be good.
But, we are still experiencing a large amount of crashes on linux at the statement_cache.

Here is a backtrace. Do you have an idea what can cause this? Can we somehow disable the statement_cache?

Thanks,
Lukas

#0  __GI_raise (sig=sig at entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007fab2971c55a in __GI_abort () at abort.c:89
#2  0x00007fab297584d0 in __libc_message (do_abort=do_abort at entry=2, fmt=fmt at entry=0x7fab29847e68 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007fab2975e956 in malloc_printerr (action=3, str=0x7fab29844b2a "free(): invalid pointer", ptr=<optimized out>, ar_ptr=<optimized out>) at malloc.c:5077
#4  0x00007fab2975f14e in _int_free (av=0x7fab29a7aae0 <main_arena>, p=0x7faae00dce00, have_lock=0) at malloc.c:3873
#5  0x00000000012a06ea in odb::access::object_traits_impl<CODBEpisode, (odb::database_id)0>::image_type::~image_type() ()
#6  0x00000000012a0735 in odb::mysql::view_statements<ODBView_Season_Episodes>::~view_statements() ()
#7  0x00000000012a075d in odb::mysql::view_statements<ODBView_Season_Episodes>::~view_statements() ()
#8  0x00000000012291f0 in std::_Rb_tree<std::type_info const*, std::pair<std::type_info const* const, odb::details::shared_ptr<odb::mysql::statements_base> >, std::_Select1st<std::pair<std::type_info const* const, odb::details::shared_ptr<odb::mysql::statements_base> > >, odb::details::type_info_comparator, std::allocator<std::pair<std::type_info const* const, odb::details::shared_ptr<odb::mysql::statements_base> > > >::_M_erase(std::_Rb_tree_node<std::pair<std::type_info const* const, odb::details::shared_ptr<odb::mysql::statements_base> > >*) ()
#9  0x00000000012291e3 in std::_Rb_tree<std::type_info const*, std::pair<std::type_info const* const, odb::details::shared_ptr<odb::mysql::statements_base> >, std::_Select1st<std::pair<std::type_info const* const, odb::details::shared_ptr<odb::mysql::statements_base> > >, odb::details::type_info_comparator, std::allocator<std::pair<std::type_info const* const, odb::details::shared_ptr<odb::mysql::statements_base> > > >::_M_erase(std::_Rb_tree_node<std::pair<std::type_info const* const, odb::details::shared_ptr<odb::mysql::statements_base> > >*) ()
#10 0x0000000001786bb8 in std::_Rb_tree<std::type_info const*, std::pair<std::type_info const* const, odb::details::shared_ptr<odb::mysql::statements_base> >, std::_Select1st<std::pair<std::type_info const* const, odb::details::shared_ptr<odb::mysql::statements_base> > >, odb::details::type_info_comparator, std::allocator<std::pair<std::type_info const* const, odb::details::shared_ptr<odb::mysql::statements_base> > > >::~_Rb_tree() ()
#11 0x0000000001786aea in std::map<std::type_info const*, odb::details::shared_ptr<odb::mysql::statements_base>, odb::details::type_info_comparator, std::allocator<std::pair<std::type_info const* const, odb::details::shared_ptr<odb::mysql::statements_base> > > >::~map() ()
#12 0x0000000001786c42 in odb::mysql::statement_cache::~statement_cache() ()
#13 0x0000000001786c67 in odb::details::unique_ptr<odb::mysql::statement_cache>::~unique_ptr() ()
#14 0x000000000178648d in odb::mysql::connection::~connection() ()
#15 0x000000000176fc24 in odb::mysql::connection_pool_factory::pooled_connection::~pooled_connection() ()
#16 0x000000000176fc40 in odb::mysql::connection_pool_factory::pooled_connection::~pooled_connection() ()
#17 0x0000000000eb79bc in std::vector<odb::details::shared_ptr<odb::mysql::connection_pool_factory::pooled_connection>, std::allocator<odb::details::shared_ptr<odb::mysql::connection_pool_factory::pooled_connection> > >::~vector() ()
#18 0x000000000176e9e0 in odb::mysql::connection_pool_factory::~connection_pool_factory() ()
#19 0x000000000176ea08 in odb::mysql::connection_pool_factory::~connection_pool_factory() ()
#20 0x0000000001772be5 in odb::details::unique_ptr<odb::mysql::connection_factory>::~unique_ptr() ()
#21 0x00000000017706ea in odb::mysql::database::~database() ()
#22 0x000000000177077e in odb::mysql::database::~database() ()
#23 0x0000000000af9e0a in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() ()
#24 0x0000000000cbb1e1 in CVideoDatabase::~CVideoDatabase() ()
#25 0x00000000011cd23e in XFILE::CSmartPlaylistDirectory::GetDirectory(CSmartPlaylist const&, CFileItemList&, std::string const&, bool) ()
#26 0x00000000011ce1bb in XFILE::CSmartPlaylistDirectory::GetDirectory(CURL const&, CFileItemList&) ()
#27 0x00000000011a54e5 in XFILE::CDirectory::GetDirectory(CURL const&, CFileItemList&, XFILE::CDirectory::CHints const&, bool) ()
#28 0x00000000011a5999 in XFILE::CDirectory::GetDirectory(std::string const&, CFileItemList&, XFILE::CDirectory::CHints const&, bool) ()
#29 0x00000000011a5a08 in XFILE::CDirectory::GetDirectory(std::string const&, CFileItemList&, std::string const&, int, bool) ()
#30 0x0000000000e02fc5 in CDirectoryJob::DoWork() ()
#31 0x0000000000d751aa in CJobWorker::Process() ()
#32 0x0000000000dc4a11 in CThread::Action() ()
#33 0x0000000000dc50bd in CThread::staticThread(void*) ()
#34 0x00007fab2def8494 in start_thread (arg=0x7faafaffd700) at pthread_create.c:456
#35 0x00007fab297cf1bf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

> Am 20.06.2017 um 14:37 schrieb Boris Kolpackov <boris at codesynthesis.com>:
> 
> Wolfgang Haupt <haupt.wolfgang at gmail.com> writes:
> 
>> "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?
> 
> No.
> 
> 
>> I had a look at the threads sample and you also share the db instance,
>> with your worker tasks.
> 
> Yes, the database instance can be shared (as in, accessed simultaneously
> by multiple threads). Connections and transactions that you get from this
> shared database instance cannot.
> 
> Boris
> 




More information about the odb-users mailing list