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

Database Problems with upgrade script 6.1.23 -> 6.2.36 (table exclusion_table column family_exclusion; NULL and primary key) #442

Closed
c-holtermann opened this issue Oct 13, 2018 · 7 comments
Labels
Milestone

Comments

@c-holtermann
Copy link

This issue came up when I did a migration and upgrade at the same time.

Version

6.1.23 to 6.2.36

Installation method

From Sympa debian .deb to compiled from source

Expected behavior

normale upgrade

Actual behavior

sympa.pl --upgrade stopped issuing the error:

notice Sympa::DatabaseManager::_check_primary_key() Primary key exclusion_table [list_exclusion,robot_exclusion,user_exclusion,family_exclusion] is missing. Adding it
err main::#842 > Sympa::Upgrade::upgrade#121 > Sympa::DatabaseManager::probe_db#214 > Sympa::DatabaseManager::_check_primary_key#453 > Sympa::DatabaseDriver::MySQL::set_primary_key#360 > Sympa::Database::do_query#280 Unable to execute SQL statement "ALTER TABLE exclusion_table ADD PRIMARY KEY (list_exclusion,robot_exclusion,user_exclusion,family_exclusion)": (01000) Data truncated for column 'family_exclusion' at row 1
err main::#842 > Sympa::Upgrade::upgrade#121 > Sympa::DatabaseManager::probe_db#214 > Sympa::DatabaseManager::_check_primary_key#453 > Sympa::DatabaseDriver::MySQL::set_primary_key#371 Could not set fields list_exclusion,robot_exclusion,user_exclusion,family_exclusion as primary key for table exclusion_table in database sympa
err main::#842 > Sympa::Upgrade::upgrade#121 > Sympa::DatabaseManager::probe_db#223 Unable to check the validity of primary key for table exclusion_table. Aborting err main::#842 > Sympa::Upgrade::upgrade#125 Database sympa defined in sympa.conf has not the right structure or is unreachable. verify db_xxx parameters in sympa.conf err main::#846 Migration from 6.1.23 to 6.2.36 failed

Additional information

Database before migration was MySQL. Used mysqldump. Migrate to MariaDB.

I couldn't run the upgrade script with mysql. But I ran the upgrade command

ALTER TABLE exclusion_table ADD PRIMARY KEY (list_exclusion,robot_exclusion,user_exclusion,family_exclusion)

on the original machine. MySQL accepts it. Even if I dump this and reimport to MariaDB I get the same error. I could only make it work when doing:

update exclusion_table SET family_exclusion=0 where family_exclusion is null;

then

alter table exclusion_table modify column family_exclusion varchar(50) not null;

now

ALTER TABLE exclusion_table ADD PRIMARY KEY (family_exclusion,user_exclusion,list_exclusion,robot_exclusion);

The problem seems to be setting family_exclusion as primary key when null values are in the database.

@c-holtermann c-holtermann changed the title Database Problems with upgrade script 6.1.23 -> 6.2.36 Database Problems with upgrade script 6.1.23 -> 6.2.36 (table exclusion_table column family_exclusion; NULL and primary key) Oct 13, 2018
@ikedas
Copy link
Member

ikedas commented Oct 13, 2018

Hi @c-holtermann,
Could you please tell us versions of (older) MySQL and (newer) MariaDB?

I found this information:

@c-holtermann
Copy link
Author

That looks like it.

old server:
mysql Ver 14.14 Distrib 5.5.60, for debian-linux-gnu (x86_64) using readline 6.3

new server:
mysql Ver 15.1 Distrib 10.3.10-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
from docker image mariadb

@ikedas
Copy link
Member

ikedas commented Oct 14, 2018

@c-holtermann, thanks for confirming. The bug may be fixed by the PR above.

Note on your workaround: family_exclusion field is varchar and modification would be better to be:

update exclusion_table SET family_exclusion = '' where family_exclusion is null;

Thanks for reporting bug!

@ikedas ikedas added the bug label Oct 14, 2018
@ikedas ikedas added this to the 6.2.38 milestone Oct 14, 2018
@c-holtermann
Copy link
Author

Thank you for the correction.

ikedas added a commit that referenced this issue Oct 21, 2018
family_exclusion field can break not_null constraint during upgrade #442
@ikedas ikedas closed this as completed Oct 21, 2018
@paulmenzel
Copy link

Distributions should backport this commit to their packages.

@guillaume-uH57J9
Copy link

I encountered the same issue with a postgresql database, when upgrading from sympa 6.1.23 to 6.2.36 on a Debian system.

The workaround worked, ie replacing null values by an empty string

@ghost
Copy link

ghost commented Jun 19, 2020

For your information, this fix is included in the sympa version (checked in 6.2.40) available in Debian Buster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants