[CP] [Bugfix] on update current_timestamp bug & TbSessNodeVal memory leak
This commit is contained in:
		@ -226,7 +226,7 @@ int ObTableExprCgService::generate_current_timestamp_expr(ObTableCtx &ctx,
 | 
				
			|||||||
  int ret = OB_SUCCESS;
 | 
					  int ret = OB_SUCCESS;
 | 
				
			||||||
  ObSysFunRawExpr *tmp_expr = NULL;
 | 
					  ObSysFunRawExpr *tmp_expr = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!IS_DEFAULT_NOW_OBJ(item.default_value_)) {
 | 
					  if ((!IS_DEFAULT_NOW_OBJ(item.default_value_)) && (!item.auto_filled_timestamp_)) {
 | 
				
			||||||
    ret = OB_INVALID_ARGUMENT;
 | 
					    ret = OB_INVALID_ARGUMENT;
 | 
				
			||||||
    LOG_WARN("invalid column item", K(ret), K(item));
 | 
					    LOG_WARN("invalid column item", K(ret), K(item));
 | 
				
			||||||
  } else if (OB_ISNULL(item.expr_)) {
 | 
					  } else if (OB_ISNULL(item.expr_)) {
 | 
				
			||||||
@ -440,7 +440,7 @@ int ObTableExprCgService::generate_assign_expr(ObTableCtx &ctx, ObTableAssignmen
 | 
				
			|||||||
    if (OB_FAIL(generate_autoinc_nextval_expr(ctx, *item, tmp_expr))) {
 | 
					    if (OB_FAIL(generate_autoinc_nextval_expr(ctx, *item, tmp_expr))) {
 | 
				
			||||||
      LOG_WARN("fail to generate autoinc nextval expr", K(ret));
 | 
					      LOG_WARN("fail to generate autoinc nextval expr", K(ret));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  } else if (IS_DEFAULT_NOW_OBJ(item->default_value_)) { // defualt current time
 | 
					  } else if (IS_DEFAULT_NOW_OBJ(item->default_value_) || item->auto_filled_timestamp_) { // defualt current time or on update current_timestamp
 | 
				
			||||||
    if (OB_FAIL(generate_current_timestamp_expr(ctx, *item, tmp_expr))) {
 | 
					    if (OB_FAIL(generate_current_timestamp_expr(ctx, *item, tmp_expr))) {
 | 
				
			||||||
      LOG_WARN("fail to generate autoinc nextval expr", K(ret));
 | 
					      LOG_WARN("fail to generate autoinc nextval expr", K(ret));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -570,8 +570,7 @@ int ObTableApiSessPool::replace_sess_node_safe(ObTableApiCredential &credential)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void ObTableApiSessNodeVal::destroy()
 | 
					void ObTableApiSessNodeVal::destroy()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  sess_info_.destroy();
 | 
					  sess_info_.~ObSQLSessionInfo();
 | 
				
			||||||
  allocator_.reset();
 | 
					 | 
				
			||||||
  is_inited_ = false;
 | 
					  is_inited_ = false;
 | 
				
			||||||
  owner_node_ = nullptr;
 | 
					  owner_node_ = nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -592,7 +591,6 @@ int ObTableApiSessNodeVal::init_sess_info()
 | 
				
			|||||||
      LOG_WARN("tenant schema is null", K(ret));
 | 
					      LOG_WARN("tenant schema is null", K(ret));
 | 
				
			||||||
    } else if (OB_FAIL(ObTableApiSessUtil::init_sess_info(MTL_ID(),
 | 
					    } else if (OB_FAIL(ObTableApiSessUtil::init_sess_info(MTL_ID(),
 | 
				
			||||||
                                                          tenant_schema->get_tenant_name_str(),
 | 
					                                                          tenant_schema->get_tenant_name_str(),
 | 
				
			||||||
                                                          &allocator_,
 | 
					 | 
				
			||||||
                                                          schema_guard,
 | 
					                                                          schema_guard,
 | 
				
			||||||
                                                          sess_info_))) {
 | 
					                                                          sess_info_))) {
 | 
				
			||||||
      LOG_WARN("fail to init sess info", K(ret), K(MTL_ID()));
 | 
					      LOG_WARN("fail to init sess info", K(ret), K(MTL_ID()));
 | 
				
			||||||
@ -790,16 +788,12 @@ int ObTableApiSessForeachOp::operator()(MapKV &entry)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
int ObTableApiSessUtil::init_sess_info(uint64_t tenant_id,
 | 
					int ObTableApiSessUtil::init_sess_info(uint64_t tenant_id,
 | 
				
			||||||
                                       const common::ObString &tenant_name,
 | 
					                                       const common::ObString &tenant_name,
 | 
				
			||||||
                                       ObIAllocator *allocator,
 | 
					 | 
				
			||||||
                                       ObSchemaGetterGuard &schema_guard,
 | 
					                                       ObSchemaGetterGuard &schema_guard,
 | 
				
			||||||
                                       sql::ObSQLSessionInfo &sess_info)
 | 
					                                       sql::ObSQLSessionInfo &sess_info)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  int ret = OB_SUCCESS;
 | 
					  int ret = OB_SUCCESS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (OB_ISNULL(allocator)) {
 | 
					  if (OB_FAIL(sess_info.init(0, 0, nullptr))) {
 | 
				
			||||||
    ret = OB_INVALID_ARGUMENT;
 | 
					 | 
				
			||||||
    LOG_WARN("allocator is null", K(ret));
 | 
					 | 
				
			||||||
  } else if (OB_FAIL(sess_info.init(0, 0, allocator))) {
 | 
					 | 
				
			||||||
    LOG_WARN("fail to init session into", K(ret));
 | 
					    LOG_WARN("fail to init session into", K(ret));
 | 
				
			||||||
  } else if (OB_FAIL(sess_info.init_tenant(tenant_name, tenant_id))) {
 | 
					  } else if (OB_FAIL(sess_info.init_tenant(tenant_name, tenant_id))) {
 | 
				
			||||||
    LOG_WARN("fail to init session tenant", K(ret), K(tenant_id));
 | 
					    LOG_WARN("fail to init session tenant", K(ret), K(tenant_id));
 | 
				
			||||||
 | 
				
			|||||||
@ -128,8 +128,7 @@ friend class ObTableApiSessNode;
 | 
				
			|||||||
friend class ObTableApiSessGuard;
 | 
					friend class ObTableApiSessGuard;
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  explicit ObTableApiSessNodeVal(ObTableApiSessNode *owner)
 | 
					  explicit ObTableApiSessNodeVal(ObTableApiSessNode *owner)
 | 
				
			||||||
      : allocator_("TbSessNodeVal", OB_MALLOC_NORMAL_BLOCK_SIZE, MTL_ID()),
 | 
					      : is_inited_(false),
 | 
				
			||||||
        is_inited_(false),
 | 
					 | 
				
			||||||
        owner_node_(owner)
 | 
					        owner_node_(owner)
 | 
				
			||||||
  {}
 | 
					  {}
 | 
				
			||||||
  TO_STRING_KV(K_(is_inited),
 | 
					  TO_STRING_KV(K_(is_inited),
 | 
				
			||||||
@ -144,7 +143,6 @@ public:
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  void give_back_to_free_list();
 | 
					  void give_back_to_free_list();
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
  common::ObArenaAllocator allocator_;
 | 
					 | 
				
			||||||
  bool is_inited_;
 | 
					  bool is_inited_;
 | 
				
			||||||
  sql::ObSQLSessionInfo sess_info_;
 | 
					  sql::ObSQLSessionInfo sess_info_;
 | 
				
			||||||
  ObTableApiSessNode *owner_node_;
 | 
					  ObTableApiSessNode *owner_node_;
 | 
				
			||||||
@ -312,7 +310,6 @@ class ObTableApiSessUtil final
 | 
				
			|||||||
public:
 | 
					public:
 | 
				
			||||||
  static int init_sess_info(uint64_t tenant_id,
 | 
					  static int init_sess_info(uint64_t tenant_id,
 | 
				
			||||||
                            const common::ObString &tenant_name,
 | 
					                            const common::ObString &tenant_name,
 | 
				
			||||||
                            common::ObIAllocator *allocator,
 | 
					 | 
				
			||||||
                            share::schema::ObSchemaGetterGuard &schema_guard,
 | 
					                            share::schema::ObSchemaGetterGuard &schema_guard,
 | 
				
			||||||
                            sql::ObSQLSessionInfo &sess_info);
 | 
					                            sql::ObSQLSessionInfo &sess_info);
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
 | 
				
			|||||||
@ -143,6 +143,7 @@ TEST_F(TestTableSessPool, mgr_get_session)
 | 
				
			|||||||
  const ObTableApiCredential *cred = nullptr;
 | 
					  const ObTableApiCredential *cred = nullptr;
 | 
				
			||||||
  ASSERT_EQ(OB_SUCCESS, guard.get_credential(cred));
 | 
					  ASSERT_EQ(OB_SUCCESS, guard.get_credential(cred));
 | 
				
			||||||
  ASSERT_NE(nullptr, cred);
 | 
					  ASSERT_NE(nullptr, cred);
 | 
				
			||||||
 | 
					  mgr->destroy();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST_F(TestTableSessPool, mgr_update_session)
 | 
					TEST_F(TestTableSessPool, mgr_update_session)
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user