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

Problems when db user cannot create or alter tables #973

Open
thomasgaillard opened this issue Aug 2, 2023 · 21 comments
Open

Problems when db user cannot create or alter tables #973

thomasgaillard opened this issue Aug 2, 2023 · 21 comments
Labels
priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: enhancement The issue is a request for an enhancement.

Comments

@thomasgaillard
Copy link

thomasgaillard commented Aug 2, 2023

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
Copy link
Author

thomasgaillard commented Aug 3, 2023

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

@ULHI-xin
Copy link

ULHI-xin commented Aug 3, 2023

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
Copy link

ULHI-xin commented Aug 3, 2023

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.

@thomasgaillard
Copy link
Author

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

@rrennick
Copy link
Contributor

rrennick commented Aug 3, 2023

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

@barryhughes
Copy link
Member

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.

@Babylon1999
Copy link

zd-6568129 and 6613737

@emar
Copy link

emar commented Aug 11, 2023

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.

@barryhughes
Copy link
Member

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 barryhughes added type: enhancement The issue is a request for an enhancement. priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. labels Aug 11, 2023
@emar
Copy link

emar commented Aug 11, 2023

@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.

@Babylon1999
Copy link

zd-6656890

@Babylon1999
Copy link

zd-6600327

@barryhughes barryhughes changed the title Fatal error on different wordpress websites Problems when db user cannot create or alter tables Aug 18, 2023
@jorgeatorres
Copy link
Member

zd-6693507

@shameemreza
Copy link

zd-6707173

@shameemreza
Copy link

zd-6746361

@barryhughes
Copy link
Member

Another report: #986

@lsinger
Copy link
Contributor

lsinger commented Oct 25, 2023

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.

@sophiegyo
Copy link

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
Copy link

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?

@barryhughes
Copy link
Member

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

No branches or pull requests

10 participants