ob_pg_partition.cpp 18.9 KB
Newer Older
O
oceanbase-admin 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
/**
 * Copyright (c) 2021 OceanBase
 * OceanBase CE is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */

#define USING_LOG_PREFIX STORAGE

#include "storage/ob_pg_partition.h"
#include "lib/utility/ob_print_utils.h"
#include "lib/utility/ob_tracepoint.h"
#include "common/ob_partition_key.h"
#include "storage/ob_i_partition_group.h"
#include "storage/ob_partition_storage.h"
#include "storage/ob_partition_service.h"
#include "storage/ob_saved_storage_info_v2.h"
#include "storage/memtable/ob_memtable.h"
#include "storage/ob_partition_log.h"
#include "share/ob_partition_modify.h"
#include "storage/ob_partition_migrator.h"
#include "storage/ob_i_partition_group.h"
#include "storage/ob_pg_storage.h"

namespace oceanbase {
using namespace common;
using namespace memtable;
using namespace transaction;
using namespace share::schema;
using namespace share;
namespace storage {

ObPGPartition::ObPGPartition()
    : is_inited_(false),
      pkey_(),
      cp_fty_(NULL),
      storage_(NULL),
      schema_recorder_(),
      pg_(NULL),
      merge_successed_(false),
      merge_timestamp_(0),
      merge_failed_cnt_(0),
      gc_start_ts_(0),
      build_index_schema_version_(0),
      build_index_schema_version_refreshed_ts_(INT64_MAX),
      schema_version_change_log_id_(0),
      schema_version_change_log_ts_(0)
{}

ObPGPartition::~ObPGPartition()
{
57
  FLOG_INFO("deconstruct ObPGPartition", K(this), K_(pkey));
O
oceanbase-admin 已提交
58 59 60 61 62
  destroy();
}

void ObPGPartition::destroy()
{
63
  FLOG_INFO("destroy ObPGPartition", K(this), K_(pkey));
O
oceanbase-admin 已提交
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
  pkey_.reset();
  if (NULL != cp_fty_) {
    if (NULL != storage_) {
      cp_fty_->free(storage_);
      storage_ = NULL;
    }
  }
  cp_fty_ = NULL;
  is_inited_ = false;
}

bool ObPGPartition::is_inited() const
{
  bool bool_ret = true;

  // No lock operation, the caller needs to handle the logic by himself
  if (!is_inited_) {
    bool_ret = false;
  } else if (OB_ISNULL(storage_) || !storage_->is_inited()) {
    bool_ret = false;
  } else {
    // do nothing
  }
  return bool_ret;
}

int ObPGPartition::check_init(void* cp, const char* cp_name) const
{
  int ret = OB_SUCCESS;
  if (!is_inited_ || NULL == cp || NULL == cp_name) {
    ret = OB_NOT_INIT;
    STORAGE_LOG(WARN, "component does not exist", "component name", cp_name);
  }

  return ret;
}

int ObPGPartition::init(const common::ObPartitionKey& pkey, ObIPartitionComponentFactory* cp_fty,
    share::schema::ObMultiVersionSchemaService* schema_service, transaction::ObTransService* txs, ObIPartitionGroup* pg,
    ObPGMemtableMgr& pg_memtable_mgr)
{
  int ret = OB_SUCCESS;
  const uint64_t tenant_id = ((pkey.get_tenant_id() > 0) ? pkey.get_tenant_id() : OB_SERVER_TENANT_ID);

  if (is_inited_) {
    ret = OB_INIT_TWICE;
    STORAGE_LOG(WARN, "ObPGPartition init twice", K(pkey), KP(cp_fty), KP(schema_service), KP(txs));
  } else if (!pkey.is_valid() || OB_ISNULL(cp_fty) || OB_ISNULL(schema_service) || OB_ISNULL(pg)) {
    ret = OB_INVALID_ARGUMENT;
    STORAGE_LOG(WARN, "invalid argument", K(pkey), KP(cp_fty), KP(schema_service));
  } else if (NULL == (storage_ = cp_fty->get_partition_storage(tenant_id))) {
    ret = OB_ALLOCATE_MEMORY_FAILED;
    STORAGE_LOG(ERROR, "create partition storage failed.", K(ret));
  } else if (OB_FAIL(storage_->init(pkey, cp_fty, schema_service, txs, pg_memtable_mgr))) {
    STORAGE_LOG(WARN, "ObPartitionStorage init error", K(ret));
  } else {
    is_inited_ = true;
    cp_fty_ = cp_fty;
    pkey_ = pkey;
    pg_ = pg;
  }
  if (OB_FAIL(ret)) {
    destroy();
  }
128
  FLOG_INFO("ObPGPartition::init", K(ret), K(pkey), K(this));
O
oceanbase-admin 已提交
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209

  return ret;
}

int ObPGPartition::serialize(ObArenaAllocator& allocator, char*& new_buf, int64_t& serialize_size)
{
  int ret = OB_SUCCESS;

  if (OB_SUCCESS == (ret = check_init(storage_, "partition storage"))) {
    if (OB_FAIL(storage_->serialize(allocator, new_buf, serialize_size))) {
      STORAGE_LOG(WARN, "Fail to serialize storage, ", K(ret));
    }
  }
  return ret;
}

int ObPGPartition::deserialize(const ObReplicaType replica_type, const char* buf, const int64_t buf_len,
    ObIPartitionGroup* pg, int64_t& pos, bool& is_old_meta, ObPartitionStoreMeta& old_meta)
{
  int ret = OB_SUCCESS;
  int64_t tmp_pos = pos;

  if (NULL == buf || buf_len <= 0 || tmp_pos < 0 || tmp_pos >= buf_len || OB_ISNULL(pg)) {
    ret = OB_INVALID_ARGUMENT;
    STORAGE_LOG(WARN, "invalid argument", K(ret), K(buf), K(buf_len), K(pos), KP(pg));
  } else if (OB_FAIL(check_init(storage_, "partition storage"))) {
    // do nothing
  } else if (OB_FAIL(storage_->deserialize(replica_type, buf, buf_len, pg, tmp_pos, is_old_meta, old_meta))) {
    STORAGE_LOG(WARN, "Fail to deserialize partition storage, ", K(ret));
  } else {
    pos = tmp_pos;
    pkey_ = storage_->get_partition_key();
  }

  STORAGE_LOG(INFO, "deserialize partition", K(ret), K_(pkey));
  return ret;
}

ObIPartitionStorage* ObPGPartition::get_storage()
{
  return storage_;
}

const ObPartitionSplitInfo& ObPGPartition::get_split_info()
{
  return pg_->get_split_info();
}

void ObPGPartition::set_merge_status(bool merge_success)
{
  ATOMIC_STORE(&merge_successed_, merge_success);
  ATOMIC_STORE(&merge_timestamp_, ObTimeUtility::current_time());
  if (merge_success) {
    ATOMIC_STORE(&merge_failed_cnt_, 0);
  } else {
    ATOMIC_AAF(&merge_failed_cnt_, 1);
  }
}

bool ObPGPartition::can_schedule_merge()
{
  bool bool_ret = true;
  int64_t delay_duration = merge_failed_cnt_ * DELAY_SCHEDULE_TIME_UNIT;
  if (delay_duration > MAX_DELAY_SCHEDULE_TIME_UNIT) {
    delay_duration = MAX_DELAY_SCHEDULE_TIME_UNIT;
  }
  if (!merge_successed_ && (ObTimeUtility::current_time() < (merge_timestamp_ + delay_duration))) {
    bool_ret = false;
    if (REACH_TIME_INTERVAL(10 * 1000 * 1000 /*10s*/)) {
      STORAGE_LOG(
          INFO, "cannot schedule merge now", K(pkey_), K(merge_timestamp_), K(merge_successed_), K(merge_failed_cnt_));
    }
  }

  return bool_ret;
}

int ObPGPartition::get_refreshed_schema_info(int64_t& schema_version, int64_t& refreshed_schema_ts,
    uint64_t& schema_version_change_log_id, int64_t& schema_version_change_log_ts)
{
  // Ensure to get the schema version first, and then get ts
C
Charles0429 已提交
210
  ObSpinLockGuard guard(lock_);
O
oceanbase-admin 已提交
211 212 213 214 215 216 217 218 219
  ATOMIC_STORE(&schema_version, build_index_schema_version_);
  refreshed_schema_ts = build_index_schema_version_refreshed_ts_;
  schema_version_change_log_id = schema_version_change_log_id_;
  schema_version_change_log_ts = schema_version_change_log_ts_;
  return OB_SUCCESS;
}

// There will be no concurrency here, so there is no need to lock
int ObPGPartition::update_build_index_schema_info(
C
Charles0429 已提交
220
    const int64_t schema_version, const uint64_t log_id, const int64_t log_ts, int64_t &schema_refreshed_ts)
O
oceanbase-admin 已提交
221 222
{
  int ret = OB_SUCCESS;
C
Charles0429 已提交
223
  ObSpinLockGuard guard(lock_);
C
Charles0429 已提交
224
  if (schema_version < 0 || log_id <= 0 || log_ts <= 0) {
O
oceanbase-admin 已提交
225
    ret = OB_INVALID_ARGUMENT;
C
Charles0429 已提交
226
    TRANS_LOG(WARN, "invalid argument", K(schema_version), K(log_id), K(log_ts));
O
oceanbase-admin 已提交
227 228 229 230
  } else if (build_index_schema_version_ < schema_version) {
    // First record
    if (INT64_MAX == build_index_schema_version_refreshed_ts_) {
      // Ensure that the schema version is updated at the end
C
Charles0429 已提交
231
      build_index_schema_version_refreshed_ts_ = ObTimeUtility::current_time();
O
oceanbase-admin 已提交
232 233 234 235 236
      schema_version_change_log_id_ = log_id;
      schema_version_change_log_ts_ = log_ts;
      ATOMIC_STORE(&build_index_schema_version_, schema_version);
    } else {
      // Ensure that the schema version is updated at the end
C
Charles0429 已提交
237 238
      build_index_schema_version_refreshed_ts_ =
          std::max(ObTimeUtility::current_time(), build_index_schema_version_refreshed_ts_);
O
oceanbase-admin 已提交
239 240 241 242 243 244 245
      schema_version_change_log_id_ = log_id;
      schema_version_change_log_ts_ = log_ts;
      ATOMIC_STORE(&build_index_schema_version_, schema_version);
    }
  } else {
    // do nothing
  }
C
Charles0429 已提交
246 247 248
  if (OB_SUCC(ret)) {
    schema_refreshed_ts = build_index_schema_version_refreshed_ts_;
  }
O
oceanbase-admin 已提交
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576
  return ret;
}

int ObPGPartition::replay_schema_log(const char* buf, const int64_t size, const int64_t log_id)
{
  return schema_recorder_.replay_schema_log(buf, size, log_id);
}

bool ObPGPartition::is_gc_starting_() const
{
  // no need to use atmoic_load
  return gc_start_ts_ > 0;
}

int ObPGPartition::get_gc_start_ts(int64_t& gc_start_ts)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else {
    // no need to use atmoic_load
    gc_start_ts = gc_start_ts_;
  }
  return ret;
}

// The call of this method, only gc thread operation,
//  there will be no multi-threaded concurrency
int ObPGPartition::set_gc_starting()
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (gc_start_ts_ <= 0) {
    /* Problem Description:
     * Here it is only necessary to preset gc_start_ts to a value greater than 0,
     * in order to solve the concurrency in the following scenarios:
     *  Thread 1: Get the local system time (a), then update gc_start_ts(b);
     *  Thread 2: Generate ctx_create_timestamp(c), access gc_start_ts is greater than 0(d)
     *  Possible problems: If the execution order becomes abcd,
     *    the gc thread may miss the transaction operated by thread 2
     *
     * Solution:
     *   (1) Set the bool variable, dml interface all checks whether the variable is greater than 0;
     *   (2) Combine gc_start_ts_ with the bool variable in (1)
     *
     * So ensure that gc_start_ts is greater than all transaction contexts
     * operated by this pg_partition ctx_create_timestamp
     */
    ATOMIC_STORE(&gc_start_ts_, 1);
    // To be safe, reduce the impact of clock rollback and other effects,
    // increase the value of gc_start_ts by 10s
    ATOMIC_STORE(&gc_start_ts_, ObTimeUtility::current_time() + 10 * 1000 * 1000);
  } else {
    // do nothing
  }
  return ret;
}

