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

Job Queue Datetime bug when using the MariaDB Database driver #50542

Closed
apoorvpal01 opened this issue Mar 14, 2024 · 8 comments
Closed

Job Queue Datetime bug when using the MariaDB Database driver #50542

apoorvpal01 opened this issue Mar 14, 2024 · 8 comments

Comments

@apoorvpal01
Copy link
Contributor

apoorvpal01 commented Mar 14, 2024

Laravel Version

11.0.5

PHP Version

8.3.3

Database Driver & Version

MariaDB 10.11.2 on Ubuntu 22.04 LTS with the MariaDB driver

Description

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '1710393058' for column laravel_test.jobs.available_at at row 1

I get the error mentioned above when running jobs on the PHP 8.3.3. The database I use has not been changed from the one migrated via Laravel 7 with the MySQL driver.

Column DataType Null Default
reserved_at timestamp YES NULL
available_at timestamp NO 0000-00-00 00:00:00
created_at timestamp NO current_timestamp()

Steps To Reproduce

  • Run migrations for the jobs and job_batches tables from an existing Laravel 7 or earlier application.
  • Upgrade sequentially to Laravel 11
  • Switch to the new mariadb driver.
  • Attempt to push a job to the queue (from any source, controller or artisan command etc.) while using the database as the QUEUE_DRIVER.
@staudenmeir
Copy link
Contributor

staudenmeir commented Mar 14, 2024

Hi @apoorvpal01,

Upgrade sequentially to Laravel 11

Did you upgrade from Laravel 7 to Laravel 11 just now or have you been running Laravel 10 for a while?

Can you switch back to the mysql driver temporarily and test if the job works?

@apoorvpal01
Copy link
Contributor Author

Hi @staudenmeir

I have been running on Laravel 10 for the past year without any issues, with the same config (except the DB driver change)

I switched back to the mysql driver on Laravel 11 and it worked fine. The problem occurs only on the mariadb driver.

@driesvints
Copy link
Member

cc @hafezdivandari

@hafezdivandari
Copy link
Contributor

@apoorvpal01 It's maybe related to strict mode, can you try mariadb driver with strict => false?

@apoorvpal01
Copy link
Contributor Author

@hafezdivandari You're right. Disabling the strict mode fixed it. If this is the default requirement for queues, is it in the docs somewhere? Did I miss it? If not, maybe I could add a PR for this to be included in the docs for jobs.

@hafezdivandari
Copy link
Contributor

@apoorvpal01 actually it's not about strict mode. The problem is that you're using an incompatible jobs table structure, the available_at column is not a timestamp but unsignedInteger (even in Laravel 7).

Laravel 7:
https://github.com/laravel/framework/blob/7.x/src/Illuminate/Queue/Console/stubs/jobs.stub#L21-L23

Laravel 11:
https://github.com/laravel/framework/blob/11.x/src/Illuminate/Queue/Console/stubs/jobs.stub#L19-L21

@staudenmeir
Copy link
Contributor

staudenmeir commented Mar 14, 2024

(The disabled strict mode just hid the error from you all this time.)

As @hafezdivandari said, it seems like Laravel has always being using integer columns for this table and therefore tries to insert a UNIX timestamp (instead of a datetime string).

@apoorvpal01
Copy link
Contributor Author

Oh, thanks for the clarification. I am not sure how I got this schema on the database then. I'll check that out. Sorry for the trouble, and thanks for your help!

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

No branches or pull requests

5 participants