MySQL: Duplicate entry ... 'idx_hm_imapfolders_unique'

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
estradis
Normal user
Normal user
Posts: 156
Joined: 2014-09-09 10:47

MySQL: Duplicate entry ... 'idx_hm_imapfolders_unique'

Post by estradis » 2017-08-18 09:57

Hi there,

since yesterday I receive following errors, each one twice:

Code: Select all

"Severity: 2 (High), Code: MH5032, Source DALConnection::Execute,  Description: MySQL: Duplicate entry '66--1-Trash' for key 'idx_hm_imapfolders_unique' (Additional info: INSERT INTO hm_imapfolders (foldercurrentuid, foldercreationtime, folderaccountid, folderparentid, foldername, folderissubscribed) VALUES (0, '2017-08-17 16:18:02', 66, -1, 'Trash', 1))"
Table Lookup:

Code: Select all

SELECT * FROM hmailserver.hm_imapfolders where foldername like 'trash' order by folderaccountid;

folderid	folderaccountid	folderparentid	foldername	folderissubscribed	foldercurrentid
38	4	-1	Trash	1	2011-02-10 17:32:21	115343
47	5	-1	Trash	1	2011-02-18 17:41:31	29822
110	6	-1	Trash	1	2011-02-18 21:21:28	129289
46	7	-1	Trash	1	2011-02-18 17:41:31	402
39	8	-1	Trash	1	2011-02-10 17:37:04	48537
763	9	-1	Trash	1	2011-02-20 00:46:42	240563
59	10	-1	Trash	1	2011-02-18 20:40:54	2
175	11	-1	Trash	0	2011-02-19 10:17:21	21189
176	12	-1	Trash	1	2011-02-19 10:19:40	11966
228	13	-1	Trash	1	2011-02-19 11:01:48	2128
48	14	-1	Trash	1	2011-02-18 17:41:31	2616806
45	19	-1	Trash	1	2011-02-18 17:37:51	38564
473	20	-1	Trash	1	2011-02-19 16:33:53	211274
1202	21	-1	Trash	1	2011-02-21 07:26:26	109172
732	22	-1	Trash	1	2011-02-19 22:04:00	18941
61	23	-1	Trash	1	2011-02-18 20:40:55	31
913	24	24	Trash	1	2011-02-20 10:41:42	9
52	24	-1	Trash	1	2011-02-18 17:46:32	17723
734	25	-1	Trash	1	2011-02-19 22:34:24	28049
968	27	-1	Trash	1	2011-02-20 15:13:08	2706
390	28	-1	Trash	0	2011-02-19 13:50:17	70
392	29	-1	Trash	0	2011-02-19 13:50:38	930
394	30	-1	Trash	0	2011-02-19 14:17:49	171
401	31	-1	Trash	0	2011-02-19 14:18:57	4
1222	32	-1	Trash	1	2011-02-21 09:15:51	2737
397	33	-1	Trash	0	2011-02-19 14:18:48	1481
1221	34	-1	Trash	1	2011-02-21 09:15:51	205
1224	35	-1	Trash	1	2011-02-21 09:16:21	2
1223	36	-1	Trash	1	2011-02-21 09:16:21	2
1457	41	-1	Trash	1	2012-05-22 15:50:23	7
1472	42	-1	Trash	1	2012-06-13 15:01:04	0
1486	43	-1	Trash	1	2012-06-28 17:27:50	16289
1522	44	-1	Trash	1	2012-08-28 14:25:50	0
1561	45	-1	Trash	1	2012-12-03 11:52:59	12176
1728	49	-1	Trash	1	2013-08-29 17:33:47	91
2523	52	-1	Trash	1	2015-10-22 13:49:36	5127
1921	53	-1	Trash	1	2014-06-24 10:12:30	14033
1984	55	-1	Trash	1	2014-11-13 13:23:47	9256
2336	56	-1	Trash	1	2015-05-21 15:57:24	1129
2644	60	-1	Trash	1	2016-04-29 14:47:53	8612
2659	61	-1	Trash	1	2016-05-13 12:58:50	1
2731	62	-1	Trash	1	2016-12-05 10:33:15	2
2834	65	-1	Trash	1	2017-05-22 10:02:33	58
2869	66	-1	Trash	1	2017-08-17 16:12:58	0

