Fix circular wait between row lock and tenant rpc thread

This commit is contained in:
Hongqin-Li
2023-11-07 06:43:08 +00:00
committed by ob-robot
parent 344036289f
commit 5af5746e1b
4 changed files with 18 additions and 7 deletions

View File

@ -483,12 +483,20 @@ int ObGlobalStatProxy::get(
return ret;
}
int ObGlobalStatProxy::select_snapshot_gc_scn_for_update_nowait(
common::ObISQLClient &sql_client,
const uint64_t tenant_id,
SCN &snapshot_gc_scn)
{
return inner_get_snapshot_gc_scn_(sql_client, tenant_id, snapshot_gc_scn, "FOR UPDATE NOWAIT");
}
int ObGlobalStatProxy::select_snapshot_gc_scn_for_update(
common::ObISQLClient &sql_client,
const uint64_t tenant_id,
SCN &snapshot_gc_scn)
{
return inner_get_snapshot_gc_scn_(sql_client, tenant_id, snapshot_gc_scn, true);
return inner_get_snapshot_gc_scn_(sql_client, tenant_id, snapshot_gc_scn, "FOR UPDATE");
}
int ObGlobalStatProxy::get_snapshot_gc_scn(
@ -496,14 +504,14 @@ int ObGlobalStatProxy::get_snapshot_gc_scn(
const uint64_t tenant_id,
SCN &snapshot_gc_scn)
{
return inner_get_snapshot_gc_scn_(sql_client, tenant_id, snapshot_gc_scn, false);
return inner_get_snapshot_gc_scn_(sql_client, tenant_id, snapshot_gc_scn, "");
}
int ObGlobalStatProxy::inner_get_snapshot_gc_scn_(
common::ObISQLClient &sql_client,
const uint64_t tenant_id,
SCN &snapshot_gc_scn,
const bool is_for_update)
const char *for_update_str)
{
int ret = OB_SUCCESS;
uint64_t snapshot_gc_scn_val = 0;
@ -512,7 +520,7 @@ int ObGlobalStatProxy::inner_get_snapshot_gc_scn_(
ObSqlString sql;
if (OB_FAIL(sql.assign_fmt(
"SELECT column_value FROM %s WHERE TABLE_NAME = '__all_global_stat' AND COLUMN_NAME"
" = 'snapshot_gc_scn' %s", OB_ALL_CORE_TABLE_TNAME, (is_for_update ? "FOR UPDATE" : "")))) {
" = 'snapshot_gc_scn' %s", OB_ALL_CORE_TABLE_TNAME, for_update_str))) {
LOG_WARN("assign sql failed", K(ret));
} else if (OB_FAIL(sql_client.read(res, tenant_id, sql.ptr()))) {
LOG_WARN("execute sql failed", K(ret), K(sql));