diff --git a/src/Common/StackTrace.cpp b/src/Common/StackTrace.cpp index 812f888b284..3fae1df0bfa 100644 --- a/src/Common/StackTrace.cpp +++ b/src/Common/StackTrace.cpp @@ -417,11 +417,7 @@ void StackTrace::toStringEveryLine(std::function call std::string StackTrace::toString() const { - /// Calculation of stack trace text is extremely slow. - /// We use simple cache because otherwise the server could be overloaded by trash queries. - - static SimpleCache func_cached; - return func_cached(frame_pointers, offset, size); + return toStringStatic(frame_pointers, offset, size); } std::string StackTrace::toString(void ** frame_pointers_, size_t offset, size_t size) @@ -432,6 +428,19 @@ std::string StackTrace::toString(void ** frame_pointers_, size_t offset, size_t for (size_t i = 0; i < size; ++i) frame_pointers_copy[i] = frame_pointers_[i]; - static SimpleCache func_cached; - return func_cached(frame_pointers_copy, offset, size); + return toStringStatic(frame_pointers_copy, offset, size); +} + +std::string StackTrace::toStringStatic(const StackTrace::FramePointers & frame_pointers, size_t offset, size_t size, bool reload) +{ + /// Calculation of stack trace text is extremely slow. + /// We use simple cache because otherwise the server could be overloaded by trash queries. + static SimpleCache func_cached; + /// Reload cached stacktrace instead. + if (reload) + { + func_cached.drop(); + return ""; + } + return func_cached(frame_pointers, offset, size); } diff --git a/src/Common/StackTrace.h b/src/Common/StackTrace.h index 8f8c88c29fe..7e6edabaf0d 100644 --- a/src/Common/StackTrace.h +++ b/src/Common/StackTrace.h @@ -61,6 +61,7 @@ public: std::string toString() const; static std::string toString(void ** frame_pointers, size_t offset, size_t size); + static std::string toStringStatic(const FramePointers & frame_pointers, size_t offset, size_t size, bool reload = false); static void symbolize(const FramePointers & frame_pointers, size_t offset, size_t size, StackTrace::Frames & frames); void toStringEveryLine(std::function callback) const; diff --git a/src/Common/SymbolIndex.cpp b/src/Common/SymbolIndex.cpp index a23184c9c0a..72ce51cccd0 100644 --- a/src/Common/SymbolIndex.cpp +++ b/src/Common/SymbolIndex.cpp @@ -466,7 +466,11 @@ MultiVersion::Version SymbolIndex::instance(bool reload) { static MultiVersion instance(std::unique_ptr(new SymbolIndex)); if (reload) + { instance.set(std::unique_ptr(new SymbolIndex)); + /// Also reload stacktrace cache. + StackTrace::toStringStatic({}, 0, 0, true); + } return instance.get(); }