问题描述
OceanBase 数据库执行带有 PUBLIC/CONNECT/RESOURCE 特殊保留字的语法 ALTER USER <特殊保留字> IDENTIFIED BY xxx; 将导致 OBServer Crash 掉。
适用版本
OceanBase 数据库 V2.x 和 V3.x 版本。
问题原因
OceanBase 数据库执行带有 PUBLIC/CONNECT/RESOURCE 特殊保留字的语法 ALTER USER <特殊保留字> IDENTIFIED BY xxx;,因为语法上不存在孩子节点,但是在解析的时候仍然去访问无效的地址导致 OBServer Crash 掉,堆栈关键信息如下。
oceanbase::sql::ObSetPasswordResolver::resolve (this=xxxxx, parse_tree=...)
oceanbase::sql::ObResolver::stmt_resolver_func<oceanbase::sql::ObSetPasswordResolver> (this=this@entry=xxxxx, params=..., parse_tree=..., stmt=@xxxxx: 0x0)
oceanbase::sql::ObResolver::resolve (this=this@entry=xxxxx, if_prepared=if_prepared@entry=oceanbase::sql::ObResolver::IS_NOT_PREPARED_STMT, parse_tree=..., stmt=@xxxxx: 0x0)
oceanbase::sql::ObSql::generate_stmt (this=this@entry=xxxxx <oceanbase::observer::ObServer::get_instance()::THE_ONE+1113280>, parse_result=..., pc_ctx=pc_ctx@entry=xxxxx, context=..., allocator=..., result=..., stmt=@xxxxx: 0x0)
oceanbase::sql::ObSql::generate_physical_plan (this=this@entry=xxxxx <oceanbase::observer::ObServer::get_instance()::THE_ONE+1113280>, parse_result=..., pc_ctx=pc_ctx@entry=xxxxx, sql_ctx=..., result=..., is_ps_mode=is_ps_mode@entry=false)
oceanbase::sql::ObSql::handle_physical_plan (this=this@entry=xxxxx <oceanbase::observer::ObServer::get_instance()::THE_ONE+1113280>, trimed_stmt=..., context=..., result=..., pc_ctx=..., get_plan_err=<optimized out>, is_psmode=false)
oceanbase::sql::ObSql::handle_text_query (this=this@entry=xxxxx <oceanbase::observer::ObServer::get_instance()::THE_ONE+1113280>, stmt=..., context=..., result=...)
oceanbase::sql::ObSql::stmt_query (this=xxxxx <oceanbase::observer::ObServer::get_instance()::THE_ONE+1113280>, stmt=..., context=..., result=...)
oceanbase::observer::ObMPQuery::do_process (need_disconnect=@xxxxx: true, async_resp_used=@xxxxx: false, force_sync_resp=false, has_more_result=false, session=..., this=xxxxx)
oceanbase::observer::ObMPQuery::process_single_stmt (this=this@entry=xxxxx, multi_stmt_item=..., session=..., has_more_result=<optimized out>, force_sync_resp=<optimized out>, async_resp_used=@xxxxx: false, need_disconnect=@xxxxx: true)
oceanbase::observer::ObMPQuery::process (this=xxxxx)
oceanbase::rpc::frame::ObReqProcessor::run (this=xxxxx)
oceanbase::omt::ObWorkerProcessor::process_one (process_ret=<synthetic pointer>: <optimized out>, req=..., this=xxxxx <oceanbase::observer::ObServer::get_instance()::THE_ONE+10009920>)
oceanbase::omt::ObWorkerProcessor::process (this=<optimized out>, req=...)
oceanbase::omt::ObThWorker::process_request (req=..., this=xxxxx)
oceanbase::omt::ObThWorker::worker (this=xxxxx, tenant_id=@xxxxx: 1002, tenant_id@entry=@xxxxx: -1, req_recv_timestamp=@xxxxx: 1668758370493989, req_recv_timestamp@entry=@xxxxx: -1, worker_level=@xxxxx: 0,worker_level@entry=@xxxxx: -1)
oceanbase::omt::ObThWorker::run (this=<optimized out>, idx=<optimized out>)
oceanbase::lib::CoKThreadTemp<oceanbase::lib::CoUserThreadTemp<oceanbase::lib::CoSetSched> >::start()::{lambda()#1}::operator()() const (__closure=<optimized out>)
std::_Function_handler<void (), oceanbase::lib::CoKThreadTemp<oceanbase::lib::CoUserThreadTemp<oceanbase::lib::CoSetSched> >::start()::{lambda()#1}>::_M_invoke(std::_Any_data const&) (__functor=...)
std::function<void ()>::operator()() const (this=xxxxx)
oceanbase::lib::CoSetSched::Worker::run (this=0xxxxx)
oceanbase::lib::CoRoutine::__start (from=...)
解决方法
规避方法为:禁止 ALTER USER 语法中使用保留关键字
PUBLIC/CONNECT/RESOURCE。解决方法:升级至问题已修复版本,目前已修复的版本包括 OceanBase 数据库企业版本 V2.2.77 BP14 (oceanbase-2.2.77-114000072022120410) 、V3.1.2 BP11 (oceanbase-3.1.2-111000052023010412)、V3.2.3 BP7 (oceanbase-3.2.3.3-107000092023011911) 及后续版本。