...
 
Commits (3)
    https://gitcode.net/oceanbase/oceanbase/-/commit/f73768650c7814c36f7c3906aa47b8d6697184a6 [CP] bugfix: lnnvl raw expr printer 2023-09-08T13:42:15+08:00 obdev obdev@oceanbase.com https://gitcode.net/oceanbase/oceanbase/-/commit/2c0f55dbd91988f02adfe8bed6a8c95901137e2d [CP] Fix aggregation result error in subquery with union 2023-09-08T13:42:47+08:00 obdev obdev@oceanbase.com https://gitcode.net/oceanbase/oceanbase/-/commit/a8d6bd86c1892f502aa4a3d9f4825070232ca9f6 [CP] fix bad MEMORY_LOG when ServerGTimer hang 2023-09-08T13:43:19+08:00 obdev obdev@oceanbase.com
......@@ -480,7 +480,8 @@ void ObMallocAllocator::print_tenant_memory_usage(uint64_t tenant_id) const
if (OB_SUCC(ret)) {
ObPageManagerCenter::get_instance().print_tenant_stat(tenant_id, buf, BUFLEN, ctx_pos);
}
buf[std::min(ctx_pos, BUFLEN - 1)] = '\0';
allow_next_syslog();
_LOG_INFO("[MEMORY] tenant: %lu, limit: %'lu hold: %'lu rpc_hold: %'lu cache_hold: %'lu "
"cache_used: %'lu cache_item_count: %'lu \n%s",
tenant_id,
......
......@@ -22,7 +22,6 @@
using namespace oceanbase::lib;
using namespace oceanbase::common;
int ObTenantCtxAllocator::iter_label(VisitFunc func) const
{
int ret = OB_SUCCESS;
......@@ -139,7 +138,7 @@ void ObTenantCtxAllocator::print_usage() const
return OB_SUCCESS;
});
}
allow_next_syslog();
_LOG_INFO("\n[MEMORY] tenant_id=%5ld ctx_id=%25s hold=% '15ld used=% '15ld\n%s",
tenant_id_,
get_global_ctx_info().get_ctx_name(ctx_id_),
......
......@@ -39,6 +39,11 @@ using namespace oceanbase::lib;
namespace oceanbase {
namespace common {
__thread char ObLogger::local_buf_[];
void __attribute__((weak)) allow_next_syslog(int64_t)
{
// do nothing
}
extern void update_easy_log_level();
lib::ObRateLimiter* ObLogger::default_log_limiter_ = nullptr;
RLOCAL(lib::ObRateLimiter*, ObLogger::tl_log_limiter_);
......
......@@ -56,6 +56,7 @@ class ObFIFOAllocator;
class ObPLogItem;
class ObString;
class ObLogCompressor;
extern void allow_next_syslog(int64_t count = 1);
#define OB_LOGGER ::oceanbase::common::ObLogger::get_logger()
#define OB_LOG_NEED_TO_PRINT(level) (OB_UNLIKELY(OB_LOGGER.need_to_print(OB_LOG_LEVEL_##level)))
......
......@@ -402,6 +402,8 @@ void ObServer::destroy()
ObBGThreadMonitor::get_instance().destroy();
TG_DESTROY(lib::TGDefIDs::ServerGTimer);
LOG_WARN("timer destroyed");
TG_DESTROY(lib::TGDefIDs::MemDumpTimer);
LOG_WARN("memory dump timer destroyed");
TG_DESTROY(lib::TGDefIDs::FreezeTimer);
LOG_WARN("freeze timer destroyed");
TG_DESTROY(lib::TGDefIDs::SqlMemTimer);
......@@ -646,6 +648,8 @@ int ObServer::stop()
LOG_INFO("begin stop timer");
TG_STOP(lib::TGDefIDs::ServerGTimer);
LOG_WARN("timer stopped");
TG_STOP(lib::TGDefIDs::MemDumpTimer);
LOG_WARN("memory dump timer stopped");
TG_STOP(lib::TGDefIDs::FreezeTimer);
LOG_WARN("freeze timer stopped");
TG_STOP(lib::TGDefIDs::SqlMemTimer);
......@@ -756,6 +760,7 @@ int ObServer::wait()
// timer
TG_WAIT(lib::TGDefIDs::ServerGTimer);
TG_WAIT(lib::TGDefIDs::MemDumpTimer);
TG_WAIT(lib::TGDefIDs::FreezeTimer);
TG_WAIT(lib::TGDefIDs::SqlMemTimer);
TG_WAIT(lib::TGDefIDs::ServerTracerTimer);
......@@ -931,6 +936,8 @@ int ObServer::init_config()
LOG_ERROR("local address isn't valid", K(self_addr_), K(ret));
} else if (OB_FAIL(TG_START(lib::TGDefIDs::ServerGTimer))) {
LOG_ERROR("init timer fail", K(ret));
} else if (OB_FAIL(TG_START(lib::TGDefIDs::MemDumpTimer))) {
LOG_ERROR("init memory dump timer fail", KR(ret));
} else if (OB_FAIL(TG_START(lib::TGDefIDs::FreezeTimer))) {
LOG_ERROR("init freeze timer fail", K(ret));
} else if (OB_FAIL(TG_START(lib::TGDefIDs::SqlMemTimer))) {
......@@ -1295,7 +1302,7 @@ int ObServer::init_multi_tenant()
LOG_ERROR("Fail to add server tenant to tenant manager, ", K(ret));
} else if (OB_FAIL(omti.set_tenant_mem_limit(OB_SERVER_TENANT_ID, 0, INT64_MAX))) {
LOG_ERROR("Fail to set tenant mem limit, ", K(ret));
} else if (OB_FAIL(omti.register_timer_task(lib::TGDefIDs::ServerGTimer))) {
} else if (OB_FAIL(omti.register_timer_task(lib::TGDefIDs::MemDumpTimer))) {
LOG_ERROR("Fail to register timer task", K(ret));
}
}
......
......@@ -19,6 +19,13 @@ using namespace oceanbase::lib;
using namespace oceanbase::common;
namespace oceanbase {
namespace common {
void allow_next_syslog(int64_t count)
{
share::ObTaskController::get().allow_next_syslog(count);
}
} // common
namespace share {
class ObLogRateLimiter : public lib::ObSimpleRateLimiter {
......
......@@ -144,4 +144,5 @@ TG_DEF(DDLRetryGhostIndex, DDLRetryGhostIndex, "", TG_STATIC, TIMER)
TG_DEF(StoreFileAutoExtend, StoreFileAutoExtend, "", TG_STATIC, TIMER)
TG_DEF(TTLScheduler, TTLScheduler, "", TG_STATIC, TIMER)
TG_DEF(CTASCleanUpTimer, CTASCleanUpTimer, "", TG_STATIC, TIMER)
TG_DEF(MemDumpTimer, MemDumpTimer, "", TG_STATIC, TIMER)
#endif
......@@ -248,23 +248,27 @@ ObSelectResolver* ObAggrExprPushUpAnalyzer::fetch_final_aggr_resolver(
* For oracle mode, if it is in having scope, it will pull subquery up to compute
* if it is in order scope (and subquery does not appear in where scope), it will pull subquery up to compute
*/
if (final_aggr_level >= 0 && cur_resolver->get_current_level() > final_aggr_level &&
NULL != cur_resolver->get_parent_namespace_resolver() &&
(share::is_mysql_mode() ||
T_HAVING_SCOPE == cur_resolver->get_parent_namespace_resolver()->get_current_scope() ||
(T_ORDER_SCOPE == cur_resolver->get_parent_namespace_resolver()->get_current_scope() &&
T_WHERE_SCOPE != cur_resolver->get_current_scope()))) {
if (cur_resolver->is_select_resolver() && static_cast<ObSelectResolver*>(cur_resolver)->is_in_set_query()) {
// The current resolver is located in the set query identified by keywords such as union,
// and the aggr function is no longer laid on the query for the upper layer of the union
// For example:
// SELECT (SELECT MAX(t1.b) from t2 union select 1 from t2 where 12 <3) FROM t1 GROUP BY t1.a;
// MAX(t1.b) refers to the attributes of the first layer, but the entire
// expression of MAX(t1.b) remains in the left branch of the union
} else {
ObDMLResolver* next_resolver = cur_resolver->get_parent_namespace_resolver();
final_resolver = fetch_final_aggr_resolver(next_resolver, final_aggr_level);
}
if (final_aggr_level >= 0 && cur_resolver->get_current_level() > final_aggr_level
&& NULL != cur_resolver->get_parent_namespace_resolver()
&& (share::is_mysql_mode()
|| T_HAVING_SCOPE == cur_resolver->get_parent_namespace_resolver()->get_current_scope())) {
/*
* For mysql, aggr func belongs to the upper level, whether there is a "union" or not.
*
* For oracle, aggr func not in "HAVING" belongs to the subquery, does not need to
* push up.
*
* SELECT (SELECT COUNT(t1.a) FROM dual) FROM t1 GROUP BY t1.a;
* *
* SELECT (SELECT COUNT(t1.a) union select 1 where 1>2) FROM t1 GROUP BY t1.a;
* *
* SELECT 1 FROM t1 HAVING 1 in (SELECT MAX(t1.n1) FROM dual);
* *
* Here, for oracle mode, COUNT belongs to the subquery, but MAX belongs to the
* upper query.
*/
ObDMLResolver *next_resolver = cur_resolver->get_parent_namespace_resolver();
final_resolver = fetch_final_aggr_resolver(next_resolver, final_aggr_level);
}
if (NULL == final_resolver && cur_resolver->is_select_resolver()) {
ObSelectResolver* select_resolver = static_cast<ObSelectResolver*>(cur_resolver);
......
......@@ -1250,7 +1250,11 @@ int ObRawExprPrinter::print(ObSysFunRawExpr* expr)
break;
}
case T_FUN_SYS_LNNVL: {
DATA_PRINTF("(%.*s", LEN_AND_PTR(func_name));
if (lib::is_oracle_mode()) {
DATA_PRINTF("(%.*s", LEN_AND_PTR(func_name));
} else {
DATA_PRINTF("%.*s(", LEN_AND_PTR(func_name));
}
if (1 != expr->get_param_count()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("param count should be equal 1", K(ret), K(expr->get_param_count()));
......
......@@ -35,3 +35,28 @@ select lnnvl('abc') from dual;
| 1 |
+--------------+
drop view if exists v1;
create view v1 as select lnnvl(1) from dual;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE VIEW `v1` AS select lnnvl(1) AS `lnnvl(1)` utf8mb4 utf8mb4_general_ci
explain select * from v1;
Query Plan
===================================
|ID|OPERATOR |NAME|EST. ROWS|COST|
-----------------------------------
|0 |EXPRESSION| |1 |1 |
===================================
Outputs & filters:
-------------------------------------
0 - output([?]), filter(nil)
values({?})
select * from v1;
+----------+
| lnnvl(1) |
+----------+
| 0 |
+----------+
drop view v1;
......@@ -19,5 +19,14 @@ select lnnvl(0) from dual;
select lnnvl(NULL) from dual;
select lnnvl('abc') from dual;
--disable_warnings
drop view if exists v1;
--enable_warnings
create view v1 as select lnnvl(1) from dual;
show create view v1;
explain select * from v1;
select * from v1;
drop view v1;
connection syscon;
--sleep 2