int ObPGPartition::delete_rows(const ObStoreCtx& ctx, const ObDMLBaseParam& dml_param,
    const ObIArray<uint64_t>& column_ids, ObNewRowIterator* row_iter, int64_t& affected_rows)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (is_gc_starting_()) {
    ret = OB_PARTITION_NOT_EXIST;
    STORAGE_LOG(WARN, "partition is garbage cleaning", K(ret), K(ctx), K(dml_param));
  } else {
    ret = storage_->delete_rows(ctx, dml_param, column_ids, row_iter, affected_rows);
  }

  return ret;
}

int ObPGPartition::delete_row(
    const ObStoreCtx& ctx, const ObDMLBaseParam& dml_param, const ObIArray<uint64_t>& column_ids, const ObNewRow& row)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (is_gc_starting_()) {
    ret = OB_PARTITION_NOT_EXIST;
    STORAGE_LOG(WARN, "partition is garbage cleaning", K(ret), K(ctx), K(dml_param));
  } else {
    ret = storage_->delete_row(ctx, dml_param, column_ids, row);
  }

  return ret;
}

int ObPGPartition::put_rows(const ObStoreCtx& ctx, const ObDMLBaseParam& dml_param,
    const ObIArray<uint64_t>& column_ids, ObNewRowIterator* row_iter, int64_t& affected_rows)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (is_gc_starting_()) {
    ret = OB_PARTITION_NOT_EXIST;
    STORAGE_LOG(WARN, "partition is garbage cleaning", K(ret), K(ctx), K(dml_param));
  } else {
    ret = storage_->put_rows(ctx, dml_param, column_ids, row_iter, affected_rows);
  }
  return ret;
}

