Running the database update (update.php) after upgrade from release 7.44 to 7.50 gave me the following message. Website stopped responding normaly sometime after that, we had to restore a backup.
-------------------------------
The following updates returned messages
node module
Update #7016
Failed: PDOException: SQLSTATE[42P16]: Invalid table definition: 7 ERROR: multiple primary keys for table "history" are not allowed: ALTER TABLE {history} ADD PRIMARY KEY (uid,nid); Array ( ) in db_add_primary_key() (regel 2927 van /srv/Http_Server/Parkstadveendam-nl/drupal/includes/database/database.inc).
-------------------------------
Log message:
-------------------------------
TYPE update
DATUM dinsdag 12 juli 2016 21:51
GEBRUIKER Redactie A
LOCATIE http://www.parkstadveendam.nl/update.php?op=selection&token=y0HAIYjz1j-z...
DOORVERWIJZER http://www.parkstadveendam.nl/update.php?op=selection&token=y0HAIYjz1j-z...
BERICHT PDOException: SQLSTATE[42P16]: Invalid table definition: 7 ERROR: multiple primary keys for table "history" are not allowed: ALTER TABLE {history} ADD PRIMARY KEY (uid,nid); Array ( ) in db_add_primary_key() (regel 2927 van /srv/Http_Server/Parkstadveendam-nl/drupal/includes/database/database.inc).
ERNST fout
HOSTNAAM 46.244.50.21
BEWERKINGEN
-------------------------------
RDBMS is PostgreSQL 9.5
Comment | File | Size | Author |
---|---|---|---|
#21 | i2765043-21.patch | 1.1 KB | attiks |
Comments
Comment #2
cilefen CreditAttribution: cilefen commentedWhat database system is this? Everywhere I look 42P16 is a is a PostgreSQL error. If so you should be on 8.3 or higher.
Comment #3
attiks CreditAttribution: attiks at Attiks commentedFixing version
Comment #4
attiks CreditAttribution: attiks at Attiks commentedSame error running PostgreSQL 9.3.13
Comment #5
attiks CreditAttribution: attiks at Attiks commentedChecking the key and it is created
Comment #6
attiks CreditAttribution: attiks at Attiks commentedIf I drop the key
ALTER TABLE drupal.history DROP CONSTRAINT history_pkey;
I can create it usingALTER TABLE drupal.history ADD PRIMARY KEY (uid,nid);
Comment #7
cilefen CreditAttribution: cilefen commentedComment #8
attiks CreditAttribution: attiks at Attiks commentedDebugged some more, key gets never dropped,
dropPrimaryKey
checks if the constraint exists, but it fails.but executing
SELECT 1 FROM pg_constraint WHERE conname = 'history_pkey';
returnsComment #9
attiks CreditAttribution: attiks at Attiks commentedFor some reason
constraintExists($table, $name)
uses{}
around the table name, but this doesn't work if your table name is prefixed. So changing$constraint_name = '{' . $table . '}_' . $name;
to$constraint_name = $table . '_' . $name;
, solves it.Comment #10
attiks CreditAttribution: attiks at Attiks commentedPS: Same for the indexes
$index_name = '{' . $table . '}_' . $name . '_idx';
to$index_name = $table . '_' . $name . '_idx';
Comment #11
drummComment #12
gjk4all CreditAttribution: gjk4all commented@cilefen it is running on a PostgreSQL 9.5 RDBMS.
Comment #13
gjk4all CreditAttribution: gjk4all commentedComment #14
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedBased on #9 could this be related to #1009828: constraintExists doesn't work with multiple schemas (or is that something else)?
Comment #15
attiks CreditAttribution: attiks at Attiks commentedNot sure if it's the same, it links to #1008128: Do not use a single underscore as table and index separator on PostgreSQL and SQLite which does not have a real patch, and I'm not really a psql expert.
On this instance there's a prefix defined
'prefix' => 'drupal.',
Comment #16
gjk4all CreditAttribution: gjk4all commented#14: I do have multiple schema's, there are 2 drupal instances in the database, one acceptance instance in schema "drupal" and one production instance in schema "drupalprod". prefixes are set in the site configuration file.
Both encountered this problem, production instance stopped functioning within a day after the failed database update, had to restore a backup.
Previous updates (till 7.44, our current version) didn't show this problem.
Comment #17
gjk4all CreditAttribution: gjk4all commentedI was able to do the upgrade, update 7016 still failed, did the manual drop as suggested:
parkstadveendam=# alter table drupalprod.history drop constraint history_pkey;
ALTER TABLE
parkstadveendam=# drop index drupalprod.history_nid_idx;
DROP INDEX
After that rerun the database update and 7016 did go well, clearing all caches with drush made the site appear again as we know it.
Comment #18
stefan.r CreditAttribution: stefan.r commentedComment #19
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedI guess this belongs in the release notes at https://www.drupal.org/project/drupal/releases/7.50, so I took a stab at adding it to the "Known issues" section although I wasn't sure exactly what to write: https://www.drupal.org/node/2762447/revisions/view/9922761/9923859
Comment #20
attiks CreditAttribution: attiks at Attiks commentedThis also happens on 7.44, tried installing the new version of panels and got the following error
Comment #21
attiks CreditAttribution: attiks at Attiks commentedAdding a patch to see what testbot says, it's add the 2 lines of #9 and #10
Comment #22
stephencamilo CreditAttribution: stephencamilo as a volunteer commentedComment #23
hestenetReset issue status.
Comment #24
poker10 CreditAttribution: poker10 at ActivIT s.r.o. commentedThis problem was fixed in Drupal 7.89 release by #998898: Make sure that the identifiers are not more the 63 characters on PostgreSQL , where the DatabaseSchema_pgsql::constraintExists() function was changed. I am not able to simulate the problem anymore, even if I prefix the history table. Therefore I am closing this.