Fix direct load data buffer members inconsistent lifecycle
This commit is contained in:
18
deps/easy/src/io/easy_negotiation.c
vendored
18
deps/easy/src/io/easy_negotiation.c
vendored
@ -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) >> 40) & 0xff);
|
||||||
*(buf + (*pos)++) = (char)(((val) >> 32) & 0xff);
|
*(buf + (*pos)++) = (char)(((val) >> 32) & 0xff);
|
||||||
*(buf + (*pos)++) = (char)(((val) >> 24) & 0xff);
|
*(buf + (*pos)++) = (char)(((val) >> 24) & 0xff);
|
||||||
*(buf + (*pos)++) = (char)(((val) >> 16) & 0xff);
|
*(buf + (*pos)++) = (char)(((val) >> 16) & 0xff);
|
||||||
*(buf + (*pos)++) = (char)(((val) >> 8) & 0xff);
|
*(buf + (*pos)++) = (char)(((val) >> 8) & 0xff);
|
||||||
*(buf + (*pos)++) = (char)((val) & 0xff);
|
*(buf + (*pos)++) = (char)((val) & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -176,9 +176,9 @@ static int easy_decode_negotiation_msg(easy_negotiation_msg_t *ne_msg, char *rec
|
|||||||
PACKET HEADER:
|
PACKET HEADER:
|
||||||
+------------------------------------------------------------------------+
|
+------------------------------------------------------------------------+
|
||||||
| negotiation packet header magic(8B) | msg body len (2B)
|
| 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)
|
| 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 &&
|
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))) {
|
(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);
|
while ((rcv_bytes = recv(fd, (char *) recv_buf, decode_len, 0)) < 0 && errno == EINTR);
|
||||||
if (rcv_bytes <= 0) {
|
if (rcv_bytes <= 0) {
|
||||||
easy_error_log("consume negotiaion buffer failed! fd:%d, errno:%d", fd, errno);
|
easy_error_log("consume negotiaion buffer failed! fd:%d, errno:%d", fd, errno);
|
||||||
} else {
|
} else {
|
||||||
easy_info_log("consume negotiation buffer %d bytes!", rcv_bytes);
|
easy_info_log("consume negotiation buffer %d bytes!", rcv_bytes);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -484,7 +484,7 @@ int ObLoadDataDirectImpl::DataDescIterator::get_next_data_desc(DataDesc &data_de
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
ObLoadDataDirectImpl::DataBuffer::DataBuffer()
|
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_) {
|
if (nullptr != file_buffer_) {
|
||||||
file_buffer_->~ObLoadFileBuffer();
|
file_buffer_->~ObLoadFileBuffer();
|
||||||
|
ob_free(file_buffer_);
|
||||||
file_buffer_ = nullptr;
|
file_buffer_ = nullptr;
|
||||||
}
|
}
|
||||||
pos_ = 0;
|
pos_ = 0;
|
||||||
allocator_.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObLoadDataDirectImpl::DataBuffer::init(int64_t capacity)
|
int ObLoadDataDirectImpl::DataBuffer::init(int64_t capacity)
|
||||||
@ -524,9 +524,9 @@ int ObLoadDataDirectImpl::DataBuffer::init(int64_t capacity)
|
|||||||
} else {
|
} else {
|
||||||
const int64_t alloc_size =
|
const int64_t alloc_size =
|
||||||
MIN(capacity + sizeof(ObLoadFileBuffer), ObLoadFileBuffer::MAX_BUFFER_SIZE);
|
MIN(capacity + sizeof(ObLoadFileBuffer), ObLoadFileBuffer::MAX_BUFFER_SIZE);
|
||||||
allocator_.set_tenant_id(MTL_ID());
|
ObMemAttr attr(MTL_ID(), "MTL_DataBuffer");
|
||||||
void *buf = nullptr;
|
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;
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
LOG_WARN("fail to allocate memory", KR(ret), K(alloc_size));
|
LOG_WARN("fail to allocate memory", KR(ret), K(alloc_size));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -229,8 +229,6 @@ private:
|
|||||||
int squash();
|
int squash();
|
||||||
void swap(DataBuffer &other);
|
void swap(DataBuffer &other);
|
||||||
TO_STRING_KV(KPC_(file_buffer), K_(pos));
|
TO_STRING_KV(KPC_(file_buffer), K_(pos));
|
||||||
private:
|
|
||||||
common::ObArenaAllocator allocator_;
|
|
||||||
public:
|
public:
|
||||||
ObLoadFileBuffer *file_buffer_;
|
ObLoadFileBuffer *file_buffer_;
|
||||||
int64_t pos_; // left pos
|
int64_t pos_; // left pos
|
||||||
|
|||||||
Reference in New Issue
Block a user