[MDEV-15786] ERROR 1062 (23000) at line 365: Duplicate entry 'spider' for key 'PRIMARY' Created: 2018-04-05  Updated: 2018-08-30  Resolved: 2018-07-23

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - Spider
Affects Version/s: 10.2.14
Fix Version/s: 10.2.17, 10.3.9, 10.4.0

Type: Bug Priority: Minor
Reporter: Dermot Brereton Assignee: Jacob Mathew (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Environment:

Ubuntu 16.04 xenial



 Description   

Reinstalling the spider plugin after a MariaDB 10.2.13 - - > 10.2.14 upgrade fails with the following error;

# apt-get install mariadb-plugin-spider
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  mariadb-plugin-spider
0 upgraded, 1 newly installed, 0 to remove and 80 not upgraded.
Need to get 0 B/286 kB of archives.
After this operation, 916 kB of additional disk space will be used.
Selecting previously unselected package mariadb-plugin-spider.
(Reading database ... 20688 files and directories currently installed.)
Preparing to unpack .../mariadb-plugin-spider_10.2.14+maria~xenial_amd64.deb ...
Unpacking mariadb-plugin-spider (10.2.14+maria~xenial) ...
Setting up mariadb-plugin-spider (10.2.14+maria~xenial) ...
ERROR 1062 (23000) at line 365: Duplicate entry 'spider' for key 'PRIMARY'



 Comments   
Comment by Elena Stepanova [ 2018-05-30 ]

What do you mean by reinstalling? What was the exact sequence of events?

Comment by Dermot Brereton [ 2018-05-31 ]

Sequence of steps.

1.) Upgraded MariaDB database server (with spider engine installed) from version 10.2.13 to 10.2.14 following the steps recommended in
https://mariadb.com/kb/en/library/upgrading-between-minor-versions-on-linux/

2.) Reinstalling the spider storage engine post-upgrade fails with the error;
ERROR 1062 (23000) at line 365: Duplicate entry 'spider' for key 'PRIMARY'

Comment by Elena Stepanova [ 2018-05-31 ]

Okay, let me be more precise. Please provide the exact sequence of command lines that you used for (1) and (2). Thanks.

Comment by Dermot Brereton [ 2018-05-31 ]

1.) Steps to deinstall & reinstall MariaDB server 10.2 (spider engine already installed)
apt-get remove --purge mysql-server mysql-client mysql-common
apt-get autoremove
apt-get install mariadb-server
mysql_upgrade -p

2.) Steps to reinstall the spider storage engine.
apt-get install mariadb-plugin-spider

Unpacking mariadb-plugin-spider (10.2.14+maria~xenial) ...
Setting up mariadb-plugin-spider (10.2.14+maria~xenial) ...
ERROR 1062 (23000) at line 365: Duplicate entry 'spider' for key 'PRIMARY'

Comment by Elena Stepanova [ 2018-07-19 ]

Unfortunately, this algorithm doesn't work.

1) apt-get remove --purge mysql-server mysql-client mysql-common does remove the server (and actually all mariadb packages), simply because everything depends on mysql-common, and is removed as a dependency. mysql-server and mysql-client are of course not recognized;

2) regardless of (1): even apt-get remove --purge mariadb-server mariadb-client mysql-common (or apt-get purge mariadb-server mariadb-client mysql-common) does not remove /var/lib/mysql, at some point during the process it says this:

Purging configuration files for mysql-common (10.2.15+maria~xenial) ...
dpkg: warning: while removing mysql-common, directory '/etc/mysql' not empty so not removed

and indeed doesn't remove it; however it completely removes all packages, so you can't run purge again afterwards (and subsequent autoremove doesn't purge anything either);

3) when one runs a "normal" remove, like sudo apt-get remove mariadb-server mariadb-client mariadb-common mysql-common, the packages are removed, but they leave

rc  mariadb-client-10.2                10.2.15+maria~xenial            amd64        MariaDB database client binaries
rc  mariadb-common                     10.2.15+maria~xenial            all          MariaDB database common files (e.g. /etc/mysql/conf.d/mariadb.cnf)
rc  mariadb-server-10.2                10.2.15+maria~xenial            amd64        MariaDB database server binaries
rc  mysql-common                       10.2.15+maria~xenial            all          MariaDB database common files (e.g. /etc/mysql/my.cnf)

and if you run sudo apt-get purge mariadb-client-10.2 mariadb-common mariadb-server-10.2 mysql-common afterwards – that's when the /var/lib/mysql gets removed, with a big shiny warning dialog.

I'm reassigning it to otto, the debian packaging expect, to determine if the above is expected behavior, and if not, fix it.

Dermot.Brereton,
So, given the above, when you removed/purged your packages, the vardir with mysql.plugin containing spider remained in place, and subsequent installation of spider failed as it tried to insert it there again.

Comment by Sergei Golubchik [ 2018-07-19 ]

jacob-mathew, could you please fix spider install script not to fail when spider is already present in the mysql.plugin table?

Comment by Jacob Mathew (Inactive) [ 2018-07-20 ]

The Spider install script installs Spider in mysql.plugin only if it is not already present in INFORMATION_SCHEMA.plugins. It is indeed possible to run the script repeatedly without failures.

Note that the error that would occur upon attempting to install Spider when Spider is already installed is the following:

ERROR 1968 (HY000): Plugin 'spider' already installed

Comment by Elena Stepanova [ 2018-07-20 ]

jacob-mathew,
I think it's not the point. The script should be able to handle the situation when the plugin is not installed, but an orphan record exists in mysql.plugin.

Comment by Jacob Mathew (Inactive) [ 2018-07-21 ]

I now understand the inconsistency that results after upgrades to MariaDB and Spider on Ubuntu. I was able to artifcially create this situation on my development machine and verified that the reported error occurs upon re-installing Spider. I have fixed the problem by making changes to the Spider installation script for recognizing and correcting the inconsistency.

Comment by Jacob Mathew (Inactive) [ 2018-07-21 ]

Kentoku, please review my fix for this problem in commit 0897d81 on my branch.

Comment by Kentoku Shiba (Inactive) [ 2018-07-23 ]

LGTM
It's O.K. to push.

Comment by Jacob Mathew (Inactive) [ 2018-07-23 ]

Fix is pushed to 10.3 and 10.2.

Generated at Thu Feb 08 08:24:00 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.