Repository navigation
Description
Tests are sometimes killed by SIGUSR1 before they report any result:
User defined signal 1
This happened once in three runs of dev/release/verify-rc.sh in an Ubuntu 26.04 container. Not only the test runner but also other processes of the same user were killed.
The cause is that the server process may call kill(-1, SIGUSR1). kill(-1, ...) sends the signal to all processes that the calling process has permission to send signals to.
I replaced kill() in src/afs.cc with a wrapper that logs calls with pid <= 0, and ran the tests repeatedly under CPU load. The following calls were logged from the server process in one of the runs:
kill(-1, 10) at Proxy::process_write_requests() (11 times)
kill(-1, 10) at Proxy::process_update_prepared_statement_requests() (1 time)
Both of them use localSession->peerPID:
kill(request->localSession->peerPID, SIGUSR1);localSession->peerPID is copied from session->executorPID only once in Proxy::process_connect_requests():
const auto initialized = session->initialized;
if (initialized && !DsaPointerIsValid(session->errorMessage))
{
auto& localSession = localSessions_.find(request->sessionID)->second;
localSession->valid = true;
localSession->peerPID = session->executorPID;But session->executorPID may still be InvalidPid (-1) at this point:
-
The main process registers an executor and waits for it in
MainProcessor::update_sessions().session->executorPIDisInvalidPiduntilWaitForBackgroundWorkerStartup()returns:WaitForBackgroundWorkerStartup(handle, &(session->executorPID)); -
The executor process starts and sets
session->initialized = true. -
The server process finds
session->initialized == trueand copiessession->executorPIDtolocalSession->peerPID. -
The main process returns from
WaitForBackgroundWorkerStartup()and setssession->executorPID.
If 3. happens before 4., localSession->peerPID is -1 for the lifetime of the session. Nothing prevents this order because these processes access the session entry with shared locks.
We need to:
- Set
session->executorPIDby the executor process itself (MyProcPid) before it setssession->initialized = true, so thatsession->executorPIDis always valid whensession->initializedistrue - Check that the PID isn't
InvalidPidbeforekill().Processor::wait()andExecutor::signal_server()already do this but thekill()calls that usesession->executorPID,localSession->peerPIDorsharedData_->serverPIDdon't
Activity