Skip to content

Commit

Permalink
Add a layer of logic to check whether the hard disk is executed (Open…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mixficsol authored Jul 27, 2023
1 parent 2de127f commit e7dfcd0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/pika_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <ifaddrs.h>
#include <netinet/in.h>
#include <sys/resource.h>
#include <sys/statvfs.h>
#include <algorithm>
#include <ctime>
#include <fstream>
Expand Down Expand Up @@ -1519,10 +1520,10 @@ void PikaServer::AutoKeepAliveRSync() {
}

void PikaServer::AutoResumeDB() {
struct statfs disk_info;
int ret = statfs(g_pika_conf->db_path().c_str(), &disk_info);
struct statvfs disk_info;
int ret = statvfs(g_pika_conf->db_path().c_str(), &disk_info);
if (ret == -1) {
LOG(WARNING) << "statfs error: " << strerror(errno);
LOG(WARNING) << "statvfs error: " << strerror(errno);
return;
}

Expand All @@ -1536,7 +1537,7 @@ void PikaServer::AutoResumeDB() {
struct timeval now;
gettimeofday(&now, nullptr);
// first check or time interval between now and last check is larger than variable "interval"
if (last_check_resume_time_.tv_sec == 0 || now.tv_sec - last_check_resume_time_.tv_sec >= interval) {
if (disk_use_ratio > min_check_resume_ratio && (last_check_resume_time_.tv_sec == 0 || now.tv_sec - last_check_resume_time_.tv_sec >= interval)) {
gettimeofday(&last_check_resume_time_, nullptr);
if (disk_use_ratio < min_check_resume_ratio || free_size < least_free_size){
return;
Expand Down

0 comments on commit e7dfcd0

Please sign in to comment.