On 02/19/2013 03:04 AM, Anssi Kääriäinen wrote: > I hope this discussion is about what to do at request finish/start > time. > > I am very strongly opposed to anything where Django suddenly changes > connections underneath you. At request finish/start this is OK (you > should expect new connections then anyways), but otherwise if you get > broken connection, it isn't Django's business to swap the connection > underneath you.
I agree completely. I assumed we were talking about closing the connection at request-finished time, which would cause a new one to be opened on the next request. > I think a good approach would be to mark the connection potentially > broken on errors in queries, and then in request_finished check for > this potentially broken flag. If flag set, then and only then run > ping() / select 1. So, this is a slight modification of no. 3 where > one can mark the connection potentially broken liberally, but the > connection is swapped only when the ping fails, and only in > request_finished. For most requests there should be no overhead as > errors in queries are rare. I like this idea. The ping is a minimal cost if you only pay it when there is a query error during the request, and it's more reliable than trying to parse error messages to figure out which ones require closing the connection. I think we should exclude some classes of errors that we already distinguish and know they don't mean the connection is broken (e.g. IntegrityError). If some codebase makes heavy use of algorithms like get_or_create that rely on a correctly-handled IntegrityError, they shouldn't need to pay the cost of the ping more frequently. Carl -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers?hl=en. For more options, visit https://groups.google.com/groups/opt_out.