<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to 22: sqlgrey DB insert race condition</title><link>https://sourceforge.net/p/sqlgrey/bugs/22/</link><description>Recent changes to 22: sqlgrey DB insert race condition</description><atom:link href="https://sourceforge.net/p/sqlgrey/bugs/22/feed.rss" rel="self"/><language>en</language><lastBuildDate>Thu, 18 Feb 2010 11:55:58 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/sqlgrey/bugs/22/feed.rss" rel="self" type="application/rss+xml"/><item><title>sqlgrey DB insert race condition</title><link>https://sourceforge.net/p/sqlgrey/bugs/22/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Hi, &lt;/p&gt;
&lt;p&gt;we just started using sqlgrey in a production environment. Its a great tool and has drasticly lowered our incoming spam!&lt;/p&gt;
&lt;p&gt;Im noticing a race condition which is causing a couple of errors per day on our different mailservers, like:&lt;/p&gt;
&lt;p&gt;Feb 18 12:14:29 mx2 sqlgrey: dbaccess: warning: couldn't do query: INSERT INTO from_awl (sender_name, sender_domain, src, first_seen, last_seen) VALUES('x','y','z','2010-02-18 11:59:28',NOW()): , reconnecting to DB&lt;/p&gt;
&lt;p&gt;We currently have a setup with 3 mailservers in every zonefile, same prio. Mail is quite evenly spread over these servers. All the servers use a central sqlgrey database to keep track of the greylisting.&lt;/p&gt;
&lt;p&gt;What happens is, sometimes a mail arrives at mx1 and mx2 at exactly the same time, from the same server and sender. Sqlgrey checks DB from both mailservers and decides the the sender can be added to from_awl. The mailserver which succeeds the first in the resulting INSERT wins. The looser gets an sql error because of the duplicate primary key and decides he needs to reconnect to MySQL and issue an error per e-mail.&lt;/p&gt;
&lt;p&gt;There could be several workarounds for this, maybe disabling the primary key so a duplicatie entry doesn't result in error (dunno if duplicate entries will create other probs). Another option would be to use MySQL  "INSERT....  ON DUPLICATE KEY UPDATE" type query.&lt;/p&gt;
&lt;p&gt;Id like to know if you acknowledge this as a bug or if you have any suggestions.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;br /&gt;
Robin&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Thu, 18 Feb 2010 11:55:58 -0000</pubDate><guid>https://sourceforge.net5a8d8f379e90c12c2c0a952baf6dfaea3c3c18b2</guid></item></channel></rss>