craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.21k stars 624 forks source link

[4.x]: Incorrect ID assignment for current revision makes page uneditable #15039

Closed Mixxey closed 3 months ago

Mixxey commented 3 months ago

What happened?

Description

Sometimes when trying to save certain entries, a server error occurs and the entry can't be saved. This seems to be related to a faulty assignment of revision IDs.

My interpretation (I'm not a pro techie): apparently the revisions all have an ID in the database, and you can't save the page (no matter what you have changed) because the system tries to write the new version to the database with an ID that is already assigned.

Workaround: Duplicate page, new page can be edited and saved without any problems. Unfortunately, this is not a sustainable solution either, as there have been problems with the “release” of URLs in the past (Colleague: “I'm pretty sure that in some past case I had some problems with a URL that was deleted, but the CMS wouldn't let me switch to it”).

Interestingly, sometimes the entries seem to recover over time. While I wasn't able to save the entry mentioned below on past Saturday, everything worked fine just now, without anyone of us touching the entry in the meantime.

Steps to reproduce

1.https://hero-software.de/_cmsadmin/entries/contentseite/1510788-barcamp?site=default

  1. Save page
  2. Error -> CMS: “Interner Serverfehler” - internal server error - entry is not saved -> Console: POST https://hero-software.de/_cmsadmin/entries/contentseite/1510788-barcamp?site=default 500 (Internal Server Error) -> Sentry: [Integrity constraint violation: 1062 Duplicate entry '1512170-1' for key 'revisions_sourceId_num_unq_idx']

Expected behavior

Entry should be saved normally.

Actual behavior

Entry is not saved.

Craft CMS version

Craft Pro 4.9.3

PHP version

8.0.30

Operating system and version

Linux 4.15.0-213-generic

Database type and version

MySQL 5.7.42

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.10-23)

Installed plugins and versions

i-just commented 3 months ago

Hi, thanks for getting in touch! This sounds a lot like #14309. There was a change related to this in 4.9.3 (released on 2024-05-14) and another one in 4.9.5 (released yesterday). Could you update to 4.9.5, run the garbage collection on the affected site (php craft gc/run), and if this happens again afterwards, could you please send the composer.json, composer.lock and database export to support@craftcms.com so we can replicate (and point out which entry this happened for)?

Mixxey commented 3 months ago

Hi, thanks for your support! We updated and ran the garbage collection without issues. Now let's hope that fixed our problems :) I will get it touch again if the error occurs again. In the meantime, I wish you a great weekend!

brandonkelly commented 3 months ago

Thanks for following up @Mixxey!