Skip to content

Commit 99fb4d4

Browse files
wanyue-wywanyue.wy
andauthored
[Store][Bugfix] Fixed the problem of filling in the wrong TE endpoint
Co-authored-by: wanyue.wy <wanyue.wy@oceanbase.com>
1 parent 0d8a51f commit 99fb4d4

4 files changed

Lines changed: 24 additions & 10 deletions

File tree

mooncake-store/include/client_service.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,12 @@ class ClientService {
513513
return local_ip_ + ":" + std::to_string(te_port_);
514514
}
515515

516+
// The segment endpoint that the transfer engine registered with the
517+
// metadata backend.
518+
std::string te_endpoint_;
519+
void initTeEndpoint();
520+
const std::string& get_te_endpoint() const { return te_endpoint_; }
521+
516522
const std::string metadata_connstring_;
517523
// For high availability
518524
MasterViewHelper master_view_helper_;

mooncake-store/src/centralized_client_service.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ ErrorCode CentralizedClientService::Init(
151151
LOG(INFO) << "Use existing transfer engine instance. Skip its "
152152
"initialization.";
153153
}
154+
initTeEndpoint();
154155

155156
InitTransferSubmitter();
156157

@@ -1639,14 +1640,7 @@ tl::expected<void, ErrorCode> CentralizedClientService::MountSegment(
16391640
CentralizedSegmentExtraData extra;
16401641
extra.base = reinterpret_cast<uintptr_t>(buffer);
16411642

1642-
// For P2P handshake mode, publish the actual transport endpoint that was
1643-
// negotiated by the transfer engine. Otherwise, keep the logical hostname
1644-
// so metadata backends (HTTP/etcd/redis) can resolve the segment by name.
1645-
if (metadata_connstring_ == P2PHANDSHAKE) {
1646-
extra.te_endpoint = transfer_engine_->getLocalIpAndPort();
1647-
} else {
1648-
extra.te_endpoint = local_endpoint();
1649-
}
1643+
extra.te_endpoint = get_te_endpoint();
16501644
segment.extra = extra;
16511645

16521646
auto mount_result = master_client_.MountSegment(segment);

mooncake-store/src/client_service.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,25 @@
1010
#include <thread>
1111

1212
#include "config.h"
13+
#include "transfer_engine.h"
1314
#include "types.h"
1415
#include "p2p_client_service.h"
1516
#include "centralized_client_service.h"
1617

1718
namespace mooncake {
1819

20+
void ClientService::initTeEndpoint() {
21+
// For P2PHANDSHAKE the TE picks a random port and updates
22+
// local_server_name_ accordingly, so getLocalIpAndPort() is authoritative.
23+
// For HTTP/etcd/redis metadata the segment is published under the
24+
// configured local_endpoint().
25+
if (metadata_connstring_ == P2PHANDSHAKE) {
26+
te_endpoint_ = transfer_engine_->getLocalIpAndPort();
27+
} else {
28+
te_endpoint_ = local_endpoint();
29+
}
30+
}
31+
1932
size_t ClientService::CalculateSliceSize(const std::vector<Slice>& slices) {
2033
size_t slice_size = 0;
2134
for (const auto& slice : slices) {

mooncake-store/src/p2p_client_service.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ ErrorCode P2PClientService::Init(const P2PClientConfig& config) {
9595
LOG(INFO) << "Use existing transfer engine instance. Skip its "
9696
"initialization.";
9797
}
98+
initTeEndpoint();
9899

99100
// 3. Register with master BEFORE InitStorage, because InitStorage
100101
// triggers TieredBackend::MountSegment which requires the client to
@@ -445,7 +446,7 @@ tl::expected<void, ErrorCode> P2PClientService::PutViaRoute(
445446
write_req.key = key;
446447
for (const auto& slice : slices) {
447448
RemoteBufferDesc buf;
448-
buf.segment_endpoint = transfer_engine_->getLocalIpAndPort();
449+
buf.segment_endpoint = get_te_endpoint();
449450
buf.addr = reinterpret_cast<uintptr_t>(slice.ptr);
450451
buf.size = slice.size;
451452
write_req.src_buffers.push_back(buf);
@@ -894,7 +895,7 @@ tl::expected<void, ErrorCode> P2PClientService::GetRemoteViaRoute(
894895
read_req.key = key;
895896
for (const auto& slice : slices) {
896897
RemoteBufferDesc buf;
897-
buf.segment_endpoint = transfer_engine_->getLocalIpAndPort();
898+
buf.segment_endpoint = get_te_endpoint();
898899
buf.addr = reinterpret_cast<uintptr_t>(slice.ptr);
899900
buf.size = slice.size;
900901
read_req.dest_buffers.push_back(buf);

0 commit comments

Comments
 (0)