Skip to content

Commit 5d69357

Browse files
rtokarevTotktonada
andcommitted
Send SIGKILL if server does not stop after timeout
If a tarantool instance does not handle SIGTERM correctly, it is the bug in tarantool. A testing system should reveal problems rather than hide them. However this patch doing that and I'll explain why. Many tests we have perform instance starting / stopping: they are written to spot different problems, but not this one. If everything else except hanging at stop is okay, there is no reason to fail the test. We print a notice on the terminal in the case and proceed further. In future, when all problems of this kind will be resolved, we can interpret presence of such notices as error. However now it'll not add anything for quality of our testing. We had a problem of this kind ([1]) in the past and now have another one ([2]). Until it will be resolved, it worth to handle the situation on the testing system side. [1]: tarantool/tarantool#4127 [2]: https://github.com/tarantool/tarantool/issues/5573 Part of #157 Co-authored-by: Alexander Turenko <[email protected]>
1 parent c1b1b14 commit 5d69357

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lib/tarantool_server.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from gevent import socket
1717
from greenlet import GreenletExit
18+
from threading import Timer
1819

1920
try:
2021
from cStringIO import StringIO
@@ -23,7 +24,9 @@
2324

2425
from lib.admin_connection import AdminConnection, AdminAsyncConnection
2526
from lib.box_connection import BoxConnection
26-
from lib.colorer import color_stdout, color_log
27+
from lib.colorer import color_stdout
28+
from lib.colorer import color_log
29+
from lib.colorer import qa_notice
2730
from lib.preprocessor import TestState
2831
from lib.server import Server
2932
from lib.test import Test
@@ -984,9 +987,24 @@ def stop(self, silent=True, signal=signal.SIGTERM):
984987
self.process.send_signal(signal)
985988
except OSError:
986989
pass
990+
991+
# Waiting for stopping the server. If the timeout
992+
# reached, send SIGKILL.
993+
timeout = 5
994+
def kill():
995+
qa_notice('The server \'{}\' does not stop during {} '
996+
'seconds after the {} ({}) signal.\n'
997+
'Info: {}\n'
998+
'Sending SIGKILL...'.format(
999+
self.name, timeout, signal, signame(signal),
1000+
format_process(self.process.pid)))
1001+
self.process.kill()
1002+
timer = Timer(timeout, kill)
1003+
timer.start()
9871004
if self.crash_detector is not None:
9881005
save_join(self.crash_detector)
9891006
self.wait_stop()
1007+
timer.cancel()
9901008

9911009
self.status = None
9921010
if re.search(r'^/', str(self._admin.port)):

0 commit comments

Comments
 (0)