[BUG] add case for write only index of double update

This commit is contained in:
Handora
2023-06-01 14:11:51 +00:00
committed by ob-robot
parent 2a28ee0b5c
commit 1abc669899
3 changed files with 28 additions and 8 deletions

View File

@ -1130,6 +1130,10 @@ int ObDMLService::init_dml_param(const ObDASDMLBaseCtDef &base_ctdef,
if (base_ctdef.is_insert_up_) {
dml_param.write_flag_.set_is_insert_up();
}
if (dml_param.table_param_->get_data_table().is_storage_index_table()
&& !dml_param.table_param_->get_data_table().can_read_index()) {
dml_param.write_flag_.set_is_write_only_index();
}
return ret;
}

View File

@ -133,6 +133,17 @@ int check_sequence_set_violation(const concurrent_control::ObWriteFlag write_fla
&& blocksstable::ObDmlFlag::DF_UPDATE == writer_dml_flag
&& blocksstable::ObDmlFlag::DF_UPDATE == locker_dml_flag) {
// bypass the case
// Case 9: For the case of the write only index, it may operate the same
// row more than once under the case that main table has two rows pointing
// to the same index which is building during the first stage(in which
// stage update and insert should consider index while the index is not
// readable). In the case, an update may update the same row on the index.
// So we need report the batched stmt warning according to this case.
} else if (write_flag.is_write_only_index()) {
ret = OB_ERR_PRIMARY_KEY_DUPLICATE;
TRANS_LOG(WARN, "write only index insert/update on the same row", K(ret),
K(writer_tx_id), K(writer_dml_flag), K(writer_seq_no),
K(locker_tx_id), K(locker_dml_flag), K(locker_seq_no));
} else {
// Others: It will never happen that two operaions on the same row for the
// same txn except the above cases. So we should report unexpected error.

View File

@ -29,6 +29,7 @@ struct ObWriteFlag
#define OBWF_BIT_MDS 1
#define OBWF_BIT_DML_BATCH_OPT 1
#define OBWF_BIT_INSERT_UP 1
#define OBWF_BIT_WRITE_ONLY_INDEX 1
#define OBWF_BIT_RESERVED 61
static const uint64_t OBWF_MASK_TABLE_API = (0x1UL << OBWF_BIT_TABLE_API) - 1;
@ -36,6 +37,7 @@ struct ObWriteFlag
static const uint64_t OBWF_MASK_MDS = (0x1UL << OBWF_BIT_MDS) - 1;
static const uint64_t OBWF_MASK_DML_BATCH_OPT = (0x1UL << OBWF_BIT_DML_BATCH_OPT) - 1;
static const uint64_t OBWF_MASK_INSERT_UP = (0x1UL << OBWF_BIT_INSERT_UP) - 1;
static const uint64_t OBWF_MASK_WRITE_ONLY_INDEX = (0x1UL << OBWF_BIT_WRITE_ONLY_INDEX) - 1;
union
{
@ -47,6 +49,7 @@ struct ObWriteFlag
uint64_t is_mds_ : OBWF_BIT_MDS; // 0: false(default), 1: true
uint64_t is_dml_batch_opt_ : OBWF_BIT_DML_BATCH_OPT; // 0: false(default), 1: true
uint64_t is_insert_up_ : OBWF_BIT_INSERT_UP; // 0: false(default), 1: true
uint64_t is_write_only_index_ : OBWF_BIT_WRITE_ONLY_INDEX; // 0: false(default), 1: true
uint64_t reserved_ : OBWF_BIT_RESERVED;
};
};
@ -63,13 +66,15 @@ struct ObWriteFlag
inline void set_is_dml_batch_opt() { is_dml_batch_opt_ = true; }
inline bool is_insert_up() const { return is_insert_up_; }
inline void set_is_insert_up() { is_insert_up_ = true; }
inline bool is_write_only_index() const { return is_write_only_index_; }
inline void set_is_write_only_index() { is_write_only_index_ = true; }
TO_STRING_KV("is_table_api", is_table_api_,
"is_table_lock", is_table_lock_,
"is_mds", is_mds_,
"is_dml_batch_opt", is_dml_batch_opt_,
"is_insert_up", is_insert_up_);
"is_insert_up", is_insert_up_,
"is_write_only_index", is_write_only_index_);
OB_UNIS_VERSION(1);
};