Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDOException gets thrown whenever a SIGALRM happens during a query #45867

Closed
amiranagram opened this issue Jan 30, 2023 · 1 comment
Closed

Comments

@amiranagram
Copy link
Contributor

amiranagram commented Jan 30, 2023

  • Laravel Version: 9.47.0
  • PHP Version: 8.1
  • Database Driver & Version: MSSql 18

Description:

Whenever a SIGALRM happens during an execution of a query a PDOException gets thrown from the MSSql server.

Illuminate\Database\QueryException in App\Jobs\Job
SQLSTATE[08S01]: [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2714 (SQL: select * from [table] order by [id] asc offset 1000 rows fetch next 1000 rows only)

NOTE: I am in no way an expert in Process Control but I've been digging about this error for days, and found relevant info. This issue describes why this happens and how, specifically in this comment a msphpsql maintainer explains how to resolve this issue. Another relevant change is this commit by Nikita Popov in PHP core.

Apparently, to solve this we need to add the third argument (restart_syscalls) as true, here:

pcntl_signal(SIGALRM, function () use ($job, $options) {
if ($job) {
$this->markJobAsFailedIfWillExceedMaxAttempts(
$job->getConnectionName(), $job, (int) $options->maxTries, $e = $this->maxAttemptsExceededException($job)
);
$this->markJobAsFailedIfWillExceedMaxExceptions(
$job->getConnectionName(), $job, $e
);
$this->markJobAsFailedIfItShouldFailOnTimeout(
$job->getConnectionName(), $job, $e
);
}
$this->kill(static::EXIT_ERROR, $options);
});

I have no idea what are the ramifications of this change, that's why I'm writing an issue and not opening a PR. Feel free to educate me and/or give me a clue on how to solve this issue for me.

Steps To Reproduce:

Have a job time out while running a query on the MSSql server.

@amiranagram amiranagram changed the title PDOException gets thrown whenever a SIGALRM happens during a query. PDOException gets thrown whenever a SIGALRM happens during a query Jan 30, 2023
@driesvints
Copy link
Member

Hi @amiranagram we'd a appreciate a PR for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants