Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble with RecordSet class #2509

Closed
kongdb opened this issue Oct 17, 2018 · 3 comments
Closed

Trouble with RecordSet class #2509

kongdb opened this issue Oct 17, 2018 · 3 comments
Labels

Comments

@kongdb
Copy link

kongdb commented Oct 17, 2018

Steps to reproduce the problem

There are two type of codes.

Type A:
void thread_func(Poco::Data::SessionPool *pool)
{
Poco::Data::Session ses(pool->get());
auto rs = new Poco::Data::RecordSet(ses, "select * from question");
//use rs to traverse
delete rs;
}

Type B:
Poco::Data::RecordSet* query(const std::string &str, Poco::Data::SessionPool *pool)
{
Poco::Data::Session ses(pool->get());
auto rs = new Poco::Data::RecordSet(ses, str);
return rs;
}

void thread_func(Poco::Data::SessionPool *pool)
{
auto rs = query("select * from question", pool);
//use rs to traverse
delete rs;
}

"Type A" is quite stable, but "Type B" is easy to crash in multithread environment.
I known it must has something to do with the scope of 'Session' object, but can any one tell me the primary cause of crash.
One of the crash backtrace is:
#0 mysql_prune_stmt_list (mysql=0x7f7e00032c30) at /home/emi/mysql-5.7.23/sql-common/client.c:5155
#1 end_server (mysql=mysql@entry=0x7f7e00032c30) at /home/emi/mysql-5.7.23/sql-common/client.c:1606
#2 0x00007f7e86195630 in cli_safe_read_with_ok (mysql=mysql@entry=0x7f7e00032c30, parse_ok=parse_ok@entry=0 '\000', is_data_packet=is_data_packet@entry=0x0) at /home/emi/mysql-5.7.23/sql-common/client.c:1071
#3 0x00007f7e8619576f in cli_safe_read (mysql=mysql@entry=0x7f7e00032c30, is_data_packet=is_data_packet@entry=0x0) at /home/emi/mysql-5.7.23/sql-common/client.c:1194
#4 0x00007f7e86190016 in cli_read_prepare_result (mysql=0x7f7e00032c30, stmt=0x7f7e2800b9a0) at /home/emi/mysql-5.7.23/libmysql/libmysql.c:1469
#5 0x00007f7e8619054f in mysql_stmt_prepare (stmt=0x7f7e2800b9a0, query=0x7f7e2800bfe8 "select * from question where id in (select question_id from ai.query_question_script where script_id='40')", length=106)
at /home/emi/mysql-5.7.23/libmysql/libmysql.c:1676
#6 0x00007f7e87d87952 in Poco::Data::MySQL::StatementExecutor::prepare (this=this@entry=0x7f7e2800b850, query="select * from question where id in (select question_id from ai.query_question_script where script_id='40')")
at /home/emi/zhangjin_install_poco/poco-1.9.0-all/Data/MySQL/src/StatementExecutor.cpp:56
#7 0x00007f7e87d8c329 in Poco::Data::MySQL::MySQLStatementImpl::compileImpl (this=0x7f7e2800b650) at /home/emi/zhangjin_install_poco/poco-1.9.0-all/Data/MySQL/src/MySQLStatementImpl.cpp:122
#8 0x00007f7e8806aacc in Poco::Data::StatementImpl::compile (this=this@entry=0x7f7e2800b650) at /home/emi/zhangjin_install_poco/poco-1.9.0-all/Data/src/StatementImpl.cpp:184
#9 0x00007f7e8806abed in Poco::Data::StatementImpl::execute (this=0x7f7e2800b650, reset=@0x7f7dd7fcec8c: true) at /home/emi/zhangjin_install_poco/poco-1.9.0-all/Data/src/StatementImpl.cpp:86
#10 0x00007f7e8813cca8 in Poco::Data::Statement::execute (this=0x7f7dd7fced10, reset=true) at /home/emi/zhangjin_install_poco/poco-1.9.0-all/Data/src/Statement.cpp:105
#11 0x00007f7e8813be86 in Poco::Data::Statement::operator, (this=this@entry=0x7f7dd7fced10, manip=manip@entry=0x7f7e880e2f30 Poco::Data::Keywords::now(Poco::Data::Statement&))
at /home/emi/zhangjin_install_poco/poco-1.9.0-all/Data/src/Statement.cpp:183
#12 0x00007f7e880e4f2c in Poco::Data::RecordSet::RecordSet (this=0x7f7e2800df10, rSession=..., query="select * from question where id in (select question_id from ai.query_question_script where script_id='40')",
pRowFormatter=...) at /home/emi/zhangjin_install_poco/poco-1.9.0-all/Data/src/RecordSet.cpp:51
#13 0x00000000004018ab in query(std::string const&, Poco::Data::SessionPool*) ()
#14 0x0000000000401957 in thread_func(Poco::Data::SessionPool*) ()
#15 0x00000000004042a2 in void std::_Bind_simple<void ((Poco::Data::SessionPool))(Poco::Data::SessionPool*)>::_M_invoke<0ul>(std::_Index_tuple<0ul>) ()
#16 0x00000000004041ad in std::_Bind_simple<void ((Poco::Data::SessionPool))(Poco::Data::SessionPool*)>::operator()() ()
#17 0x0000000000404146 in std::thread::_Impl<std::_Bind_simple<void ((Poco::Data::SessionPool))(Poco::Data::SessionPool*)> >::_M_run() ()
#18 0x00007f7e8773a070 in ?? () from /lib64/libstdc++.so.6
#19 0x00007f7e86b95e25 in start_thread () from /lib64/libpthread.so.0
#20 0x00007f7e86ea234d in clone () from /lib64/libc.so.6

POCO version

v 1.9

Operating system and version

centos 7

@ChrisZhangJin
Copy link

kongdb is my colleague. I need to add remarks for the testing case.
The issue only occurs in the case of muliti-core cpu server with more than 30 threads concurrency.
so I think it is something about multi-core. We are checking it, and hope someone can help.

@github-actions
Copy link

This issue is stale because it has been open for 365 days with no activity.

@github-actions github-actions bot added the stale label Jun 24, 2022
@aleks-f
Copy link
Member

aleks-f commented Jun 24, 2022

this is a temporary string that is not guaranteed to be around after that line:

auto rs = query("select * from question", pool);

@aleks-f aleks-f closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2022
@aleks-f aleks-f added question and removed stale labels Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants