action-scheduler icon indicating copy to clipboard operation
action-scheduler copied to clipboard

Problems when db user cannot create or alter tables

Open thomasgaillard opened this issue 11 months ago • 21 comments

Hi there

Some of my Wordpress sites didn't have admin rights on the SQL user side when I upgraded Woocommerce.

I now have fatal errors because the "priority" column in the wp_actionscheduler_actions table was not created when I updated Woocommerce (and therefore ActionScheduler).

How can I manually replay the last two ActionScheduler core updates please?

Manual creation using the sql command given on another workstation doesn't work: ALTER TABLE wp_actionscheduler_actions ADD priority TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' AFTER extended_args;

And I want to repatch the whole thing. I don't have access to WP CLI.

Thanks for your help, I've already spent many hours

Capture d’écran 2023-08-02 à 17 48 02

thomasgaillard avatar Aug 02 '23 18:08 thomasgaillard

I finally success to install WP CLI and run the command for manually update ActionScheduler : and everything works !!

thomasgaillard avatar Aug 03 '23 08:08 thomasgaillard

Same here. My whole WP site was down because the SQL trying inserting a new row with field priority but the column was not added yet.

It seems no straightforward way to fix it, including disabling all plugin and installing Action Scheduler plugin directly.

But I finally got it fixed by running a manual DB DDL (actually just alter table add column). If you have privilege to run DDL you might try this way.

ULHI-xin avatar Aug 03 '23 08:08 ULHI-xin

I finally success to install WP CLI and run the command for manually update ActionScheduler : and everything works !!

Hi @thomasgaillard would you mind sharing the CLI command to do the manual update? I believe it would be very helpful.

Manual creation using the sql command given on another workstation doesn't work: ALTER TABLE wp_actionscheduler_actions ADD priority TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' AFTER extended_args;

Also I'm a little bit curious why the alter table is not working for you. In my case, it solve the problem as well. Just FYI.

ULHI-xin avatar Aug 03 '23 08:08 ULHI-xin

Helo @ULHI-xin,

I had an sql error while running the command alter table .. and I don't know if this "Priority column" was the only one missing So the idea was to manually update/repair with these following commands :

  1. Ssh connexion
  2. WP CLi install curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  3. Fix things in database for Action Scheduler with this command wp action-scheduler fix-schema

Have a good day

thomasgaillard avatar Aug 03 '23 08:08 thomasgaillard

We still need to address this issue for folks who don't have WP CLI.

rrennick avatar Aug 03 '23 12:08 rrennick

The backtrace in the original comment shows WooCommerce is present (which itself periodically ships schema updates). I'm curious why Action Scheduler's updates in particular aren't sticking.

barryhughes avatar Aug 04 '23 14:08 barryhughes

zd-6568129 and 6613737

Babylon1999 avatar Aug 08 '23 17:08 Babylon1999

I'm still having issues after going into ssh as domain user and applying the fix.

[root@user1 /]# su user1 [user1@user1 /]$ home/user1/public_html [user1@user1 /]$ cd /home/user1/public_html [user1@user1 public_html]$ wp action-scheduler fix-schema Success: Registered schema for ActionScheduler_LoggerSchema Success: Registered schema for ActionScheduler_StoreSchema

I don't think it worked, there's no priority column in the db for wp_actionscheduler_actions. I'm only going by what I've read on here and the replies to my topic on WordPress forum. Can't enable WooCommerce and some other plugins without critical error related to action scheduler.

emar avatar Aug 11 '23 08:08 emar

Unfortunately, wp action-scheduler fix-schema will report success even if it did not manage to actually update the schemas.

My guess here is that your database user has not been granted the privileges it requires to modify existing tables. Do you have a hosting provider you can turn to for help with this, or are you self-hosting (if so, the references below might be useful)?

barryhughes avatar Aug 11 '23 17:08 barryhughes

@barryhughes I have root access..

Usually I'd do the db and WordPress from scratch, this time Softaculous.

I checked the database user permissions. SELECT | INSERT | UPDATE | DELETE

Gave the user full permissions and ran wp action-scheduler fix-schema again.

Priority column appears in the database, WooCommerce enables without error.

Thanks a lot.

emar avatar Aug 11 '23 20:08 emar

zd-6656890

Babylon1999 avatar Aug 12 '23 17:08 Babylon1999

zd-6600327

Babylon1999 avatar Aug 12 '23 17:08 Babylon1999

Related reports:

  • https://github.com/woocommerce/action-scheduler/issues/958 (closed in favor of this one)
  • https://github.com/woocommerce/action-scheduler/issues/856 (not identical, but has some cross-over)

barryhughes avatar Aug 18 '23 16:08 barryhughes

zd-6693507

jorgeatorres avatar Aug 29 '23 14:08 jorgeatorres

zd-6707173

shameemreza avatar Aug 31 '23 08:08 shameemreza

zd-6746361

shameemreza avatar Sep 04 '23 10:09 shameemreza

Another report: https://github.com/woocommerce/action-scheduler/issues/986

barryhughes avatar Sep 13 '23 14:09 barryhughes

Heads up that in #1000 we have merged some more defensive error handling to ensure that if we can't update the schema, we don't bubble up that error to produce fatal errors on the site but instead log to the error log. This is a first step to handling this situation, future work might include additional strategies.

lsinger avatar Oct 25 '23 16:10 lsinger

Possible instance of this in 7781794-zen - I've asked them to try the wp action-scheduler fix-schema method but if not then maybe one of the additional contributions in this thread can help: https://wordpress.org/support/topic/fatal-error-missing-column-priority/

sophiegyo avatar Mar 04 '24 13:03 sophiegyo

The merchant in 7781794-zen shared the following as their non-CLI fix - they simply created the priority column that the site was clamouring for:

I found the solution as this:

https://wordpress.org/support/topic/fatal-error-missing-column-priority/

I ran SQL query to add priority column to wp_actionscheduler_actions table and that's it - update database looked working and the prompt to update is gone.

No fatal errors from the log.

What do you think about that approach?

sophiegyo avatar Mar 13 '24 13:03 sophiegyo

Yep ... that's a perfectly reasonable approach (in fact, it is essentially what Action Scheduler tries to do, except in various cases it does not have permission).

barryhughes avatar Mar 25 '24 22:03 barryhughes