mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-17 13:13:36 +00:00
Refactor
This commit is contained in:
parent
e6a1124ebe
commit
163a416366
@ -431,16 +431,20 @@ std::string StackTrace::toString(void ** frame_pointers_, size_t offset, size_t
|
|||||||
return toStringStatic(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)
|
static SimpleCache<decltype(toStringImpl), &toStringImpl> & cacheInstance()
|
||||||
|
{
|
||||||
|
static SimpleCache<decltype(toStringImpl), &toStringImpl> cache;
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string StackTrace::toStringStatic(const StackTrace::FramePointers & frame_pointers, size_t offset, size_t size)
|
||||||
{
|
{
|
||||||
/// Calculation of stack trace text is extremely slow.
|
/// Calculation of stack trace text is extremely slow.
|
||||||
/// We use simple cache because otherwise the server could be overloaded by trash queries.
|
/// We use simple cache because otherwise the server could be overloaded by trash queries.
|
||||||
static SimpleCache<decltype(toStringImpl), &toStringImpl> func_cached;
|
return cacheInstance()(frame_pointers, offset, size);
|
||||||
/// Reload cached stacktrace instead.
|
}
|
||||||
if (reload)
|
|
||||||
{
|
void StackTrace::dropCache()
|
||||||
func_cached.drop();
|
{
|
||||||
return "";
|
cacheInstance().drop();
|
||||||
}
|
|
||||||
return func_cached(frame_pointers, offset, size);
|
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,8 @@ public:
|
|||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
static std::string toString(void ** frame_pointers, size_t offset, size_t size);
|
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 std::string toStringStatic(const FramePointers & frame_pointers, size_t offset, size_t size);
|
||||||
|
static void dropCache();
|
||||||
static void symbolize(const FramePointers & frame_pointers, size_t offset, size_t size, StackTrace::Frames & frames);
|
static void symbolize(const FramePointers & frame_pointers, size_t offset, size_t size, StackTrace::Frames & frames);
|
||||||
|
|
||||||
void toStringEveryLine(std::function<void(const std::string &)> callback) const;
|
void toStringEveryLine(std::function<void(const std::string &)> callback) const;
|
||||||
|
@ -462,16 +462,22 @@ String SymbolIndex::getBuildIDHex() const
|
|||||||
return build_id_hex;
|
return build_id_hex;
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiVersion<SymbolIndex>::Version SymbolIndex::instance(bool reload)
|
MultiVersion<SymbolIndex> & SymbolIndex::instanceImpl()
|
||||||
{
|
{
|
||||||
static MultiVersion<SymbolIndex> instance(std::unique_ptr<SymbolIndex>(new SymbolIndex));
|
static MultiVersion<SymbolIndex> instance(std::unique_ptr<SymbolIndex>(new SymbolIndex));
|
||||||
if (reload)
|
return instance;
|
||||||
{
|
}
|
||||||
instance.set(std::unique_ptr<SymbolIndex>(new SymbolIndex));
|
|
||||||
/// Also reload stacktrace cache.
|
MultiVersion<SymbolIndex>::Version SymbolIndex::instance()
|
||||||
StackTrace::toStringStatic({}, 0, 0, true);
|
{
|
||||||
}
|
return instanceImpl().get();
|
||||||
return instance.get();
|
}
|
||||||
|
|
||||||
|
void SymbolIndex::reload()
|
||||||
|
{
|
||||||
|
instanceImpl().set(std::unique_ptr<SymbolIndex>(new SymbolIndex));
|
||||||
|
/// Also drop stacktrace cache.
|
||||||
|
StackTrace::dropCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,8 @@ protected:
|
|||||||
SymbolIndex() { update(); }
|
SymbolIndex() { update(); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static MultiVersion<SymbolIndex>::Version instance(bool reload = false);
|
static MultiVersion<SymbolIndex>::Version instance();
|
||||||
|
static void reload();
|
||||||
|
|
||||||
struct Symbol
|
struct Symbol
|
||||||
{
|
{
|
||||||
@ -60,6 +61,7 @@ private:
|
|||||||
Data data;
|
Data data;
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
static MultiVersion<SymbolIndex> & instanceImpl();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ BlockIO InterpreterSystemQuery::execute()
|
|||||||
{
|
{
|
||||||
#if defined(__ELF__) && !defined(__FreeBSD__)
|
#if defined(__ELF__) && !defined(__FreeBSD__)
|
||||||
getContext()->checkAccess(AccessType::SYSTEM_RELOAD_SYMBOLS);
|
getContext()->checkAccess(AccessType::SYSTEM_RELOAD_SYMBOLS);
|
||||||
(void)SymbolIndex::instance(true);
|
SymbolIndex::reload();
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
throw Exception("SYSTEM RELOAD SYMBOLS is not supported on current platform", ErrorCodes::NOT_IMPLEMENTED);
|
throw Exception("SYSTEM RELOAD SYMBOLS is not supported on current platform", ErrorCodes::NOT_IMPLEMENTED);
|
||||||
|
Loading…
Reference in New Issue
Block a user