Fix direct load data buffer members inconsistent lifecycle

This commit is contained in:
obdev 2023-04-23 10:44:32 +00:00 committed by ob-robot
parent f5d814801f
commit d663d4218e
3 changed files with 13 additions and 15 deletions

View File

@ -52,9 +52,9 @@ static int easy_encode_uint64(char *buf, const uint64_t buf_len, int64_t *pos, u
*(buf + (*pos)++) = (char)(((val) >> 40) & 0xff);
*(buf + (*pos)++) = (char)(((val) >> 32) & 0xff);
*(buf + (*pos)++) = (char)(((val) >> 24) & 0xff);
*(buf + (*pos)++) = (char)(((val) >> 16) & 0xff);
*(buf + (*pos)++) = (char)(((val) >> 8) & 0xff);
*(buf + (*pos)++) = (char)((val) & 0xff);
*(buf + (*pos)++) = (char)(((val) >> 16) & 0xff);
*(buf + (*pos)++) = (char)(((val) >> 8) & 0xff);
*(buf + (*pos)++) = (char)((val) & 0xff);
}
return ret;
@ -176,9 +176,9 @@ static int easy_decode_negotiation_msg(easy_negotiation_msg_t *ne_msg, char *rec
PACKET HEADER:
+------------------------------------------------------------------------+
| negotiation packet header magic(8B) | msg body len (2B)
+------------------------------------------------------------------------+
PACKET MSG BODY:
+------------------------------------------------------------------------+
PACKET MSG BODY:
+------------------------------------------------------------------------+
| io thread corresponding eio magic(8B) | io thread index (1B)
+------------------------------------------------------------------------+
@ -264,9 +264,9 @@ void net_consume_negotiation_msg(int fd, uint64_t magic)
if (ne_msg.msg_header.header_magic == EASY_NEGOTIATION_PACKET_HEADER_MAGIC &&
(ne_msg.msg_body.eio_magic == magic || easy_magic_in_support_list(ne_msg.msg_body.eio_magic))) {
while ((rcv_bytes = recv(fd, (char *) recv_buf, decode_len, 0)) < 0 && errno == EINTR);
if (rcv_bytes <= 0) {
easy_error_log("consume negotiaion buffer failed! fd:%d, errno:%d", fd, errno);
} else {
if (rcv_bytes <= 0) {
easy_error_log("consume negotiaion buffer failed! fd:%d, errno:%d", fd, errno);
} else {
easy_info_log("consume negotiation buffer %d bytes!", rcv_bytes);
}
} else {

View File

@ -484,7 +484,7 @@ int ObLoadDataDirectImpl::DataDescIterator::get_next_data_desc(DataDesc &data_de
*/
ObLoadDataDirectImpl::DataBuffer::DataBuffer()
: allocator_("MTL_DataBuffer"), file_buffer_(nullptr), pos_(0), is_end_file_(false)
: file_buffer_(nullptr), pos_(0), is_end_file_(false)
{
}
@ -506,10 +506,10 @@ void ObLoadDataDirectImpl::DataBuffer::reset()
{
if (nullptr != file_buffer_) {
file_buffer_->~ObLoadFileBuffer();
ob_free(file_buffer_);
file_buffer_ = nullptr;
}
pos_ = 0;
allocator_.reset();
}
int ObLoadDataDirectImpl::DataBuffer::init(int64_t capacity)
@ -524,9 +524,9 @@ int ObLoadDataDirectImpl::DataBuffer::init(int64_t capacity)
} else {
const int64_t alloc_size =
MIN(capacity + sizeof(ObLoadFileBuffer), ObLoadFileBuffer::MAX_BUFFER_SIZE);
allocator_.set_tenant_id(MTL_ID());
ObMemAttr attr(MTL_ID(), "MTL_DataBuffer");
void *buf = nullptr;
if (OB_ISNULL(buf = allocator_.alloc(alloc_size))) {
if (OB_ISNULL(buf = ob_malloc(alloc_size, attr))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("fail to allocate memory", KR(ret), K(alloc_size));
} else {

View File

@ -229,8 +229,6 @@ private:
int squash();
void swap(DataBuffer &other);
TO_STRING_KV(KPC_(file_buffer), K_(pos));
private:
common::ObArenaAllocator allocator_;
public:
ObLoadFileBuffer *file_buffer_;
int64_t pos_; // left pos