Fair question we did think about. Short answer is that it should not happen in practice, although in

Fair question we did think about. Short answer is that it should not happen in practice, although in theory it is possible.
There is a very rare case that attempt 1 executed on the underlying database, published stats about rows read/written, and then the response failed to be returned back to our D1 worker (what your code is calling through the D1 worker binding), so the worker will retry the query.
In our experience with the errors we see is that the vast majority of them is literally not even reaching the database in the first place (or failing before start execution), and the retries are meant to solve that problem mostly in case of transient errors. Also, if the response failed to come back to us, probably the retry will fail too since it is probably a network issue.

I haven't notice this being an issue in a few accounts I have been spot checking over the past few weeks, but please, if you do notice in your case some billing issue, let us know. We are still monitoring the retry success ratios and considering more improvements to do over time, so any feedback is welcome.

Remember, D1 is not billing on requests, but on actual rows read and written successfully.
Was this page helpful?