-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use google breakpad in ydbd (#12894)
- Loading branch information
Showing
8 changed files
with
94 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <util/generic/ptr.h> | ||
#include <contrib/libs/breakpad/src/client/linux/handler/exception_handler.h> | ||
#include <unistd.h> | ||
#include <sys/wait.h> | ||
|
||
|
||
class TMinidumper { | ||
public: | ||
TMinidumper() { | ||
if(const char* path = getenv("BREAKPAD_MINIDUMPS_PATH")) { | ||
using namespace google_breakpad; | ||
Handler = MakeHolder<ExceptionHandler>(MinidumpDescriptor(path), nullptr, DumpCallback, nullptr, true, -1, true); | ||
} | ||
} | ||
|
||
private: | ||
static bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void* context, bool succeeded) { | ||
if (char* script = getenv("BREAKPAD_MINIDUMPS_SCRIPT")) { | ||
if (auto pid = fork()) { | ||
waitpid(pid, 0, 0); | ||
} else { | ||
char* dumpSucceded = succeeded ? (char *)"true" : (char *)"false"; | ||
char* descriptorPath = succeeded ? (char *)descriptor.path() : (char *)"\0"; | ||
char* cmd[] = {script, dumpSucceded, descriptorPath, NULL}; | ||
execve(cmd[0], &cmd[0], NULL); | ||
} | ||
} | ||
return succeeded; | ||
} | ||
|
||
THolder<google_breakpad::ExceptionHandler> Handler; | ||
}; | ||
|
||
TMinidumper Minidumper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
LIBRARY() | ||
|
||
IF (OS_LINUX) | ||
PEERDIR( | ||
contrib/libs/breakpad/src | ||
contrib/libs/breakpad/src/client/linux | ||
) | ||
|
||
SRCS( | ||
GLOBAL minidumps.cpp | ||
) | ||
ENDIF() | ||
|
||
END() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ RECURSE( | |
arrow_parquet | ||
backup | ||
benchmarks | ||
breakpad | ||
chunks_limiter | ||
folder_service | ||
formats | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import yatest.common | ||
import os | ||
from ydb.tests.library.harness.kikimr_runner import KiKiMR | ||
|
||
|
||
def test_create_minidump(): | ||
dump_path = os.path.join(yatest.common.tempfile.gettempdir(), 'dumps') | ||
os.makedirs(dump_path, exist_ok=True) | ||
os.environ['BREAKPAD_MINIDUMPS_PATH'] = dump_path | ||
cluster = KiKiMR() | ||
cluster.start() | ||
for node in cluster.nodes.values(): | ||
node.send_signal(6) | ||
try: | ||
cluster.stop() | ||
except RuntimeError: | ||
pass | ||
assert len(os.listdir(dump_path)) == len(cluster.nodes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
IF (OS_LINUX) | ||
|
||
PY3TEST() | ||
|
||
TEST_SRCS( | ||
test_break.py | ||
) | ||
|
||
SIZE(MEDIUM) | ||
|
||
ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") | ||
|
||
PEERDIR( | ||
ydb/tests/library | ||
) | ||
|
||
DEPENDS( | ||
ydb/apps/ydbd | ||
) | ||
|
||
|
||
END() | ||
|
||
ENDIF() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ RECURSE( | |
kv_workload | ||
large_serializable | ||
limits | ||
minidumps | ||
open_source | ||
postgresql | ||
query_cache | ||
|