Closed Bug 1543450 Opened 6 years ago Closed 6 years ago

Fix graceful shutdown in vcsreplicator.consumer.py

Categories

(Developer Services :: Mercurial: hg.mozilla.org, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: lars, Unassigned)

References

Details

Attachments

(1 file)

Within the code for vcsreplicator.consumer.py file, there is signal handling code that purports to enable the vcsreplicator-consumer to shutdown gracefully. Unfortunately, the code does not take into account that if a shutdown signal arrives during a blocking system call (like Kafka reading from a socket), a simple return from a signal handler will induce the blocking call to raise an EINTR exception. This exception is not handled and results in a graceless shutdown.

Improve the signal handler in consumer.consume to avoid the case where it induces the EINTR exception.

Blocks: 1543448

The existing shutdown signal handler fails to take into account the EINTR
exception raised by blocking system calls. This is raised when the signal
is caught during a system call like reading from a socket by Kafka. This
happens when the signal handler simply returns without raising an exception
of its own. The exsting handler used a counter as a closure to control the
message consuming loop.

As an alternate implementation, this new handler raises a custom exception
whenever a signal is received. This doesn't allow the blocking system call
the opportunity to raise the EINTR exception. The custom exception breaks
the consuming loop without the need of a counter.

An exception handler was added to the try:finally: construct to take
the responsibility of logging the shutdown process.

For this change to pass tests, Bug 1543448 must also be resolved.

Pushed by lars@mozilla.com:
https://hg.mozilla.org/hgcustom/version-control-tools/rev/a99aa3f3fd35
vcsreplicator: simplify shutdown signal handlers r=sheehan

Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: