Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mds:fix updatechunkserverstat bug & add some logs #2947

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/chunkserver/chunkserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ int ChunkServer::Run(int argc, char** argv) {
heartbeatOptions.chunkFilePool = chunkfilePool;
heartbeatOptions.chunkserverId = metadata.id();
heartbeatOptions.chunkserverToken = metadata.token();
heartbeatOptions.useChunkFilePoolAsWalPool = useChunkFilePoolAsWalPool;
LOG_IF(FATAL, heartbeat_.Init(heartbeatOptions) != 0)
<< "Failed to init Heartbeat manager.";

Expand Down
5 changes: 0 additions & 5 deletions src/chunkserver/datastore/file_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ bool FilePool::ScanInternal() {
}
}

currentState_.capacity = tmpvec.size();
currentState_.preallocatedChunksLeft = tmpvec.size();

std::unique_lock<std::mutex> lk(mtx_);
Expand All @@ -539,10 +538,6 @@ size_t FilePool::Size() {
return tmpChunkvec_.size();
}

size_t FilePool::Capacity() {
return currentState_.capacity;
}

FilePoolState FilePool::GetState() const {
return currentState_;
}
Expand Down
4 changes: 0 additions & 4 deletions src/chunkserver/datastore/file_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ struct FilePoolState {
uint32_t metaPageSize = 0;
// io alignment
uint32_t blockSize = 0;
// filepool Capacity
uint64_t capacity = 0;
};

struct FilePoolMeta {
Expand Down Expand Up @@ -173,8 +171,6 @@ class CURVE_CACHELINE_ALIGNMENT FilePool {
*/
virtual size_t Size();

virtual size_t Capacity();

/**
* Get the allocation status of FilePool
*/
Expand Down
16 changes: 11 additions & 5 deletions src/chunkserver/heartbeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,17 @@ int Heartbeat::BuildRequest(HeartbeatRequest* req) {
// leftWalSegmentSize will be 0 when CHUNK and WAL share file pool
uint64_t leftWalSegmentSize = metric->GetWalSegmentLeftCount()
* walSegmentFileSize;
uint64_t chunkPoolSize = options_.chunkFilePool->Capacity() *
options_.chunkFilePool->GetFilePoolOpt().fileSize;
stats->set_chunkfilepoolsize(chunkPoolSize);
stats->set_chunksizeusedbytes(usedChunkSize+usedWalSegmentSize);
stats->set_chunksizeleftbytes(leftChunkSize+leftWalSegmentSize);
// CHUNK and WAL share file pool
uint64_t totalSize = 0;
if (options_.useChunkFilePoolAsWalPool) {
totalSize = usedChunkSize + usedWalSegmentSize +
leftChunkSize + leftWalSegmentSize;
} else {
totalSize = usedChunkSize + leftChunkSize;
}
stats->set_chunkfilepoolsize(totalSize);
stats->set_chunksizeusedbytes(usedChunkSize + usedWalSegmentSize);
stats->set_chunksizeleftbytes(leftChunkSize + leftWalSegmentSize);
stats->set_chunksizetrashedbytes(trashedChunkSize);
req->set_allocated_stats(stats);

Expand Down
1 change: 1 addition & 0 deletions src/chunkserver/heartbeat.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct HeartbeatOptions {
uint32_t port;
uint32_t intervalSec;
uint32_t timeout;
bool useChunkFilePoolAsWalPool;
CopysetNodeManager* copysetNodeManager;

std::shared_ptr<LocalFileSystem> fs;
Expand Down
6 changes: 5 additions & 1 deletion src/fs/ext4_filesystem_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,11 @@ int Ext4FileSystemImpl::Write(int fd,
continue;
}
LOG(ERROR) << "IOBuf::pcut_into_file_descriptor failed: "
<< strerror(errno);
<< strerror(errno)
<< ", fd: " << fd
<< ", offset: " << offset
<< ", remainLength: " << remainLength
<< ", length: " << length;
return -errno;
}

Expand Down
11 changes: 4 additions & 7 deletions src/mds/topology/topology_service_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,9 @@ void TopologyServiceManager::RegistChunkServer(

std::string hostIp = request->hostip();
uint32_t port = request->port();
ChunkServerStat stat;
bool useChunkFilePoolAsWalPool = false;
uint32_t useChunkFilePoolAsWalPoolReserve;
bool useChunkFilepool = false;
if (request->has_chunkfilepoolsize()) {
stat.chunkFilepoolSize = request->chunkfilepoolsize();
}
if (request->has_usechunkfilepoolaswalpool()) {
useChunkFilepool = true;
useChunkFilePoolAsWalPool = request->usechunkfilepoolaswalpool();
Expand Down Expand Up @@ -135,7 +131,7 @@ void TopologyServiceManager::RegistChunkServer(
response->set_statuscode(kTopoErrCodeSuccess);
response->set_chunkserverid(cs.GetId());
response->set_token(cs.GetToken());
topoStat_->UpdateChunkServerStat(cs.GetId(), stat);

topologyChunkAllocator_->UpdateChunkFilePoolAllocConfig(
useChunkFilepool, useChunkFilePoolAsWalPool,
useChunkFilePoolAsWalPoolReserve);
Expand Down Expand Up @@ -172,8 +168,6 @@ void TopologyServiceManager::RegistChunkServer(
response->set_statuscode(kTopoErrCodeSuccess);
response->set_chunkserverid(cs.GetId());
response->set_token(cs.GetToken());
topoStat_->UpdateChunkServerStat(cs.GetId(),
stat);
topologyChunkAllocator_->UpdateChunkFilePoolAllocConfig(
useChunkFilepool, useChunkFilePoolAsWalPool,
useChunkFilePoolAsWalPoolReserve);
Expand Down Expand Up @@ -253,6 +247,9 @@ void TopologyServiceManager::RegistChunkServer(
response->set_token(chunkserver.GetToken());
ChunkServerStat stat;
stat.chunkFilepoolSize = request->chunkfilepoolsize();
stat.chunkSizeUsedBytes = 0;
stat.chunkSizeLeftBytes = stat.chunkFilepoolSize;
stat.chunkSizeTrashedBytes = 0;
topoStat_->UpdateChunkServerStat(chunkserver.GetId(), stat);
topologyChunkAllocator_->UpdateChunkFilePoolAllocConfig(
useChunkFilepool, useChunkFilePoolAsWalPool,
Expand Down