mchk fails with error: PRIMARY KEY must be unique

Created:

2016-11-16 13:02:34 UTC

Modified:

2017-04-24 11:59:25 UTC

0

Was this article helpful?


Have more questions?

Submit a request

mchk fails with error: PRIMARY KEY must be unique

Applicable to:

  • Plesk 12.0 for Linux

Symptoms

Creation of domain on existed subscription results in error:

ERROR:outgoing:domains.subscription_id may not be NULL

Execution of mchk utility results in another error:

..
==> Checking for: mail_outgoing_restore... fail
==> Checking for: mail_transport_restore... ok
Errors occured in mail restore procedure
Some utilities have exited with errors:
/usr/lib/plesk-9.0/remote_mail_restore/mail_outgoing_restore

Manual execution of /usr/lib/plesk-9.0/remote_mail_restore/mail_outgoing_restore utility also results in error:

 Error: PRIMARY KEY must be unique

Cause

Duplicate user ID in /etc/passwd .

Resolution

Users for different subscriptions should have different ID and path.

  1. Use following script to find what user have duplicate ID and belongs to another subscription in /etc/passwd :

    ~]# cat duplicate

    #!/bin/bash
    find_duplicate_users() {
    SYS_USERS=$(mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -NBe "select login from sys_users WHERE mapped_to IS NULL;")
    for USER in `echo $SYS_USERS`
    do
    grep "$USER:" /etc/passwd | awk -F":" '{print $1" "$3}'
    done
    }
    find_duplicate_users | sort -k2

    ~]#chmod +x duplicate

    ~]#./duplicate
  2. Create a backup of /etc/passwd :

    cp -p /etc/passwd /etc/passwd.orig
  3. Change dublicated UID:

    ~]# usermod -u <New UID> <user>
Have more questions? Submit a request
Please sign in to leave a comment.