<h3 dir="auto">What version of Go are you using (go version)?</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="jack@edi:~$ go version
go version go1.5beta3 linux/amd64"><pre class="notranslate"><code class="notranslate">jack@edi:~$ go version
go version go1.5beta3 linux/amd64
</code></pre></div>
<h3 dir="auto">What operating system and processor architecture are you using?</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="jack@edi:~$ uname -a
Linux edi 3.13.0-61-generic #100-Ubuntu SMP Wed Jul 29 11:21:34 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux"><pre class="notranslate"><code class="notranslate">jack@edi:~$ uname -a
Linux edi 3.13.0-61-generic #100-Ubuntu SMP Wed Jul 29 11:21:34 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
</code></pre></div>
<h3 dir="auto">What did you do?</h3>
<p dir="auto">Execute a query with database/sql over an unreliable connection. For example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="update t set n=n+1;"><pre class="notranslate"><code class="notranslate">update t set n=n+1;
</code></pre></div>
<h3 dir="auto">What did you expect to see?</h3>
<p dir="auto">An error message that means the query failed and n is unchanged, or no error meaning the query executed exactly one time and n has been incremented by 1.</p>
<h3 dir="auto">What did you see instead?</h3>
<p dir="auto">The query may have actually executed multiple times and thereby n may have been incremented multiple times.</p>
<h3 dir="auto">Reproducing the error</h3>
<p dir="auto">It was necessary to build some infrastructure to reproduce this error. I wrote <a href="https://github.com/jackc/cavein">cavein</a>, a TCP tunnel server that purposely breaks connections to aid in reproduction. That, combined with <a href="https://github.com/jackc/go_database_sql_retry_bug">go_database_sql_retry_bug</a>, a test application that executes many updates over the unreliable connections provided by <a href="https://github.com/jackc/cavein">cavein</a> can reliably reproduce queries being executed extra times.</p>
<h3 dir="auto">Suggested solution</h3>
<p dir="auto">Automatic retry should be removed from Exec and Query. It is impossible at the library layer to know if it is safe to retry a query.</p>
<p dir="auto">when gobind or gomobile fails to generate code, print the source location.</p>