[Enhancement] Staros v3.3 rc3 and brpc glog update (#48949)
Signed-off-by: stdpain <drfeng08@gmail.com> Signed-off-by: Kevin Xiaohua Cai <caixiaohua@starrocks.com> Co-authored-by: stdpain <drfeng08@gmail.com>
This commit is contained in:
parent
2c7cf6ad99
commit
47e85eeef9
|
|
@ -158,7 +158,7 @@ static void dontdump_unused_pages() {
|
|||
start_dump = true;
|
||||
}
|
||||
|
||||
static void failure_writer(const char* data, int size) {
|
||||
static void failure_writer(const char* data, size_t size) {
|
||||
dump_trace_info();
|
||||
[[maybe_unused]] auto wt = write(STDERR_FILENO, data, size);
|
||||
|
||||
|
|
@ -278,7 +278,7 @@ bool init_glog(const char* basename, bool install_signal_handler) {
|
|||
|
||||
if (config::dump_trace_info) {
|
||||
google::InstallFailureWriter(failure_writer);
|
||||
google::InstallFailureFunction(failure_function);
|
||||
google::InstallFailureFunction((google::logging_fail_func_t)failure_function);
|
||||
}
|
||||
|
||||
logging_initialized = true;
|
||||
|
|
|
|||
|
|
@ -217,9 +217,7 @@ void start_be(const std::vector<StorePath>& paths, bool as_cn) {
|
|||
brpc::FLAGS_max_body_size = config::brpc_max_body_size;
|
||||
|
||||
// Configure keepalive.
|
||||
#ifdef WITH_BRPC_KEEPALIVE
|
||||
brpc::FLAGS_socket_keepalive = config::brpc_socket_keepalive;
|
||||
#endif
|
||||
|
||||
brpc::FLAGS_socket_max_unwritten_bytes = config::brpc_socket_max_unwritten_bytes;
|
||||
auto brpc_server = std::make_unique<brpc::Server>();
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@
|
|||
#include <fmt/format.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include "common/config.h"
|
||||
#include "gutil/strings/join.h"
|
||||
#include "gutil/strings/split.h"
|
||||
|
|
@ -31,22 +29,21 @@
|
|||
#include "runtime/current_thread.h"
|
||||
#include "util/time.h"
|
||||
|
||||
namespace google::glog_internal_namespace_ {
|
||||
void DumpStackTraceToString(std::string* stacktrace);
|
||||
} // namespace google::glog_internal_namespace_
|
||||
namespace google {
|
||||
std::string GetStackTrace();
|
||||
}
|
||||
|
||||
// import hidden stack trace functions from glog
|
||||
namespace google {
|
||||
namespace google::glog_internal_namespace_ {
|
||||
enum class SymbolizeOptions { kNone = 0, kNoLineNumbers = 1 };
|
||||
int GetStackTrace(void** result, int max_depth, int skip_count);
|
||||
bool Symbolize(void* pc, char* out, int out_size);
|
||||
} // namespace google
|
||||
bool Symbolize(void* pc, char* out, unsigned long out_size, SymbolizeOptions options = SymbolizeOptions::kNone);
|
||||
} // namespace google::glog_internal_namespace_
|
||||
|
||||
namespace starrocks {
|
||||
|
||||
std::string get_stack_trace() {
|
||||
std::string s;
|
||||
google::glog_internal_namespace_::DumpStackTraceToString(&s);
|
||||
return s;
|
||||
return google::GetStackTrace();
|
||||
}
|
||||
|
||||
struct StackTraceTask {
|
||||
|
|
@ -59,7 +56,7 @@ struct StackTraceTask {
|
|||
for (int i = 0; i < depth; ++i) {
|
||||
char line[2048];
|
||||
char buf[1024];
|
||||
if (google::Symbolize(addrs[i], buf, sizeof(buf))) {
|
||||
if (google::glog_internal_namespace_::Symbolize(addrs[i], buf, sizeof(buf))) {
|
||||
snprintf(line, 2048, " %16p %s\n", addrs[i], buf);
|
||||
} else {
|
||||
snprintf(line, 2048, " %16p (unknown)\n", addrs[i]);
|
||||
|
|
@ -93,7 +90,7 @@ struct StackTraceTaskHash {
|
|||
|
||||
void get_stack_trace_sighandler(int signum, siginfo_t* siginfo, void* ucontext) {
|
||||
auto task = reinterpret_cast<StackTraceTask*>(siginfo->si_value.sival_ptr);
|
||||
task->depth = google::GetStackTrace(task->addrs, StackTraceTask::kMaxStackDepth, 2);
|
||||
task->depth = google::glog_internal_namespace_::GetStackTrace(task->addrs, StackTraceTask::kMaxStackDepth, 2);
|
||||
task->done = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
3
build.sh
3
build.sh
|
|
@ -153,7 +153,6 @@ WITH_GCOV=OFF
|
|||
WITH_BENCH=OFF
|
||||
WITH_CLANG_TIDY=OFF
|
||||
WITH_STARCACHE=ON
|
||||
WITH_BRPC_KEEPALIVE=OFF
|
||||
USE_STAROS=OFF
|
||||
BUILD_JAVA_EXT=ON
|
||||
OUTPUT_COMPILE_TIME=OFF
|
||||
|
|
@ -244,7 +243,6 @@ else
|
|||
--with-clang-tidy) WITH_CLANG_TIDY=ON; shift ;;
|
||||
--without-java-ext) BUILD_JAVA_EXT=OFF; shift ;;
|
||||
--without-starcache) WITH_STARCACHE=OFF; shift ;;
|
||||
--with-brpc-keepalive) WITH_BRPC_KEEPALIVE=ON; shift ;;
|
||||
--output-compile-time) OUTPUT_COMPILE_TIME=ON; shift ;;
|
||||
--with-tenann) WITH_TENANN=ON; shift ;;
|
||||
-h) HELP=1; shift ;;
|
||||
|
|
@ -383,7 +381,6 @@ if [ ${BUILD_BE} -eq 1 ] ; then
|
|||
-DWITH_CLANG_TIDY=${WITH_CLANG_TIDY} \
|
||||
-DWITH_COMPRESS=${WITH_COMPRESS} \
|
||||
-DWITH_STARCACHE=${WITH_STARCACHE} \
|
||||
-DWITH_BRPC_KEEPALIVE=${WITH_BRPC_KEEPALIVE} \
|
||||
-DUSE_STAROS=${USE_STAROS} \
|
||||
-DENABLE_FAULT_INJECTION=${ENABLE_FAULT_INJECTION} \
|
||||
-DWITH_TENANN=${WITH_TENANN} \
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ ARG predownload_thirdparty=false
|
|||
ARG thirdparty_url=https://cdn-thirdparty.starrocks.com/starrocks-thirdparty-main-20240411.tar
|
||||
ARG commit_id
|
||||
# check thirdparty/starlet-artifacts-version.sh, to get the right tag
|
||||
ARG starlet_tag=v3.3-rc2
|
||||
ARG starlet_tag=v3.3-rc3
|
||||
# build for which linux distro: centos7|ubuntu
|
||||
ARG distro=ubuntu
|
||||
# Token to access artifacts in private github repositories.
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ under the License.
|
|||
<iceberg.version>1.5.0</iceberg.version>
|
||||
<paimon.version>0.8.1</paimon.version>
|
||||
<delta-kernel.version>4.0.0rc1</delta-kernel.version>
|
||||
<staros.version>3.3-rc2</staros.version>
|
||||
<staros.version>3.3-rc3</staros.version>
|
||||
<python>python</python>
|
||||
</properties>
|
||||
|
||||
|
|
|
|||
|
|
@ -368,13 +368,8 @@ build_glog() {
|
|||
check_if_source_exist $GLOG_SOURCE
|
||||
cd $TP_SOURCE_DIR/$GLOG_SOURCE
|
||||
|
||||
# to generate config.guess and config.sub to support aarch64
|
||||
rm -rf config.*
|
||||
autoreconf -i
|
||||
$CMAKE_CMD -G "${CMAKE_GENERATOR}" -DCMAKE_INSTALL_PREFIX=$TP_INSTALL_DIR -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_LIBDIR=lib
|
||||
|
||||
LDFLAGS="-L${TP_LIB_DIR}" \
|
||||
CPPFLAGS="-I${TP_INCLUDE_DIR}" \
|
||||
./configure --prefix=$TP_INSTALL_DIR --enable-frame-pointers --disable-shared --enable-static
|
||||
make -j$PARALLEL
|
||||
make install
|
||||
}
|
||||
|
|
@ -560,7 +555,7 @@ build_brpc() {
|
|||
cd $TP_SOURCE_DIR/$BRPC_SOURCE
|
||||
CMAKE_GENERATOR="Unix Makefiles"
|
||||
BUILD_SYSTEM='make'
|
||||
./config_brpc.sh --headers="$TP_INSTALL_DIR/include /usr/include" --libs="$TP_INSTALL_DIR/bin $TP_INSTALL_DIR/lib /usr/lib" --with-glog
|
||||
PATH=$PATH:$TP_INSTALL_DIR/bin/ ./config_brpc.sh --headers="$TP_INSTALL_DIR/include" --libs="$TP_INSTALL_DIR/bin $TP_INSTALL_DIR/lib" --with-glog --with-thrift
|
||||
make -j$PARALLEL
|
||||
cp -rf output/* ${TP_INSTALL_DIR}/
|
||||
if [ -f $TP_INSTALL_DIR/lib/libbrpc.a ]; then
|
||||
|
|
@ -747,6 +742,7 @@ build_s2() {
|
|||
$CMAKE_CMD -G "${CMAKE_GENERATOR}" -DBUILD_SHARED_LIBS=0 -DCMAKE_INSTALL_PREFIX=$TP_INSTALL_DIR \
|
||||
-DCMAKE_INCLUDE_PATH="$TP_INSTALL_DIR/include" \
|
||||
-DBUILD_SHARED_LIBS=OFF \
|
||||
-DCMAKE_CXX_STANDARD="17" \
|
||||
-DGFLAGS_ROOT_DIR="$TP_INSTALL_DIR/include" \
|
||||
-DWITH_GFLAGS=ON \
|
||||
-DGLOG_ROOT_DIR="$TP_INSTALL_DIR/include" \
|
||||
|
|
|
|||
|
|
@ -250,6 +250,10 @@ if [ ! -f $PATCHED_MARK ] && [ $GLOG_SOURCE == "glog-0.4.0" ]; then
|
|||
patch -p1 < $TP_PATCH_DIR/glog-0.4.0-remove-unwind-dependency.patch
|
||||
touch $PATCHED_MARK
|
||||
fi
|
||||
if [ ! -f $PATCHED_MARK ] && [ $GLOG_SOURCE == "glog-0.7.1" ]; then
|
||||
patch -p1 < $TP_PATCH_DIR/glog-0.7.1.patch
|
||||
touch $PATCHED_MARK
|
||||
fi
|
||||
cd -
|
||||
echo "Finished patching $GLOG_SOURCE"
|
||||
|
||||
|
|
@ -305,6 +309,10 @@ if [ ! -f $PATCHED_MARK ] && [ $BRPC_SOURCE == "brpc-1.3.0" ]; then
|
|||
patch -p1 < $TP_PATCH_DIR/brpc-1.3.0-2479.patch
|
||||
touch $PATCHED_MARK
|
||||
fi
|
||||
if [ ! -f $PATCHED_MARK ] && [ $BRPC_SOURCE == "brpc-1.9.0" ]; then
|
||||
patch < $TP_PATCH_DIR/brpc-1.9.0.patch
|
||||
touch $PATCHED_MARK
|
||||
fi
|
||||
cd -
|
||||
echo "Finished patching $BRPC_SOURCE"
|
||||
|
||||
|
|
@ -314,6 +322,7 @@ if [ ! -f $PATCHED_MARK ]; then
|
|||
patch -p1 < $TP_PATCH_DIR/s2geometry-0.9.0.patch
|
||||
# replace uint64 with uint64_t to make compiler happy
|
||||
patch -p0 < $TP_PATCH_DIR/s2geometry-0.9.0-uint64.patch
|
||||
patch -p1 < $TP_PATCH_DIR/s2geometry-0.9.0-cxx17.patch
|
||||
touch $PATCHED_MARK
|
||||
fi
|
||||
cd -
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
diff --git a/config_brpc.sh b/config_brpc.sh
|
||||
index ddaa6daa..2269587a 100755
|
||||
--- a/config_brpc.sh
|
||||
+++ b/config_brpc.sh
|
||||
@@ -341,7 +341,7 @@ if [ "$PROTOBUF_VERSION" -ge 4022000 ]; then
|
||||
done
|
||||
CXXFLAGS="-std=c++17"
|
||||
else
|
||||
- CXXFLAGS="-std=c++0x"
|
||||
+ CXXFLAGS="-std=c++17"
|
||||
fi
|
||||
|
||||
LEVELDB_HDR=$(find_dir_of_header_or_die leveldb/db.h)
|
||||
|
|
@ -0,0 +1,334 @@
|
|||
diff --git a/src/flags.cc b/src/flags.cc
|
||||
index c4c2aa4..7329c80 100644
|
||||
--- a/src/flags.cc
|
||||
+++ b/src/flags.cc
|
||||
@@ -137,6 +137,10 @@ GLOG_DEFINE_uint32(max_log_size, 1800,
|
||||
GLOG_DEFINE_bool(stop_logging_if_full_disk, false,
|
||||
"Stop attempting to log to disk if the disk is full.");
|
||||
|
||||
+GLOG_DEFINE_string(log_split_method, "day", "split log by size, day, hour");
|
||||
+
|
||||
+GLOG_DEFINE_int32(log_filenum_quota, 10, "max log file num in log dir");
|
||||
+
|
||||
GLOG_DEFINE_string(log_backtrace_at, "",
|
||||
"Emit a backtrace when logging at file:linenum.");
|
||||
|
||||
diff --git a/src/glog/flags.h b/src/glog/flags.h
|
||||
index cb542b9..31d5e6e 100644
|
||||
--- a/src/glog/flags.h
|
||||
+++ b/src/glog/flags.h
|
||||
@@ -182,6 +182,10 @@ DECLARE_string(logmailer);
|
||||
|
||||
DECLARE_bool(symbolize_stacktrace);
|
||||
|
||||
+DECLARE_int32(log_filenum_quota);
|
||||
+
|
||||
+DECLARE_string(log_split_method);
|
||||
+
|
||||
#pragma pop_macro("DECLARE_VARIABLE")
|
||||
#pragma pop_macro("DECLARE_bool")
|
||||
#pragma pop_macro("DECLARE_string")
|
||||
diff --git a/src/glog/logging.h b/src/glog/logging.h
|
||||
index 88d793f..8b90782 100644
|
||||
--- a/src/glog/logging.h
|
||||
+++ b/src/glog/logging.h
|
||||
@@ -52,6 +52,10 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
+#ifndef GLOG_USE_GLOG_EXPORT
|
||||
+#define GLOG_USE_GLOG_EXPORT
|
||||
+#endif
|
||||
+
|
||||
#if defined(GLOG_USE_GLOG_EXPORT)
|
||||
# include "glog/export.h"
|
||||
#endif
|
||||
diff --git a/src/logging.cc b/src/logging.cc
|
||||
index fc63995..16b2cb1 100644
|
||||
--- a/src/logging.cc
|
||||
+++ b/src/logging.cc
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "glog/logging.h"
|
||||
|
||||
+#include <list>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
@@ -443,6 +444,14 @@ class PrefixFormatter {
|
||||
|
||||
std::unique_ptr<PrefixFormatter> g_prefix_formatter;
|
||||
|
||||
+typedef struct filetime {
|
||||
+ std::string name;
|
||||
+ time_t time;
|
||||
+ bool operator < (const struct filetime& o) const {
|
||||
+ return o.time > time;
|
||||
+ }
|
||||
+}Filetime;
|
||||
+
|
||||
// Encapsulates all file-system related state
|
||||
class LogFileObject : public base::Logger {
|
||||
public:
|
||||
@@ -474,6 +483,8 @@ class LogFileObject : public base::Logger {
|
||||
// acquiring lock_.
|
||||
void FlushUnlocked(const std::chrono::system_clock::time_point& now);
|
||||
|
||||
+ void CheckFileNumQuota();
|
||||
+
|
||||
private:
|
||||
static const uint32 kRolloverAttemptFrequency = 0x20;
|
||||
|
||||
@@ -496,6 +507,10 @@ class LogFileObject : public base::Logger {
|
||||
// optional argument time_pid_string
|
||||
// REQUIRES: lock_ is held
|
||||
bool CreateLogfile(const string& time_pid_string);
|
||||
+
|
||||
+ std::list<Filetime> file_list_;
|
||||
+ bool inited_;
|
||||
+ struct ::tm tm_time_;
|
||||
};
|
||||
|
||||
// Encapsulate all log cleaner related states
|
||||
@@ -707,7 +722,7 @@ inline void LogDestination::FlushLogFiles(int min_severity) {
|
||||
// all this stuff.
|
||||
std::lock_guard<std::mutex> l{log_mutex};
|
||||
for (int i = min_severity; i < NUM_SEVERITIES; i++) {
|
||||
- LogDestination* log = log_destination(static_cast<LogSeverity>(i));
|
||||
+ LogDestination* log = log_destinations_[i].get();
|
||||
if (log != nullptr) {
|
||||
log->logger_->Flush();
|
||||
}
|
||||
@@ -904,8 +919,12 @@ inline void LogDestination::LogToAllLogfiles(
|
||||
ColoredWriteToStderr(severity, message, len);
|
||||
} else {
|
||||
for (int i = severity; i >= 0; --i) {
|
||||
- LogDestination::MaybeLogToLogfile(static_cast<LogSeverity>(i), timestamp,
|
||||
- message, len);
|
||||
+ if (severity >= 1) {
|
||||
+ LogDestination::MaybeLogToLogfile(static_cast<LogSeverity>(1), timestamp, message, len);
|
||||
+ LogDestination::MaybeLogToLogfile(static_cast<LogSeverity>(0), timestamp, message, len);
|
||||
+ } else if (severity == 0) {
|
||||
+ LogDestination::MaybeLogToLogfile(static_cast<LogSeverity>(0), timestamp, message, len);
|
||||
+ } else {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -997,7 +1016,8 @@ LogFileObject::LogFileObject(LogSeverity severity, const char* base_filename)
|
||||
filename_extension_(),
|
||||
severity_(severity),
|
||||
rollover_attempt_(kRolloverAttemptFrequency - 1),
|
||||
- start_time_(std::chrono::system_clock::now()) {}
|
||||
+ start_time_(std::chrono::system_clock::now()),
|
||||
+ inited_(false) {}
|
||||
|
||||
LogFileObject::~LogFileObject() {
|
||||
std::lock_guard<std::mutex> l{mutex_};
|
||||
@@ -1058,14 +1078,9 @@ bool LogFileObject::CreateLogfile(const string& time_pid_string) {
|
||||
}
|
||||
string_filename += filename_extension_;
|
||||
const char* filename = string_filename.c_str();
|
||||
- // only write to files, create if non-existant.
|
||||
- int flags = O_WRONLY | O_CREAT;
|
||||
- if (FLAGS_timestamp_in_logfile_name) {
|
||||
- // demand that the file is unique for our timestamp (fail if it exists).
|
||||
- flags = flags | O_EXCL;
|
||||
- }
|
||||
- FileDescriptor fd{
|
||||
- open(filename, flags, static_cast<mode_t>(FLAGS_logfile_mode))};
|
||||
+ int fdh = open(filename, O_WRONLY | O_CREAT /* | O_EXCL */ | O_APPEND, 0664);
|
||||
+ FileDescriptor fd{fdh};
|
||||
+
|
||||
if (!fd) return false;
|
||||
#ifdef HAVE_FCNTL
|
||||
// Mark the file close-on-exec. We don't really care if this fails
|
||||
@@ -1112,6 +1127,9 @@ bool LogFileObject::CreateLogfile(const string& time_pid_string) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+ Filetime ft;
|
||||
+ ft.name = string_filename;
|
||||
+ file_list_.push_back(ft);
|
||||
// We try to create a symlink called <program_name>.<severity>,
|
||||
// which is easier to use. (Every time we create a new logfile,
|
||||
// we destroy the old symlink and create a new one, so it always
|
||||
@@ -1155,6 +1173,55 @@ bool LogFileObject::CreateLogfile(const string& time_pid_string) {
|
||||
return true; // Everything worked
|
||||
}
|
||||
|
||||
+void LogFileObject::CheckFileNumQuota() {
|
||||
+ struct dirent *entry;
|
||||
+ DIR *dp;
|
||||
+ const vector<string> & log_dirs = GetLoggingDirectories();
|
||||
+ if (log_dirs.size() < 1) return;
|
||||
+
|
||||
+ //fprintf(stderr, "log dir: %s\n", log_dirs[0].c_str());
|
||||
+ // list file in log dir
|
||||
+
|
||||
+ dp = opendir(log_dirs[0].c_str());
|
||||
+ if (dp == NULL) {
|
||||
+ fprintf(stderr, "open log dir %s fail\n", log_dirs[0].c_str());
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ file_list_.clear();
|
||||
+ while ((entry = readdir(dp)) != NULL) {
|
||||
+ if (DT_DIR == entry->d_type ||
|
||||
+ DT_LNK == entry->d_type) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ std::string filename = std::string(entry->d_name);
|
||||
+ //fprintf(stderr, "filename: %s\n", filename.c_str());
|
||||
+ if (filename.find(symlink_basename_ + '.' + LogSeverityNames[severity_]) == 0) {
|
||||
+ std::string filepath = log_dirs[0] + "/" + filename;
|
||||
+ struct stat fstat;
|
||||
+ if (::stat(filepath.c_str(), &fstat) < 0) {
|
||||
+ fprintf(stderr, "state %s fail\n", filepath.c_str());
|
||||
+ closedir(dp);
|
||||
+ return;
|
||||
+ }
|
||||
+ //fprintf(stderr, "filepath: %s\n", filepath.c_str());
|
||||
+ Filetime file_time;
|
||||
+ file_time.time = fstat.st_mtime;
|
||||
+ file_time.name = filepath;
|
||||
+ file_list_.push_back(file_time);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ closedir(dp);
|
||||
+ file_list_.sort();
|
||||
+
|
||||
+ while (FLAGS_log_filenum_quota > 0 && file_list_.size() >= FLAGS_log_filenum_quota) {
|
||||
+ // fprintf(stderr, "delete %s\n", file_list_.front().name.c_str());
|
||||
+ unlink(file_list_.front().name.c_str());
|
||||
+ file_list_.pop_front();
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void LogFileObject::Write(
|
||||
bool force_flush, const std::chrono::system_clock::time_point& timestamp,
|
||||
const char* message, size_t message_len) {
|
||||
@@ -1171,16 +1238,58 @@ void LogFileObject::Write(
|
||||
filename_extension_);
|
||||
}
|
||||
};
|
||||
+ std::time_t t = std::chrono::system_clock::to_time_t(timestamp);
|
||||
|
||||
// Remove old logs
|
||||
ScopedExit<decltype(cleanupLogs)> cleanupAtEnd{cleanupLogs};
|
||||
|
||||
- if (file_length_ >> 20U >= MaxLogSize() || PidHasChanged()) {
|
||||
+ struct ::tm tm_time;
|
||||
+ bool is_split = false;
|
||||
+ if ("day" == FLAGS_log_split_method) {
|
||||
+ localtime_r(&t, &tm_time);
|
||||
+ if (tm_time.tm_year != tm_time_.tm_year
|
||||
+ || tm_time.tm_mon != tm_time_.tm_mon
|
||||
+ || tm_time.tm_mday != tm_time_.tm_mday) {
|
||||
+ is_split = true;
|
||||
+ }
|
||||
+ } else if ("hour" == FLAGS_log_split_method) {
|
||||
+ localtime_r(&t, &tm_time);
|
||||
+ if (tm_time.tm_year != tm_time_.tm_year
|
||||
+ || tm_time.tm_mon != tm_time_.tm_mon
|
||||
+ || tm_time.tm_mday != tm_time_.tm_mday
|
||||
+ || tm_time.tm_hour != tm_time_.tm_hour) {
|
||||
+ is_split = true;
|
||||
+ }
|
||||
+ } else if (static_cast<int>(file_length_ >> 20) >= MaxLogSize()) {
|
||||
+ // PidHasChanged()) {
|
||||
+ is_split = true;
|
||||
+ }
|
||||
+
|
||||
+ if (is_split) {
|
||||
file_ = nullptr;
|
||||
file_length_ = bytes_since_flush_ = dropped_mem_length_ = 0;
|
||||
rollover_attempt_ = kRolloverAttemptFrequency - 1;
|
||||
}
|
||||
|
||||
+ if ((file_ == NULL) && (!inited_) && (FLAGS_log_split_method == "size")) {
|
||||
+ CheckFileNumQuota();
|
||||
+ const char* filename = file_list_.back().name.c_str();
|
||||
+ int fd = open(filename, O_WRONLY | O_CREAT /* | O_EXCL */ | O_APPEND, 0664);
|
||||
+ if (fd != -1) {
|
||||
+#ifdef HAVE_FCNTL
|
||||
+ // Mark the file close-on-exec. We don't really care if this fails
|
||||
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
+#endif
|
||||
+ file_.reset(fopen(filename, "a+"));
|
||||
+ if (file_ == NULL) { // Man, we're screwed!, try to create new log file
|
||||
+ close(fd);
|
||||
+ }
|
||||
+ fseek(file_.get(), 0, SEEK_END);
|
||||
+ file_length_ = bytes_since_flush_ = ftell(file_.get());
|
||||
+ inited_ = true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
// If there's no destination file, make one before outputting
|
||||
if (file_ == nullptr) {
|
||||
// Try to rollover the log file every 32 log messages. The only time
|
||||
@@ -1190,21 +1299,35 @@ void LogFileObject::Write(
|
||||
rollover_attempt_ = 0;
|
||||
|
||||
struct ::tm tm_time;
|
||||
- std::time_t t = std::chrono::system_clock::to_time_t(timestamp);
|
||||
|
||||
- if (FLAGS_log_utc_time) {
|
||||
- gmtime_r(&t, &tm_time);
|
||||
+ if (!inited_) {
|
||||
+ CheckFileNumQuota();
|
||||
+ inited_ = true;
|
||||
} else {
|
||||
- localtime_r(&t, &tm_time);
|
||||
+ while (FLAGS_log_filenum_quota > 0 && file_list_.size() >= FLAGS_log_filenum_quota) {
|
||||
+ unlink(file_list_.front().name.c_str());
|
||||
+ file_list_.pop_front();
|
||||
+ }
|
||||
}
|
||||
+ localtime_r(&t, &tm_time);
|
||||
|
||||
// The logfile's filename will have the date/time & pid in it
|
||||
ostringstream time_pid_stream;
|
||||
time_pid_stream.fill('0');
|
||||
- time_pid_stream << 1900 + tm_time.tm_year << setw(2) << 1 + tm_time.tm_mon
|
||||
- << setw(2) << tm_time.tm_mday << '-' << setw(2)
|
||||
- << tm_time.tm_hour << setw(2) << tm_time.tm_min << setw(2)
|
||||
- << tm_time.tm_sec << '.' << GetMainThreadPid();
|
||||
+ time_pid_stream << 1900 + tm_time.tm_year
|
||||
+ << setw(2) << 1 + tm_time.tm_mon
|
||||
+ << setw(2) << tm_time.tm_mday;
|
||||
+
|
||||
+ if ("hour" == FLAGS_log_split_method) {
|
||||
+ time_pid_stream << setw(2) << tm_time.tm_hour;
|
||||
+ } else if ("day" != FLAGS_log_split_method) {
|
||||
+ time_pid_stream << '-'
|
||||
+ << setw(2) << tm_time.tm_hour
|
||||
+ << setw(2) << tm_time.tm_min
|
||||
+ << setw(2) << tm_time.tm_sec;
|
||||
+ }
|
||||
+
|
||||
+ tm_time_ = tm_time;
|
||||
const string& time_pid_string = time_pid_stream.str();
|
||||
|
||||
if (base_filename_selected_) {
|
||||
@@ -1238,8 +1361,8 @@ void LogFileObject::Write(
|
||||
// deadlock. Simply use a name like invalid-user.
|
||||
if (uidname.empty()) uidname = "invalid-user";
|
||||
|
||||
- stripped_filename = stripped_filename + '.' + hostname + '.' + uidname +
|
||||
- ".log." + LogSeverityNames[severity_] + '.';
|
||||
+ stripped_filename = stripped_filename + "." + LogSeverityNames[severity_] + ".log.";
|
||||
+
|
||||
// We're going to (potentially) try to put logs in several different dirs
|
||||
const vector<string>& log_dirs = GetLoggingDirectories();
|
||||
|
||||
@@ -1263,7 +1386,7 @@ void LogFileObject::Write(
|
||||
}
|
||||
|
||||
// Write a header message into the log file
|
||||
- if (FLAGS_log_file_header) {
|
||||
+ if (false) {
|
||||
ostringstream file_header_stream;
|
||||
file_header_stream.fill('0');
|
||||
file_header_stream << "Log file created at: " << 1900 + tm_time.tm_year
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
--- a/CMakeLists.txt 2024-07-12 11:56:13.164623272 +0000
|
||||
+++ b/CMakeLists.txt 2024-07-12 11:55:30.791316892 +0000
|
||||
@@ -13,7 +13,7 @@
|
||||
set(CMAKE_MACOSX_RPATH TRUE)
|
||||
endif()
|
||||
|
||||
-set(CMAKE_CXX_STANDARD 11)
|
||||
+set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
# No compiler-specific extensions, i.e. -std=c++11, not -std=gnu++11.
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
|
@ -9,4 +9,4 @@
|
|||
# https://hub.docker.com/r/starrocks/starlet-artifacts-centos7/tags
|
||||
#
|
||||
# Update the following tag when STARLET releases a new version.
|
||||
export STARLET_ARTIFACTS_TAG=v3.3-rc2
|
||||
export STARLET_ARTIFACTS_TAG=v3.3-rc3
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ JINDOSDK_SOURCE="jindosdk-4.6.8-linux-el7-aarch64"
|
|||
JINDOSDK_MD5SUM="27a4e2cd9a403c6e21079a866287d88b"
|
||||
|
||||
# starcache
|
||||
STARCACHE_DOWNLOAD="https://cdn-thirdparty.starrocks.com/starcache/v3.3.2-rc01/starcache-centos7_arm64.tar.gz"
|
||||
STARCACHE_DOWNLOAD="https://cdn-thirdparty.starrocks.com/starcache/v3.3.3/starcache-centos7_arm64.tar.gz"
|
||||
STARCACHE_NAME="starcache.tar.gz"
|
||||
STARCACHE_SOURCE="starcache"
|
||||
STARCACHE_MD5SUM="8d4316b77e6da4758f044b28a5590a14"
|
||||
STARCACHE_MD5SUM="545ca196d5591c9e6925788ba363c313"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#####################################################
|
||||
|
||||
# starcache
|
||||
STARCACHE_DOWNLOAD="https://cdn-thirdparty.starrocks.com/starcache/v3.3.2-rc01/starcache-ubuntu22_arm64.tar.gz"
|
||||
STARCACHE_DOWNLOAD="https://cdn-thirdparty.starrocks.com/starcache/v3.3.3/starcache-ubuntu22_arm64.tar.gz"
|
||||
STARCACHE_NAME="starcache.tar.gz"
|
||||
STARCACHE_SOURCE="starcache"
|
||||
STARCACHE_MD5SUM="ecc6a8c39ba386e28c4c228c613d9ccf"
|
||||
STARCACHE_MD5SUM="0752ac974552a1caadd7ab6ce97878f9"
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ JINDOSDK_SOURCE="jindosdk-4.6.8-linux-ubuntu22-x86_64"
|
|||
JINDOSDK_MD5SUM="52236053391091591c2d09684791e810"
|
||||
|
||||
# starcache
|
||||
STARCACHE_DOWNLOAD="https://cdn-thirdparty.starrocks.com/starcache/v3.3.2-rc01/starcache-ubuntu22_amd64.tar.gz"
|
||||
STARCACHE_DOWNLOAD="https://cdn-thirdparty.starrocks.com/starcache/v3.3.3/starcache-ubuntu22_amd64.tar.gz"
|
||||
STARCACHE_NAME="starcache.tar.gz"
|
||||
STARCACHE_SOURCE="starcache"
|
||||
STARCACHE_MD5SUM="0321cba1451638acf27e78e4d80ffaa8"
|
||||
STARCACHE_MD5SUM="612584eff0018e9632b9031ad546693a"
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ JINDOSDK_SOURCE="jindosdk-4.6.8-linux"
|
|||
JINDOSDK_MD5SUM="5436e4fe39c4dfdc942e41821f1dd8a9"
|
||||
|
||||
# starcache
|
||||
STARCACHE_DOWNLOAD="https://cdn-thirdparty.starrocks.com/starcache/v3.3.2-rc01/starcache-centos7_amd64.tar.gz"
|
||||
STARCACHE_DOWNLOAD="https://cdn-thirdparty.starrocks.com/starcache/v3.3.3/starcache-centos7_amd64.tar.gz"
|
||||
STARCACHE_NAME="starcache.tar.gz"
|
||||
STARCACHE_SOURCE="starcache"
|
||||
STARCACHE_MD5SUM="cbc576a535fd7e06245ad2077b71c69a"
|
||||
STARCACHE_MD5SUM="595d1b5d0c7935e1d1f91bf43059e461"
|
||||
|
|
|
|||
|
|
@ -115,10 +115,10 @@ GFLAGS_SOURCE=gflags-2.2.2
|
|||
GFLAGS_MD5SUM="1a865b93bacfa963201af3f75b7bd64c"
|
||||
|
||||
# glog
|
||||
GLOG_DOWNLOAD="https://github.com/google/glog/archive/v0.4.0.tar.gz"
|
||||
GLOG_NAME=glog-0.4.0.tar.gz
|
||||
GLOG_SOURCE=glog-0.4.0
|
||||
GLOG_MD5SUM="0daea8785e6df922d7887755c3d100d0"
|
||||
GLOG_DOWNLOAD="https://github.com/google/glog/archive/v0.7.1.tar.gz"
|
||||
GLOG_NAME=glog-0.7.1.tar.gz
|
||||
GLOG_SOURCE=glog-0.7.1
|
||||
GLOG_MD5SUM="128e2995cc33d794ff24f785a3060346"
|
||||
|
||||
# gtest
|
||||
GTEST_DOWNLOAD="https://github.com/google/googletest/archive/release-1.10.0.tar.gz"
|
||||
|
|
@ -193,10 +193,10 @@ LEVELDB_SOURCE=leveldb-1.20
|
|||
LEVELDB_MD5SUM="298b5bddf12c675d6345784261302252"
|
||||
|
||||
# brpc
|
||||
BRPC_DOWNLOAD="https://github.com/apache/brpc/archive/refs/tags/1.3.0.tar.gz"
|
||||
BRPC_NAME=brpc-1.3.0.tar.gz
|
||||
BRPC_SOURCE=brpc-1.3.0
|
||||
BRPC_MD5SUM="9470f1a77ec153e82cd8a25dc2148e47"
|
||||
BRPC_DOWNLOAD="https://github.com/apache/brpc/archive/refs/tags/1.9.0.tar.gz"
|
||||
BRPC_NAME=brpc-1.9.0.tar.gz
|
||||
BRPC_SOURCE=brpc-1.9.0
|
||||
BRPC_MD5SUM="a2b626d96a5b017f2a6701ffa594530c"
|
||||
|
||||
# rocksdb
|
||||
ROCKSDB_DOWNLOAD="https://github.com/facebook/rocksdb/archive/refs/tags/v6.22.1.zip"
|
||||
|
|
|
|||
Loading…
Reference in New Issue