int ObPGPartition::insert_rows(const ObStoreCtx& ctx, const ObDMLBaseParam& dml_param,
    const common::ObIArray<uint64_t>& column_ids, common::ObNewRowIterator* row_iter, int64_t& affected_rows)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (is_gc_starting_()) {
    ret = OB_PARTITION_NOT_EXIST;
    STORAGE_LOG(WARN, "partition is garbage cleaning", K(ret), K(ctx), K(dml_param));
  } else {
    ret = storage_->insert_rows(ctx, dml_param, column_ids, row_iter, affected_rows);
  }

  return ret;
}

int ObPGPartition::insert_row(
    const ObStoreCtx& ctx, const ObDMLBaseParam& dml_param, const ObIArray<uint64_t>& column_ids, const ObNewRow& row)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (is_gc_starting_()) {
    ret = OB_PARTITION_NOT_EXIST;
    STORAGE_LOG(WARN, "partition is garbage cleaning", K(ret), K(ctx), K(dml_param));
  } else {
    ret = storage_->insert_row(ctx, dml_param, column_ids, row);
  }

  return ret;
}

int ObPGPartition::insert_row(const ObStoreCtx& ctx, const ObDMLBaseParam& dml_param,
    const common::ObIArray<uint64_t>& column_ids, const common::ObIArray<uint64_t>& duplicated_column_ids,
    const common::ObNewRow& row, const ObInsertFlag flag, int64_t& affected_rows,
    common::ObNewRowIterator*& duplicated_rows)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (is_gc_starting_()) {
    ret = OB_PARTITION_NOT_EXIST;
    STORAGE_LOG(WARN, "partition is garbage cleaning", K(ret), K(ctx), K(dml_param));
  } else {
    ret = storage_->insert_row(
        ctx, dml_param, column_ids, duplicated_column_ids, row, flag, affected_rows, duplicated_rows);
  }

  return ret;
}

