BUGFIX: depart the ls meta lock
This commit is contained in:
@ -1263,7 +1263,7 @@ int ObLS::get_replica_status(ObReplicaStatus &replica_status)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObMigrationStatus migration_status;
|
||||
ObLSMeta::ObReentrantRLockGuard guard(ls_meta_.lock_);
|
||||
RDLockGuard guard(meta_rwlock_);
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("ls is not inited", K(ret));
|
||||
@ -1402,6 +1402,60 @@ int ObLS::ObLSInnerTabletIDIter::get_next(common::ObTabletID &tablet_id)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ObLS::RDLockGuard::RDLockGuard(RWLock &lock, const int64_t abs_timeout_us)
|
||||
: lock_(lock), ret_(OB_SUCCESS), start_ts_(0)
|
||||
{
|
||||
ObTimeGuard tg("ObLS::rwlock", LOCK_CONFLICT_WARN_TIME);
|
||||
if (OB_UNLIKELY(OB_SUCCESS != (ret_ = lock_.rdlock(ObLatchIds::LS_LOCK,
|
||||
abs_timeout_us)))) {
|
||||
STORAGE_LOG_RET(WARN, ret_, "Fail to read lock, ", K_(ret));
|
||||
} else {
|
||||
start_ts_ = ObTimeUtility::current_time();
|
||||
}
|
||||
}
|
||||
|
||||
ObLS::RDLockGuard::~RDLockGuard()
|
||||
{
|
||||
if (OB_LIKELY(OB_SUCCESS == ret_)) {
|
||||
if (OB_UNLIKELY(OB_SUCCESS != (ret_ = lock_.unlock()))) {
|
||||
STORAGE_LOG_RET(WARN, ret_, "Fail to unlock, ", K_(ret));
|
||||
}
|
||||
}
|
||||
const int64_t end_ts = ObTimeUtility::current_time();
|
||||
if (end_ts - start_ts_ > 5 * 1000 * 1000) {
|
||||
STORAGE_LOG_RET(WARN, OB_ERR_TOO_MUCH_TIME, "ls lock cost too much time", K_(start_ts),
|
||||
"cost_us", end_ts - start_ts_, K(lbt()));
|
||||
}
|
||||
start_ts_ = INT64_MAX;
|
||||
}
|
||||
|
||||
ObLS::WRLockGuard::WRLockGuard(RWLock &lock, const int64_t abs_timeout_us)
|
||||
: lock_(lock), ret_(OB_SUCCESS), start_ts_(0)
|
||||
{
|
||||
ObTimeGuard tg("ObLS::rwlock", LOCK_CONFLICT_WARN_TIME);
|
||||
if (OB_UNLIKELY(OB_SUCCESS != (ret_ = lock_.wrlock(ObLatchIds::LS_LOCK,
|
||||
abs_timeout_us)))) {
|
||||
STORAGE_LOG_RET(WARN, ret_, "Fail to read lock, ", K_(ret));
|
||||
} else {
|
||||
start_ts_ = ObTimeUtility::current_time();
|
||||
}
|
||||
}
|
||||
|
||||
ObLS::WRLockGuard::~WRLockGuard()
|
||||
{
|
||||
if (OB_LIKELY(OB_SUCCESS == ret_)) {
|
||||
if (OB_UNLIKELY(OB_SUCCESS != (ret_ = lock_.unlock()))) {
|
||||
STORAGE_LOG_RET(WARN, ret_, "Fail to unlock, ", K_(ret));
|
||||
}
|
||||
}
|
||||
const int64_t end_ts = ObTimeUtility::current_time();
|
||||
if (end_ts - start_ts_ > 5 * 1000 * 1000) {
|
||||
STORAGE_LOG_RET(WARN, OB_ERR_TOO_MUCH_TIME, "ls lock cost too much time", K_(start_ts),
|
||||
"cost_us", end_ts - start_ts_, K(lbt()));
|
||||
}
|
||||
start_ts_ = INT64_MAX;
|
||||
}
|
||||
|
||||
int ObLS::block_tx_start()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -1470,7 +1524,7 @@ int ObLS::update_tablet_table_store(
|
||||
ObTabletHandle &handle)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObLSMeta::ObReentrantRLockGuard guard(ls_meta_.lock_);
|
||||
RDLockGuard guard(meta_rwlock_);
|
||||
|
||||
return update_tablet_table_store_without_lock_(tablet_id, param, handle);
|
||||
}
|
||||
@ -1507,7 +1561,7 @@ int ObLS::update_tablet_table_store(
|
||||
const ObIArray<storage::ObITable *> &tables)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObLSMeta::ObReentrantRLockGuard guard(ls_meta_.lock_);
|
||||
RDLockGuard guard(meta_rwlock_);
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("ls hasn't been inited", K(ret));
|
||||
@ -1533,7 +1587,7 @@ int ObLS::build_ha_tablet_new_table_store(
|
||||
const ObBatchUpdateTableStoreParam ¶m)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObLSMeta::ObReentrantRLockGuard guard(ls_meta_.lock_);
|
||||
RDLockGuard guard(meta_rwlock_);
|
||||
const share::ObLSID &ls_id = ls_meta_.ls_id_;
|
||||
const int64_t rebuild_seq = ls_meta_.get_rebuild_seq();
|
||||
if (IS_NOT_INIT) {
|
||||
@ -1559,7 +1613,7 @@ int ObLS::build_new_tablet_from_mds_table(
|
||||
const share::SCN &flush_scn)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObLSMeta::ObReentrantRLockGuard guard(ls_meta_.lock_);
|
||||
RDLockGuard guard(meta_rwlock_);
|
||||
const share::ObLSID &ls_id = ls_meta_.ls_id_;
|
||||
const int64_t rebuild_seq = ls_meta_.get_rebuild_seq();
|
||||
if (IS_NOT_INIT) {
|
||||
@ -1880,7 +1934,7 @@ int ObLS::get_ls_meta_package_and_tablet_ids(const bool check_archive,
|
||||
int ret = OB_SUCCESS;
|
||||
const bool need_initial_state = false;
|
||||
ObHALSTabletIDIterator iter(ls_meta_.ls_id_, need_initial_state);
|
||||
ObLSMeta::ObReentrantRLockGuard guard(ls_meta_.lock_);
|
||||
RDLockGuard guard(meta_rwlock_);
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("ls is not inited", K(ret));
|
||||
@ -1948,7 +2002,7 @@ int ObLS::get_transfer_scn(share::SCN &scn)
|
||||
int ret = OB_SUCCESS;
|
||||
share::SCN max_tablet_scn;
|
||||
max_tablet_scn.set_min();
|
||||
ObLSMeta::ObReentrantRLockGuard guard(ls_meta_.lock_);
|
||||
RDLockGuard guard(meta_rwlock_);
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("ls is not inited", K(ret));
|
||||
@ -2127,7 +2181,7 @@ int ObLS::try_update_upper_trans_version_and_gc_sstable(
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
ObLSMeta::ObReentrantRLockGuard guard(ls_meta_.lock_);
|
||||
RDLockGuard guard(meta_rwlock_);
|
||||
bool update_upper_trans_version = true;
|
||||
const share::ObLSID &ls_id = get_ls_id();
|
||||
ObMigrationStatus migration_status;
|
||||
@ -2270,7 +2324,7 @@ int ObLS::diagnose(DiagnoseInfo &info) const
|
||||
int ObLS::inc_update_transfer_scn(const share::SCN &transfer_scn)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObLSMeta::ObReentrantWLockGuard guard(ls_meta_.lock_);
|
||||
WRLockGuard guard(meta_rwlock_);
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(ls_meta_.inc_update_transfer_scn(transfer_scn))) {
|
||||
LOG_WARN("fail to set transfer scn", K(ret), K(transfer_scn), K_(ls_meta));
|
||||
@ -2287,7 +2341,7 @@ int ObLS::set_migration_status(
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
share::ObLSRestoreStatus restore_status;
|
||||
ObLSMeta::ObReentrantWLockGuard guard(ls_meta_.lock_);
|
||||
WRLockGuard guard(meta_rwlock_);
|
||||
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
@ -2323,7 +2377,7 @@ int ObLS::set_restore_status(
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObMigrationStatus migration_status = ObMigrationStatus::OB_MIGRATION_STATUS_MAX;
|
||||
ObLSMeta::ObReentrantWLockGuard guard(ls_meta_.lock_);
|
||||
WRLockGuard guard(meta_rwlock_);
|
||||
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
@ -2374,7 +2428,7 @@ int ObLS::set_gc_state(const logservice::LSGCState &gc_state, const share::SCN &
|
||||
int ObLS::set_ls_rebuild()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObLSMeta::ObReentrantWLockGuard guard(ls_meta_.lock_);
|
||||
WRLockGuard guard(meta_rwlock_);
|
||||
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
|
||||
@ -174,6 +174,7 @@ class ObIComponentFactory;
|
||||
class ObLS : public common::ObLink
|
||||
{
|
||||
public:
|
||||
typedef common::ObLatch RWLock;
|
||||
friend ObLSLockGuard;
|
||||
friend class ObFreezer;
|
||||
friend class checkpoint::ObDataCheckpoint;
|
||||
@ -195,6 +196,34 @@ public:
|
||||
private:
|
||||
int64_t pos_;
|
||||
};
|
||||
class RDLockGuard
|
||||
{
|
||||
static const int64_t LOCK_CONFLICT_WARN_TIME = 100 * 1000; // 100 ms
|
||||
public:
|
||||
[[nodiscard]] explicit RDLockGuard(RWLock &lock, const int64_t abs_timeout_us = INT64_MAX);
|
||||
~RDLockGuard();
|
||||
inline int get_ret() const { return ret_; }
|
||||
private:
|
||||
RWLock &lock_;
|
||||
int ret_;
|
||||
int64_t start_ts_;
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(RDLockGuard);
|
||||
};
|
||||
class WRLockGuard
|
||||
{
|
||||
static const int64_t LOCK_CONFLICT_WARN_TIME = 100 * 1000; // 100 ms
|
||||
public:
|
||||
[[nodiscard]] explicit WRLockGuard(RWLock &lock, const int64_t abs_timeout_us = INT64_MAX);
|
||||
~WRLockGuard();
|
||||
inline int get_ret() const { return ret_; }
|
||||
private:
|
||||
RWLock &lock_;
|
||||
int ret_;
|
||||
int64_t start_ts_;
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(WRLockGuard);
|
||||
};
|
||||
public:
|
||||
ObLS();
|
||||
virtual ~ObLS();
|
||||
@ -938,7 +967,8 @@ private:
|
||||
ObTransferHandler transfer_handler_;
|
||||
// Record the dependent transfer information when restarting
|
||||
ObLSTransferInfo startup_transfer_info_;
|
||||
|
||||
// this is used for the meta lock, and will be removed later
|
||||
RWLock meta_rwlock_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -24,3 +24,4 @@ select /* QUERY_TIMEOUT(15000000) */ id from notify_000 where gmt_create <= cur
|
||||
select /* QUERY_TIMEOUT(15000000) */ id, business_order, business_type from notify_000 where gmt_create <= current_timestamp() AND gmt_create >= date_sub(current_timestamp(), INTERVAL 6 MINUTE) AND ((status = 'N') AND (gmt_modify < current_timestamp())) limit 1;
|
||||
select id, plugin, plugin_host, parameter, group_no, status, gmt_create, gmt_local_create, gmt_modify, iw_user_id, channel_endpoint, business_order, business_type from notify_000 where (iw_user_id ='1111') and (gmt_create < current_timestamp()) and (gmt_create >= current_timestamp());
|
||||
delete from notify_history_000 where ((group_no = (- 1)) AND (iw_user_id = '1111'));
|
||||
|
||||
|
||||
@ -33,3 +33,6 @@ select c5+1 c51,c6 c61,c7+1 c71 from t1 where c1=1 and c2='s' and c3=1.5;
|
||||
select c5+1 c51,c6 c61,c7+1 c71 from t1 where c1=1 and c2='s' and c3=1.5 and c5 in (1,2,3);
|
||||
|
||||
drop table t1;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -42,3 +42,6 @@ select c1, c1+c2 as total from t1 group by total having c1>2 order by c1 desc;
|
||||
select c1 as a1, c2 as a2 from t1 where c1>1;
|
||||
select c1 as a1, c2 as a2 from t1 where c2>1;
|
||||
select c1,c1+c2 as a1 from t1 where c1+c2>2;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -31,3 +31,4 @@ delete from t1 WHERE ( a = 1 ) OR (( b = 3 ) AND ( a = 2 )) order by a desc limi
|
||||
select * from t1;
|
||||
delete from t1 WHERE ( a = 1 ) OR (( b = 3 ) AND ( a = 2 )) order by a desc;
|
||||
select * from t1;
|
||||
|
||||
|
||||
@ -19,3 +19,5 @@ commit;
|
||||
set autocommit=1;
|
||||
select * from t1;
|
||||
disconnect conn1;
|
||||
|
||||
|
||||
|
||||
@ -37,3 +37,5 @@ select c1 as c1, c2 as c1 from tt1 where c1<4;
|
||||
#show columns from t1 like 'c1';
|
||||
show columns from tt1;
|
||||
#show columns from t1 like '%c%';
|
||||
|
||||
|
||||
|
||||
@ -93,3 +93,5 @@ select c2 from t5 except all select c2 from t6;
|
||||
|
||||
|
||||
drop table t1,t2,t3,t4,t5,t6;
|
||||
|
||||
|
||||
|
||||
@ -29,3 +29,5 @@ create unique index idx_5 on tbl1(d4);
|
||||
create unique index idx_7 on tbl1(i1,v2,i3,d4,i6);
|
||||
#--source mysql_test/include/check_idx_error.inc
|
||||
drop table tbl1;
|
||||
|
||||
|
||||
|
||||
@ -85,3 +85,5 @@ select pk1 from t1 where key2=NULL and key3<=NULL;
|
||||
##
|
||||
select * from t1 where key2=NULL and key3>=NULL;
|
||||
select pk1 from t1 where key2=NULL and key3>=NULL;
|
||||
|
||||
|
||||
|
||||
@ -28,3 +28,5 @@ select /*+index(t1 i1) */ * from t1 b where b.c2 > 0 and b.c2 < 5;
|
||||
select /*+index(b i1) */ * from t1 b where b.c2 > 0 and b.c2 < 5;
|
||||
|
||||
drop table t1;
|
||||
|
||||
|
||||
|
||||
@ -102,3 +102,5 @@ insert into t8 values('cdxLVdvvJjcoHFBECqXKkRGoMXYgNsTpJRrqYaluQdfEeB00000',0,'R
|
||||
explain ((select c6 from t8 where c6 < 1000) except (select c6 from t8 where c6 > -1000) order by c6 limit 1000) union all (select t8_alias1.c10 from t8 t8_alias1 limit 1);
|
||||
|
||||
drop table t1,t2,t3,t4,t5,t6, t8;
|
||||
|
||||
|
||||
|
||||
@ -66,3 +66,4 @@ select * from t2;
|
||||
select * from t1, t2 where t1.c1>=t2.c1;
|
||||
|
||||
drop table orders,persons, t1, t2, t3;
|
||||
|
||||
|
||||
@ -72,3 +72,5 @@ select t1.pk,t2.c2 from t1 RIGHT join t2 on t1.pk=t2.pk and t2.pk=1;
|
||||
|
||||
--sorted_result
|
||||
select t1.pk,t2.c2 from t1 FULL join t2 on t1.pk=t2.pk and t2.pk=1;
|
||||
|
||||
|
||||
|
||||
@ -34,3 +34,4 @@ SELECT * FROM (SELECT * FROM tjuo1) tjuo1_alias RIGHT JOIN tjuo2 USING (c1) RI
|
||||
SELECT * FROM (SELECT c2 FROM tjuo1 as i1 JOIN (SELECT * FROM tjuo2) as i2 USING (c1) ) as t12 RIGHT JOIN (SELECT * FROM tjuo3) as tjuo3_alias USING (c2);
|
||||
SELECT * FROM (SELECT c2 FROM tjuo1 as i1 JOIN (SELECT * FROM tjuo2) as i2 USING (c1) ) as t12;
|
||||
drop table tjuo1, tjuo2, tjuo3;
|
||||
|
||||
|
||||
@ -38,3 +38,4 @@ select * FROM t1 ORDER BY a desc LIMIT 8;
|
||||
select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
|
||||
select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
|
||||
drop table t1;
|
||||
|
||||
|
||||
@ -17,3 +17,5 @@ insert into t1 values(1,1);
|
||||
rollback;
|
||||
insert into t1 values(1,1);
|
||||
rollback;
|
||||
|
||||
|
||||
|
||||
@ -27,3 +27,4 @@ select use_bloom_filter() from dual;
|
||||
select use_bloom() from dual;
|
||||
|
||||
drop table t_status;
|
||||
|
||||
|
||||
@ -41,3 +41,7 @@ commit;
|
||||
|
||||
|
||||
select * from t1;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -142,3 +142,4 @@ commit;
|
||||
|
||||
select * from tbl1 where pk in (100,200);
|
||||
delete from tbl1 where pk in (100,200);
|
||||
|
||||
|
||||
@ -103,3 +103,7 @@ if($user2_c_2 == $user2_ct)
|
||||
}
|
||||
|
||||
drop table t1;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -20,3 +20,4 @@ delete from t1 where pk<4;
|
||||
sleep 12;
|
||||
--error 6002
|
||||
commit;
|
||||
|
||||
|
||||
@ -54,3 +54,4 @@ select * from test;
|
||||
set @@global.ob_enable_plan_cache= 1;
|
||||
drop table test;
|
||||
drop database db1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user