github-actions[bot] commented on code in PR #26359:
URL: https://github.com/apache/doris/pull/26359#discussion_r1381124352
##########
be/src/olap/wal_manager.cpp:
##########
@@ -69,6 +73,87 @@ Status WalManager::init() {
&_replay_thread);
}
+void WalManager::add_wal_status_queue(int64_t table_id, int64_t wal_id,
WAL_STATUS wal_status) {
Review Comment:
warning: method 'add_wal_status_queue' can be made static
[readability-convert-member-functions-to-static]
be/src/olap/wal_manager.h:58:
```diff
- void add_wal_status_queue(int64_t table_id, int64_t wal_id, WAL_STATUS
wal_status);
+ static void add_wal_status_queue(int64_t table_id, int64_t wal_id,
WAL_STATUS wal_status);
```
##########
be/src/olap/wal_manager.cpp:
##########
@@ -69,6 +73,87 @@
&_replay_thread);
}
+void WalManager::add_wal_status_queue(int64_t table_id, int64_t wal_id,
WAL_STATUS wal_status) {
+ std::lock_guard<std::shared_mutex> wrlock(_wal_status_lock);
+ LOG(INFO) << "add wal queue "
+ << ",table_id:" << table_id << ",wal_id:" << wal_id <<
",status:" << wal_status;
+ auto it = _wal_status_queues.find(table_id);
+ if (it == _wal_status_queues.end()) {
+ std::unordered_map<int64_t, WAL_STATUS> tmp;
+ tmp.emplace(wal_id, wal_status);
+ _wal_status_queues.emplace(table_id, tmp);
+ } else {
+ it->second.emplace(wal_id, wal_status);
+ }
+}
+
+Status WalManager::erase_wal_status_queue(int64_t table_id, int64_t wal_id) {
Review Comment:
warning: method 'erase_wal_status_queue' can be made static
[readability-convert-member-functions-to-static]
be/src/olap/wal_manager.h:59:
```diff
- Status erase_wal_status_queue(int64_t table_id, int64_t wal_id);
+ static Status erase_wal_status_queue(int64_t table_id, int64_t wal_id);
```
##########
be/src/olap/wal_manager.cpp:
##########
@@ -69,6 +73,87 @@
&_replay_thread);
}
+void WalManager::add_wal_status_queue(int64_t table_id, int64_t wal_id,
WAL_STATUS wal_status) {
+ std::lock_guard<std::shared_mutex> wrlock(_wal_status_lock);
+ LOG(INFO) << "add wal queue "
+ << ",table_id:" << table_id << ",wal_id:" << wal_id <<
",status:" << wal_status;
+ auto it = _wal_status_queues.find(table_id);
+ if (it == _wal_status_queues.end()) {
+ std::unordered_map<int64_t, WAL_STATUS> tmp;
+ tmp.emplace(wal_id, wal_status);
+ _wal_status_queues.emplace(table_id, tmp);
+ } else {
+ it->second.emplace(wal_id, wal_status);
+ }
+}
+
+Status WalManager::erase_wal_status_queue(int64_t table_id, int64_t wal_id) {
+ std::lock_guard<std::shared_mutex> wrlock(_wal_status_lock);
+ auto it = _wal_status_queues.find(table_id);
+ LOG(INFO) << "remove wal queue "
+ << ",table_id:" << table_id << ",wal_id:" << wal_id;
+ if (it == _wal_status_queues.end()) {
+ return Status::InternalError("table_id " + std::to_string(table_id) +
+ " not found in wal status queue");
+ } else {
+ it->second.erase(wal_id);
+ if (it->second.empty()) {
+ _wal_status_queues.erase(table_id);
+ }
+ }
+ return Status::OK();
+}
+
+Status WalManager::get_wal_status_queue_size(const PGetWalQueueSizeRequest*
request,
+ PGetWalQueueSizeResponse*
response) {
+ std::lock_guard<std::shared_mutex> wrlock(_wal_status_lock);
+ auto table_id = request->table_id();
+ auto txn_id = request->txn_id();
+ LOG(INFO) << "table_id:" << table_id << ",txn_id:" << txn_id;
+ size_t count = 0;
+ auto it = _wal_status_queues.find(table_id);
+ if (it == _wal_status_queues.end()) {
+ LOG(INFO) << ("table_id " + std::to_string(table_id) + " not found in
wal status queue");
+ } else {
+ for (auto wal_it = it->second.begin(); wal_it != it->second.end();
++wal_it) {
+ if (wal_it->first <= txn_id) {
+ count += 1;
+ }
+ }
+ }
+ response->set_size(count);
+ if (count > 0) {
+ print_wal_status_queue();
+ }
+ return Status::OK();
+}
+
+Status WalManager::get_all_wal_status_queue_size(const
PGetWalQueueSizeRequest* request,
+ PGetWalQueueSizeResponse*
response) {
+ std::lock_guard<std::shared_mutex> wrlock(_wal_status_lock);
+ size_t count = 0;
+ for (auto it = _wal_status_queues.begin(); it != _wal_status_queues.end();
it++) {
+ count += it->second.size();
+ }
+ response->set_size(count);
+ LOG(INFO) << "get all wal size:" << count;
+ if (count > 0) {
+ print_wal_status_queue();
+ }
+ return Status::OK();
+}
+
+void WalManager::print_wal_status_queue() {
Review Comment:
warning: method 'print_wal_status_queue' can be made static
[readability-convert-member-functions-to-static]
be/src/olap/wal_manager.h:60:
```diff
- void print_wal_status_queue();
+ static void print_wal_status_queue();
```
##########
be/src/service/internal_service.cpp:
##########
@@ -1838,4 +1839,34 @@ void
PInternalServiceImpl::group_commit_insert(google::protobuf::RpcController*
}
};
+void PInternalServiceImpl::get_wal_queue_size(google::protobuf::RpcController*
controller,
Review Comment:
warning: method 'get_wal_queue_size' can be made static
[readability-convert-member-functions-to-static]
```suggestion
static void
PInternalServiceImpl::get_wal_queue_size(google::protobuf::RpcController*
controller,
```
##########
be/src/olap/wal_manager.h:
##########
@@ -15,6 +15,8 @@
// specific language governing permissions and limitations
// under the License.
+#include <gen_cpp/PaloInternalService_types.h>
Review Comment:
warning: 'gen_cpp/PaloInternalService_types.h' file not found
[clang-diagnostic-error]
```cpp
#include <gen_cpp/PaloInternalService_types.h>
^
```
##########
be/src/olap/wal_writer.cpp:
##########
@@ -72,4 +72,24 @@ Status WalWriter::append_blocks(const PBlockArray& blocks) {
return Status::OK();
}
+Status WalWriter::append_header(uint32_t version, std::string col_ids) {
Review Comment:
warning: method 'append_header' can be made static
[readability-convert-member-functions-to-static]
```suggestion
static Status WalWriter::append_header(uint32_t version, std::string
col_ids) {
```
##########
be/src/service/internal_service.cpp:
##########
@@ -1838,4 +1839,34 @@
}
};
+void PInternalServiceImpl::get_wal_queue_size(google::protobuf::RpcController*
controller,
+ const PGetWalQueueSizeRequest*
request,
+ PGetWalQueueSizeResponse*
response,
+ google::protobuf::Closure* done)
{
+ bool ret = _light_work_pool.try_offer([this, request, response, done]() {
+ brpc::ClosureGuard closure_guard(done);
+ Status st = Status::OK();
+ st = _exec_env->wal_mgr()->get_wal_status_queue_size(request,
response);
+ response->mutable_status()->set_status_code(st.code());
+ });
+ if (!ret) {
+ offer_failed(response, done, _light_work_pool);
+ }
+}
+
+void
PInternalServiceImpl::get_all_wal_queue_size(google::protobuf::RpcController*
controller,
Review Comment:
warning: method 'get_all_wal_queue_size' can be made static
[readability-convert-member-functions-to-static]
```suggestion
static void
PInternalServiceImpl::get_all_wal_queue_size(google::protobuf::RpcController*
controller,
```
##########
be/src/olap/wal_reader.cpp:
##########
@@ -71,6 +71,25 @@
return Status::OK();
}
+Status WalReader::read_header(uint32_t& version, std::string& col_ids) {
+ size_t bytes_read = 0;
+ uint8_t version_buf[WalWriter::VERSION_SIZE];
+ RETURN_IF_ERROR(
+ file_reader->read_at(_offset, {version_buf,
WalWriter::VERSION_SIZE}, &bytes_read));
+ _offset += WalWriter::VERSION_SIZE;
+ memcpy(&version, version_buf, WalWriter::VERSION_SIZE);
+ uint8_t len_buf[WalWriter::LENGTH_SIZE];
Review Comment:
warning: do not declare C-style arrays, use std::array<> instead
[modernize-avoid-c-arrays]
```cpp
uint8_t len_buf[WalWriter::LENGTH_SIZE];
^
```
##########
be/src/olap/wal_reader.cpp:
##########
@@ -71,6 +71,25 @@ Status WalReader::read_block(PBlock& block) {
return Status::OK();
}
+Status WalReader::read_header(uint32_t& version, std::string& col_ids) {
+ size_t bytes_read = 0;
+ uint8_t version_buf[WalWriter::VERSION_SIZE];
Review Comment:
warning: do not declare C-style arrays, use std::array<> instead
[modernize-avoid-c-arrays]
```cpp
uint8_t version_buf[WalWriter::VERSION_SIZE];
^
```
##########
be/src/olap/wal_manager.cpp:
##########
@@ -249,4 +342,16 @@
return Status::OK();
}
+bool WalManager::is_running() {
Review Comment:
warning: method 'is_running' can be made const
[readability-make-member-function-const]
```suggestion
bool WalManager::is_running() const {
```
be/src/olap/wal_manager.h:62:
```diff
- bool is_running();
+ bool is_running() const;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]