Code: Select all

SELECT * FROM hmailserver.hm_imapfolders where folderaccountid = 66;

folderid	folderaccountid	folderparentid	foldername	folderissubscribed	foldercurrentid
2867	66	-1	Drafts	1	2017-08-17 16:03:47	0
2863	66	-1	INBOX	1	2017-08-17 11:30:47	6
2873	66	-1	Junk-E-Mail	1	2017-08-18 08:51:41	0
2866	66	-1	Sent	1	2017-08-17 16:03:29	4
2868	66	-1	Templates	1	2017-08-17 16:03:59	0
2869	66	-1	Trash	1	2017-08-17 16:12:58	0
How can I fix this?

User avatar
mattg
Moderator
Moderator
Posts: 20899
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: MySQL: Duplicate entry ... 'idx_hm_imapfolders_unique'

Post by mattg » 2017-08-18 10:07

Use some database tool (Workbench will do) and remove the duplicate entry, then restart the hMailserver SERVICE
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

estradis
Normal user
Normal user
Posts: 156
Joined: 2014-09-09 10:47

Re: MySQL: Duplicate entry ... 'idx_hm_imapfolders_unique'

Post by estradis » 2017-08-18 10:34

mattg wrote:Use some database tool (Workbench will do) and remove the duplicate entry, then restart the hMailserver SERVICE
Maybe I'm blind, but which one is the duplicate?

User avatar
jimimaseye
Moderator
Moderator
Posts: 8646
Joined: 2011-09-08 17:48

Re: MySQL: Duplicate entry ... 'idx_hm_imapfolders_unique'

Post by jimimaseye » 2017-08-18 13:43

estradis wrote:
mattg wrote:Use some database tool (Workbench will do) and remove the duplicate entry, then restart the hMailserver SERVICE
Maybe I'm blind, but which one is the duplicate?
My guess would be

Code: Select all

2869   66   -1   Trash   1   2017-08-17 16:12:58   0
Your fail is trying to insert the TRASH folder bu the trash folder already exists.
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

estradis
Normal user
Normal user
Posts: 156
Joined: 2014-09-09 10:47

Re: MySQL: Duplicate entry ... 'idx_hm_imapfolders_unique'

Post by estradis » 2017-08-18 15:12

jimimaseye wrote:
estradis wrote:
mattg wrote:Use some database tool (Workbench will do) and remove the duplicate entry, then restart the hMailserver SERVICE
Maybe I'm blind, but which one is the duplicate?
My guess would be

Code: Select all

2869   66   -1   Trash   1   2017-08-17 16:12:58   0
Your fail is trying to insert the TRASH folder bu the trash folder already exists.

Don't know where exactly this came from. I only responded to the alert mail from hMailserver.

I deleted the record from database and adviced the user to delete a previsious received testmail (should have been automatically be moved to trash). This caused the hMailerver to be stopped. After restarting it, we recognized that the testmail was deleted correctly, but not copied to trash before. The error log says twice "Severity: 2 (High), Code: HM5213, Source: PersistentMessage::AddObject, Description: Aborting save since no folder was specified.".

After that I
  • disabled the account
  • copied the account folder below data\domain to temp dir
  • copied the account settings (signature, external accounts, rules, etc.)
  • deleted the account
  • created a new account and reconfigured it
  • moved copied account folder back to data\domain dir
  • run DDS
Fortunatly the user hasn't much mails and no personal folders created herself. So it wasn't a problem that all mails were restored in her inbox folder.

For me this issue is closed so you can nevermind it.
Anyways, thank you for your assistance.

Post Reply