[master] fix ls gc in primary when switchover
This commit is contained in:
@ -625,7 +625,12 @@ int ObLogRestoreProxyUtil::get_max_log_info(const ObLSID &id, palf::AccessMode &
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get result failed", K(sql));
|
||||
} else if (OB_FAIL(result->next())) {
|
||||
LOG_WARN("next failed");
|
||||
if (OB_ITER_END == ret) {
|
||||
ret = OB_ENTRY_NOT_EXIST;
|
||||
LOG_WARN("get max log info failed", K(sql), K(id));
|
||||
} else {
|
||||
LOG_WARN("next failed", K(sql), K(id));
|
||||
}
|
||||
} else {
|
||||
uint64_t max_scn = 0;
|
||||
ObString access_mode_str;
|
||||
@ -645,6 +650,44 @@ int ObLogRestoreProxyUtil::get_max_log_info(const ObLSID &id, palf::AccessMode &
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogRestoreProxyUtil::is_ls_existing(const ObLSID &id)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const char *LS_ID = "LS_ID";
|
||||
common::ObMySQLProxy *proxy = &sql_proxy_;
|
||||
if (OB_UNLIKELY(!inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
} else if (OB_UNLIKELY(!id.is_valid())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invlaid argument", K(id));
|
||||
} else {
|
||||
RESTORE_RETRY(
|
||||
SMART_VAR(common::ObMySQLProxy::MySQLResult, res) {
|
||||
common::sqlclient::ObMySQLResult *result = NULL;
|
||||
common::ObSqlString sql;
|
||||
const char *GET_LS_SQL = "SELECT COUNT(1) as COUNT FROM %s WHERE %s=%ld";
|
||||
if (OB_FAIL(sql.append_fmt(GET_LS_SQL, OB_DBA_OB_LS_TNAME, LS_ID, id.id()))) {
|
||||
LOG_WARN("append_fmt failed");
|
||||
} else if (OB_FAIL(proxy->read(res, sql.ptr()))) {
|
||||
LOG_WARN("excute sql failed", K(sql));
|
||||
} else if (OB_ISNULL(result = res.get_result())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get result failed", K(sql));
|
||||
} else if (OB_FAIL(result->next())) {
|
||||
LOG_WARN("next failed", K(id), K(sql));
|
||||
} else {
|
||||
uint64_t count = 0;
|
||||
EXTRACT_UINT_FIELD_MYSQL(*result, "COUNT", count, uint64_t);
|
||||
if (OB_SUCC(ret) && 0 == count) {
|
||||
ret = OB_LS_NOT_EXIST;
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ObLogRestoreProxyUtil::destroy_tg_()
|
||||
{
|
||||
if (-1 != tg_id_) {
|
||||
|
||||
Reference in New Issue
Block a user