• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Forwarded to devs Error: mailmng-outgoing failed: ERROR:__main__:UNIQUE constraint failed: vhost_ids.guid

Azurel

Silver Pleskian
Username:

TITLE

Error: mailmng-outgoing failed: ERROR:__main__:UNIQUE constraint failed: vhost_ids.guid

PRODUCT, VERSION, OPERATING SYSTEM, ARCHITECTURE

AlmaLinux 8.6, Plesk Obsidian 46

PROBLEM DESCRIPTION

I want add mail service and checked only checkbox for "Activate mail service on this domain"
URL: /smb/mail-settings/edit/id/46/domainId/46
to a already existing Domain since months and get this error:
Error: mailmng-outgoing failed: ERROR:__main__:UNIQUE constraint failed: vhost_ids.guid
Search for related Knowledge Base articles

/var/log/plesk/panel.log

Code:
stderr:
ERROR:__main__:UNIQUE constraint failed: vhost_ids.guid

[2022-09-01 13:24:37.039] 1054275:63109674a3b62 ERR [panel] mailmng-outgoing failed: ERROR:__main__:UNIQUE constraint failed: vhost_ids.guid
[2022-09-01 13:24:37.039] 1054275:63109674a3b62 ERR [panel.ui] mailmng-outgoing failed: ERROR:__main__:UNIQUE constraint failed: vhost_ids.guid<br><a href='http://kb.plesk.com/plesk-error/search?metaId=6c73567f2c2ef5165c88c8d1691acabb&messageId=aed4d8eef21597253ddaf9f2fee4f22d&file=Agent.php&line=196&type=PleskUtilException&version=18.0.46&message=mailmng-outgoing+failed%3A+ERROR%3A__main__%3AUNIQUE+constraint+failed%3A+vhost_ids.guid' target='_blank'>Search for related Knowledge Base articles</a>
[2022-09-01 13:27:11.185] 1054274:6310970eeee8c ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/mailmng-outgoing' '--add-domain' '--main-domain-name=example.com' '--domain-name=example.jp' '--out-limit=50'] with exit code [1]
[2022-09-01 13:27:11.185] 1054274:6310970eeee8c ERR [panel] '/usr/local/psa/admin/bin/mailmng-outgoing' '--add-domain' '--main-domain-name=example.com' '--domain-name=example.jp' '--out-limit=50' failed with code 1.

stdout:

stderr:
ERROR:__main__:UNIQUE constraint failed: domains.name

[2022-09-01 13:27:11.342] 1054274:6310970eeee8c ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/mailmng-outgoing' '--register-vhost-id' '--domain-name=example.jp'] with exit code [1]
[2022-09-01 13:27:11.342] 1054274:6310970eeee8c ERR [panel] '/usr/local/psa/admin/bin/mailmng-outgoing' '--register-vhost-id' '--domain-name=example.jp' failed with code 1.

Repair not helped

# plesk repair db -y

Checking the Plesk database using the native database server tools .. [OK]
Checking the structure of the Plesk database ........................ [OK]
Checking the consistency of the Plesk database ...................... [OK]
Error messages: 0; Warnings: 0; Errors resolved: 0

# plesk repair mail -y

Repairing the mail server configuration
Reconfiguring all domains and mailboxes ......................... [OK]
Error messages: 0; Warnings: 0; Errors resolved: 0

--


After enabled debug there and tried enable mail there was no other message in panel.log. Nothing with "/opt/psa/admin/plib/Mail/AbstractFacade.php" or part of it.

I have checked db with
> sqlite3 /var/lib/plesk/mail/outgoing/data.db

select * from vhost_ids;
> ......3f7c|30
+
select * from domains;
> 30|example.jp|6|50

and see all domain-ids in both tables. No missing entry.

STEPS TO REPRODUCE

unknown

ACTUAL RESULT

unknown.png


EXPECTED RESULT

No error message

ANY ADDITIONAL INFORMATION

(DID NOT ANSWER QUESTION)

YOUR EXPECTATIONS FROM PLESK SERVICE TEAM

Confirm bug
 
I have tried step "Multiple domains are affected" too https://support.plesk.com/hc/en-us/...-main-UNIQUE-constraint-failed-vhost-ids-guid

Before I have in both tables 32 entries. After copy, destroy and init the db the error was gone but "vhost_ids" have only a single entry:

select * from vhost_ids;
> .....7e3f7c|2

"domains" have now only two entries and its look wrong.

before for table "domains" with 32 enrties
...

9|example.com|6|50
...
30|example.jp|6|50
...
32...

after re-init (only 2 entries) in table "domains"
1|example.com|1|-1
2|example.jp|1|50

So I have delete the new version and rename that backup back to data.db. I hope thats fine.

Funny... The error message is gone. I'm not sure now if I broke anything. Because why is the error still gone now?
 
Another thing;
original "data.db" is 0640 and root : root
the new "data.db" after init is 0660 and root : popuser

Shouldn't that be identical?
 
Try to rebuild the database:

# /usr/lib64/plesk-9.0/remote_mail_restore/mail_outgoing_restore

If the issue still persists thereafter:

1. Remove mail service from the domain:

# /usr/local/psa/admin/sbin/mailmng-outgoing --remove-domain --domain-name=domain-example.jp

2. Activate mail service on the domain back.
 
Maybe my text in this post was little confusing. Therefore formulated in a different way.

Currently its working.
After this post Forwarded to devs - Error: mailmng-outgoing failed: ERROR:__main__:UNIQUE constraint failed: vhost_ids.guid I check both single- and multi domain are affected and make repair ALTHOUGH THERE WAS NO ORPHANED ENTRY. Both tables had 32 entries, including for example.jp.

1. I call following commands for "multi affected":
# cp /var/lib/plesk/mail/outgoing/data.db{,.bkp}
# plesk sbin mailmng-outgoing --destroy
# plesk sbin mailmng-outgoing --init

2. As described, the new database "data.db" does not look repaired with this commands, but rather destroyed/corrupted, since instead of 32 entries in both tables now in new tables there are only 1 and other 2 entries exists. You should check this command.

3. So I delete new created "data.db" and renamed "data.db.bkp" back to "data.db". Since I must assume here rather damage was done than repaired, I restore previous one.

4. But; Since step 1 and still after step 3 too, I can now deactivate and activate mail service for example.jp.

My amateurish guess is:
- The command "mailmng-outgoing" created a incomplete/corrupted database?
- Its created the file "data.db" with other rights as the previous one
- But behind this, its repaired something else, so that mail service for domain example.jp now its working.

I not know what "mailmng-outgoing --destroy" and "mailmng-outgoing --init" make at all. Its look not only create a wrong database. It fixed something in addition.
 
Can't edit post. Is it necessary to call "plesk sbin mailmng-outgoing --init" after rename "data.db.bkp" back to "data.db"?
The support article describes how to create a backup, but not a word about how to restore it correctly.
 
Back
Top