On 7/30/2014 6:28 AM, ML mail wrote:
Hi,
I am using a PostgreSQL database to store the AutoWhiteList entries
but from time to time I see in my PostgreSQL log file the following
entries:
2014-07-30 12:07:42 CEST ERROR: duplicate key value violates unique
constraint "awl_pkey"
2014-07-30 12:07:42 CEST DETAIL: Key (username, email, signedby,
ip)=(amavis, em...@domain.tld, , none) already exists.
2014-07-30 12:07:42 CEST STATEMENT: INSERT INTO awl
(username,email,ip,count,totscore) VALUES ($1,$2,$3,$4,$5)
It looks like SpamAssassin tries to INSERT an entry (e-mail address)
which already exists. Shouldn't SpamAssassin AWL code first check if
an entry exists or not and use UPDATE instead of INSERT if an entry
already exists?
Regards
ML
What's your database layout? SA's pg awl layout using a primary key on
all 4 items PRIMARY KEY (username,email,signedby,ip). However, I
think that your example that it's just email address is not a cut and paste.
So beyond that, based on add_score, the behavior you are seeing is expected:
# try inserting first, and if that fails we'll do the update; this way
# we avoid to large extent a race condition between multiple processes
Not saying there isn't a better way to do it but it does seem to be on
purpose.
Regards,
KAM