Skip to content

Commit

Permalink
fix autoinc not refresh location cache for some error code
Browse files Browse the repository at this point in the history
  • Loading branch information
Hongqin-Li authored and ob-robot committed Oct 19, 2023
1 parent 82bdfc1 commit f257fc0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions src/share/ob_tablet_autoincrement_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,16 @@ int ObTabletAutoincMgr::fetch_new_range(const ObTabletAutoincParam &param,
} else {
finish = true;
}
if (OB_FAIL(ret) && is_retryable(ret)) {
const bool need_refresh_leader = OB_NOT_MASTER == ret || OB_LS_NOT_EXIST == ret || OB_TABLET_NOT_EXIST == ret;
ob_usleep<common::ObWaitEventIds::STORAGE_AUTOINC_FETCH_RETRY_SLEEP>(RETRY_INTERVAL);
res.reset();
if (OB_FAIL(THIS_WORKER.check_status())) { // overwrite ret
LOG_WARN("failed to check status", K(ret));
} else if (need_refresh_leader) {
if (OB_FAIL(ret)) {
const bool force_refresh_leader = OB_NOT_MASTER == ret || OB_LS_NOT_EXIST == ret || OB_TABLET_NOT_EXIST == ret || OB_TENANT_NOT_IN_SERVER == ret;
if (is_retryable(ret)) {
ob_usleep<common::ObWaitEventIds::STORAGE_AUTOINC_FETCH_RETRY_SLEEP>(RETRY_INTERVAL);
res.reset();
if (OB_FAIL(THIS_WORKER.check_status())) { // overwrite ret
LOG_WARN("failed to check status", K(ret));
}
}
if (OB_SUCC(ret) && force_refresh_leader) {
if (OB_FAIL(location_service->get(param.tenant_id_, tablet_id, INT64_MAX/*expire_renew_time*/, is_cache_hit, arg.ls_id_))) {
LOG_WARN("fail to get log stream id", K(ret), K(ret), K(tablet_id));
} else if (OB_FAIL(location_service->get_leader(GCONF.cluster_id,
Expand All @@ -175,6 +178,8 @@ int ObTabletAutoincMgr::fetch_new_range(const ObTabletAutoincParam &param,
leader_addr))) {
LOG_WARN("force get leader failed", K(ret), K(ret), K(arg.ls_id_));
}
} else {
(void)location_service->renew_tablet_location(param.tenant_id_, tablet_id, ret, true/*is_nonblock*/);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/share/ob_tablet_autoincrement_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ObTabletAutoincMgr: public common::LinkHashValue<ObTabletAutoincKey>
}
bool is_retryable(int ret)
{
return OB_NOT_MASTER == ret || OB_NOT_INIT == ret || OB_TIMEOUT == ret || OB_EAGAIN == ret || OB_LS_NOT_EXIST == ret || OB_TABLET_NOT_EXIST == ret;
return OB_NOT_MASTER == ret || OB_NOT_INIT == ret || OB_TIMEOUT == ret || OB_EAGAIN == ret || OB_LS_NOT_EXIST == ret || OB_TABLET_NOT_EXIST == ret || OB_TENANT_NOT_IN_SERVER == ret;
}
private:
static const int64_t PREFETCH_THRESHOLD = 4;
Expand Down

0 comments on commit f257fc0

Please sign in to comment.