int ObPGPartition::fetch_conflict_rows(const ObStoreCtx& ctx, const ObDMLBaseParam& dml_param,
    const ObIArray<uint64_t>& in_column_ids, const ObIArray<uint64_t>& out_column_ids, ObNewRowIterator& check_row_iter,
    ObIArray<ObNewRowIterator*>& dup_row_iters)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (is_gc_starting_()) {
    ret = OB_PARTITION_NOT_EXIST;
    STORAGE_LOG(WARN, "partition is garbage cleaning", K(ret), K(ctx), K(dml_param));
  } else {
    ret = storage_->fetch_conflict_rows(ctx, dml_param, in_column_ids, out_column_ids, check_row_iter, dup_row_iters);
  }

  return ret;
}

int ObPGPartition::update_rows(const ObStoreCtx& ctx, const ObDMLBaseParam& dml_param,
    const ObIArray<uint64_t>& column_ids, const ObIArray<uint64_t>& updated_column_ids, ObNewRowIterator* row_iter,
    int64_t& affected_rows)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (is_gc_starting_()) {
    ret = OB_PARTITION_NOT_EXIST;
    STORAGE_LOG(WARN, "partition is garbage cleaning", K(ret), K(ctx), K(dml_param));
  } else {
    ret = storage_->update_rows(ctx, dml_param, column_ids, updated_column_ids, row_iter, affected_rows);
  }

  return ret;
}

int ObPGPartition::update_row(const ObStoreCtx& ctx, const ObDMLBaseParam& dml_param,
    const ObIArray<uint64_t>& column_ids, const ObIArray<uint64_t>& updated_column_ids, const ObNewRow& old_row,
    const ObNewRow& new_row)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (is_gc_starting_()) {
    ret = OB_PARTITION_NOT_EXIST;
    STORAGE_LOG(WARN, "partition is garbage cleaning", K(ret), K(ctx), K(dml_param));
  } else {
    ret = storage_->update_row(ctx, dml_param, column_ids, updated_column_ids, old_row, new_row);
  }
  return ret;
}

