Skip to content

Commit

Permalink
dist: add workaround to capture coredump during system reboot or shut…
Browse files Browse the repository at this point in the history
…down

We found that systemd-coredump does not correctly capturing coredump
during system reboot or shutdown.
As a workaround of this issue, set coredump file path to
kernel.core_pattern during system reboot or shutdown.
It will save core to /var/lib/scylla/shutdown-coredump/.

Fixes scylladb/scylla-machine-image#436
  • Loading branch information
syuu1228 committed Oct 23, 2023
1 parent 1ab2bb6 commit b1a38cb
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions dist/common/scripts/scylla_kill
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# When shutdown is being called, stop using systemd-coredump handler
# since it does not work correctly
st_jobs=$(systemctl list-jobs --no-pager shutdown.target)
if [[ ! $st_jobs =~ (^No jobs .*\.$) ]]; then
sysctl -w kernel.core_pattern=/var/lib/scylla/coredump-shutdown/core.%e.%P.%u.%g.%s.%t.%c.%h
fi
# Shutdown Scylla
pkill scylla
2 changes: 1 addition & 1 deletion dist/common/scripts/scylla_raid_setup
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ WantedBy=multi-user.target
gid = grp.getgrnam('scylla').gr_gid
os.chown(root, uid, gid)

for d in ['coredump', 'data', 'commitlog', 'hints', 'view_hints', 'saved_caches']:
for d in ['coredump', 'coredump-shutdown', 'data', 'commitlog', 'hints', 'view_hints', 'saved_caches']:
dpath = '{}/{}'.format(root, d)
os.makedirs(dpath, exist_ok=True)
os.chown(dpath, uid, gid)
Expand Down
1 change: 1 addition & 0 deletions dist/common/systemd/scylla-server.service
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ EnvironmentFile=/etc/sysconfig/scylla-server
EnvironmentFile=/etc/scylla.d/*.conf
ExecStartPre=/opt/scylladb/scripts/scylla_prepare
ExecStart=/usr/bin/scylla $SCYLLA_ARGS $SEASTAR_IO $DEV_MODE $CPUSET $MEM_CONF
ExecStop=/opt/scylladb/scripts/scylla_kill
ExecStopPost=/opt/scylladb/scripts/scylla_stop
TimeoutStartSec=1y
TimeoutStopSec=900
Expand Down
1 change: 1 addition & 0 deletions dist/debian/debian/scylla-server.install
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var/lib/scylla/commitlog
var/lib/scylla/hints
var/lib/scylla/view_hints
var/lib/scylla/coredump
var/lib/scylla/coredump-shutdown
var/lib/scylla-housekeeping
etc/systemd/system/scylla-server.service.d/dependencies.conf
etc/systemd/system/scylla-server.service.d/sysconfdir.conf
Expand Down
1 change: 1 addition & 0 deletions dist/redhat/scylla.spec
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ rm -rf $RPM_BUILD_ROOT
%attr(0755,scylla,scylla) %dir %{_sharedstatedir}/scylla/hints
%attr(0755,scylla,scylla) %dir %{_sharedstatedir}/scylla/view_hints
%attr(0755,scylla,scylla) %dir %{_sharedstatedir}/scylla/coredump
%attr(0755,scylla,scylla) %dir %{_sharedstatedir}/scylla/coredump-shutdown
%attr(0755,scylla,scylla) %dir %{_sharedstatedir}/scylla-housekeeping
%ghost /etc/systemd/system/scylla-helper.slice.d/
%ghost /etc/systemd/system/scylla-helper.slice.d/memory.conf
Expand Down
1 change: 1 addition & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ install -m755 -d "$rdata"/commitlog
install -m755 -d "$rdata"/hints
install -m755 -d "$rdata"/view_hints
install -m755 -d "$rdata"/coredump
install -m755 -d "$rdata"/coredump-shutdown
install -m755 -d "$rprefix"/swagger-ui
cp -r swagger-ui/dist "$rprefix"/swagger-ui
install -d -m755 -d "$rprefix"/api
Expand Down

0 comments on commit b1a38cb

Please sign in to comment.