When attempting to update today to handle security updates, I am hitting fatal errors. I have tried updating both from 2.2.6 and 2.2.8 (different projects) to 3.1.0 and I am consistently getting this fatal error:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'lightning_core.versions' for key 'PRIMARY': UPDATE {config} SET name=:db_update_placeholder_0                                       [error]
WHERE (name = :db_condition_placeholder_0) AND (collection = :db_condition_placeholder_1); Array
(
    [:db_update_placeholder_0] => lightning_core.versions
    [:db_condition_placeholder_0] => lightning.versions
    [:db_condition_placeholder_1] => 
)

I see the same error two times in the output.

CommentFileSizeAuthor
#7 2955072-7.patch3.75 KBphenaproxima
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikemadison created an issue. See original summary.

balsama’s picture

balsama’s picture

Assigned: Unassigned » phenaproxima
balsama’s picture

As I understand this:

  1. At some point, Lightning introduced a config object named lightning.versions, then stopped using it.
  2. Our test fixtures ceased to include this config object five releases after it was introduced, but we never actually deleted it.
  3. The 1.x branch of Lightning Core (used in the 3.0.x branch of the profile) reintroduced that same config object in update_8006
  4. This had the unintended consequence of causing Lightning Core to have a dependency on the Lightning profile due to the name, so lightning_core_update_8007 was introduced to rename it.
  5. Around this time people who had the old vestigial lightning.versions config object started reporting the same DB error as in this IS.

This is where things start to get fuzzy because there are at least three separate commits which actually change the contents of lightning_core_update_8006. One thing is certain, HEAD of lightning_core 1.x and 2.x and the most recent release on each (1.0.0-rc3 and 2.1.0 respectively) have identical code in 8006 and 8007. And the version of Lightning Core that shipped with the 2.2.8 profile DID NOT HAVE EITHER.

So, updating from 2.2.6 to 3.0.3 (for example) should be the same as updating from 2.2.8 to 3.1.0 as far as the lightning.versions config is concerned.

It seems to me that 8006 is still very much broken for anybody that has the lightning.versions config object.

balsama’s picture

After to talking to @phenaproxima, I think my assessment in #4 is wrong. The situation arises when the installer reaches the 8007 update and the lightning_core.versions already exists. This can happen if lightning_core_modules_installed has reacted to a module being installed sometime before 8007 - which becomes more likely if your update is particularly complex (lots of things getting installed/updated/uninstalled).

The fix should be to just have 8007 check for the presence of lightning_core.versions and merge the contents of it if it does exist.

++ to @phenaproxima and @mikemadison for tracing this.

phenaproxima’s picture

Status: Active » Needs review

Opened a PR which should correct the issue: https://github.com/acquia/lightning-core/pull/39

phenaproxima’s picture

Project: Lightning » Lightning Core
Version: 8.x-3.100 » 8.x-2.x-dev
FileSize
3.75 KB

Here is a patch, for those who cannot access the pull request.

From the PR summary, for posterity:

The problem is that 8007 is blithely assuming that lightning_core.versions doesn't exist in config yet. This is an issue because, in a big update chain, it is entirely possible that lightning_core_modules_installed() will be invoked, which would create or update the lightning_core.versions config object. Then, if update 8007 is run, KABOOM!

As of this PR (which includes test coverage), 8007 will check if lightning_core.versions already exists. If it does, it will meekly merge the data from lightning.versions (i.e., the new data will take precedence) into it, then delete lightning.versions.

  • phenaproxima authored d83dff7 on 8.x-2.x
    Issue #2955072 by phenaproxima, mikemadison: Updating from 2.x to 3.x...

  • phenaproxima authored 4a2b916 on 8.x-1.x
    Issue #2955072 by phenaproxima, mikemadison: Updating from 2.x to 3.x...
phenaproxima’s picture

Status: Needs review » Fixed

Committed to 8.x-2.x and cherry-picked to 8.x-1.x. Cheerio!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.