int ObPGPartition::lock_rows(const ObStoreCtx& ctx, const ObDMLBaseParam& dml_param, const int64_t abs_lock_timeout,
    ObNewRowIterator* row_iter, const ObLockFlag lock_flag, int64_t& affected_rows)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (is_gc_starting_()) {
    ret = OB_PARTITION_NOT_EXIST;
    STORAGE_LOG(WARN, "partition is garbage cleaning", K(ret), K(ctx), K(dml_param));
  } else {
    ret = storage_->lock_rows(ctx, dml_param, abs_lock_timeout, row_iter, lock_flag, affected_rows);
  }
  return ret;
}

int ObPGPartition::lock_rows(const ObStoreCtx& ctx, const ObDMLBaseParam& dml_param, const int64_t abs_lock_timeout,
    const ObNewRow& row, const ObLockFlag lock_flag)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (is_gc_starting_()) {
    ret = OB_PARTITION_NOT_EXIST;
    STORAGE_LOG(WARN, "partition is garbage cleaning", K(ret), K(ctx), K(dml_param));
  } else {
    ret = storage_->lock_rows(ctx, dml_param, abs_lock_timeout, row, lock_flag);
  }
  return ret;
}

int ObPGPartition::table_scan(ObTableScanParam& param, const int64_t data_max_schema_version, ObNewRowIterator*& result)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (is_gc_starting_()) {
    ret = OB_PARTITION_NOT_EXIST;
    STORAGE_LOG(WARN, "partition is garbage cleaning", K(ret), K(param));
  } else {
    ret = storage_->table_scan(param, data_max_schema_version, result);
  }
  return ret;
}

int ObPGPartition::table_scan(
    ObTableScanParam& param, const int64_t data_max_schema_version, ObNewIterIterator*& result)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (is_gc_starting_()) {
    ret = OB_PARTITION_NOT_EXIST;
    STORAGE_LOG(WARN, "partition is garbage cleaning", K(ret), K(param));
  } else {
    ret = storage_->table_scan(param, data_max_schema_version, result);
  }
  return ret;
}

int ObPGPartition::join_mv_scan(ObTableScanParam& left_param, ObTableScanParam& right_param,
    const int64_t left_data_max_schema_version, const int64_t right_data_max_schema_version, ObPGPartition& right_part,
    common::ObNewRowIterator*& result)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (OB_ISNULL(right_part.get_storage())) {
    ret = OB_INVALID_ARGUMENT;
    LOG_WARN("invalid argument", K(ret), K(right_part.get_storage()));
  } else if (is_gc_starting_()) {
    ret = OB_PARTITION_NOT_EXIST;
    STORAGE_LOG(WARN, "partition is garbage cleaning", K(ret), K(left_param), K(right_param));
  } else {
    ret = storage_->join_mv_scan(left_param,
        right_param,
        left_data_max_schema_version,
        right_data_max_schema_version,
        *(right_part.get_storage()),
        result);
  }
  return ret;
}

int ObPGPartition::feedback_scan_access_stat(const ObTableScanParam& param)
{
  int ret = OB_SUCCESS;

  if (OB_FAIL(check_init(storage_, "partition storage"))) {
  } else if (is_gc_starting_()) {
    ret = OB_PARTITION_NOT_EXIST;
    STORAGE_LOG(WARN, "partition is garbage cleaning", K(ret), K(param));
  } else {
    ret = storage_->feedback_scan_access_stat(param);
  }
  return ret;
}

ObPGPartitionArrayGuard::~ObPGPartitionArrayGuard()
{
  ObPGPartition* partition = nullptr;
  ObIPartitionGroup* pg = nullptr;
  for (int64_t i = 0; i < partitions_.count(); ++i) {
    if (OB_LIKELY(nullptr != (partition = partitions_.at(i)))) {
      if (OB_LIKELY(nullptr != (pg = partition->get_pg()))) {
        pg_partition_map_.revert(partition);
      }
    }
  }
}

int ObPGPartitionArrayGuard::push_back(ObPGPartition* pg_partition)
{
  int ret = OB_SUCCESS;
  if (OB_FAIL(partitions_.push_back(pg_partition))) {
    STORAGE_LOG(WARN, "failed to push back pg partition", K(ret));
  }
  return ret;
}

}  // namespace storage
}  // namespace oceanbase