[CP] Clear tablet autoinc seq cache when drop table

This commit is contained in:
Hongqin-Li
2024-03-05 03:19:34 +00:00
committed by ob-robot
parent d87ab32ed3
commit 5cb186e4a7
10 changed files with 253 additions and 6 deletions

View File

@ -104,6 +104,35 @@ private:
bool is_inited_;
};
class ObTabletAutoincMgrAllocHandle
{
public:
typedef LinkHashNode<ObTabletAutoincKey> TabletAutoincNode;
typedef ObTabletAutoincMgr TabletAutoincMgr;
static ObTabletAutoincMgr* alloc_value() { return op_reclaim_alloc(TabletAutoincMgr); }
static void free_value(ObTabletAutoincMgr* val) { op_reclaim_free(val); val = nullptr; }
static TabletAutoincNode* alloc_node(ObTabletAutoincMgr* val) { UNUSED(val); return op_reclaim_alloc(TabletAutoincNode); }
static void free_node(TabletAutoincNode* node) { op_reclaim_free(node); node = nullptr; }
};
class ObTabletAutoincCacheCleaner final
{
public:
static const int64_t DEFAULT_TIMEOUT_US = 1 * 1000 * 1000;
ObTabletAutoincCacheCleaner(const uint64_t tenant_id) : tenant_id_(tenant_id), tablet_ids_() {}
~ObTabletAutoincCacheCleaner() {}
int add_table(schema::ObSchemaGetterGuard &schema_guard, const schema::ObTableSchema &table_schema);
int add_database(const schema::ObDatabaseSchema &database_schema);
int commit(const int64_t timeout_us = DEFAULT_TIMEOUT_US);
TO_STRING_KV(K_(tenant_id), K_(tablet_ids));
private:
int add_single_table(const schema::ObSimpleTableSchemaV2 &table_schema);
private:
DISALLOW_COPY_AND_ASSIGN(ObTabletAutoincCacheCleaner);
uint64_t tenant_id_;
ObArray<ObTabletID> tablet_ids_;
};
class ObTabletAutoincrementService
{
public:
@ -113,7 +142,7 @@ public:
int get_tablet_cache_interval(const uint64_t tenant_id,
ObTabletCacheInterval &interval);
int get_autoinc_seq(const uint64_t tenant_id, const common::ObTabletID &tablet_id, uint64_t &autoinc_seq);
int clear_tablet_autoinc_cache(const uint64_t tenant_id, const common::ObTabletID &tablet_id);
int clear_tablet_autoinc_seq_cache(const uint64_t tenant_id, const common::ObIArray<common::ObTabletID> &tablet_ids, const int64_t abs_timeout_us);
private:
int acquire_mgr(const uint64_t tenant_id, const common::ObTabletID &tablet_id, const int64_t init_cache_size, ObTabletAutoincMgr *&autoinc_mgr);
void release_mgr(ObTabletAutoincMgr *autoinc_mgr);
@ -122,7 +151,7 @@ private:
~ObTabletAutoincrementService();
private:
typedef common::ObLinkHashMap<ObTabletAutoincKey, ObTabletAutoincMgr> TabletAutoincMgrMap;
typedef common::ObLinkHashMap<ObTabletAutoincKey, ObTabletAutoincMgr, ObTabletAutoincMgrAllocHandle> TabletAutoincMgrMap;
const static int INIT_NODE_MUTEX_NUM = 10243L;
bool is_inited_;
common::ObSmallAllocator node_allocator_;