#3460: postgresql_psycopg2 backend uses wrong isolation level --------------------------------------------------------+------------------- Reporter: Jack Moffitt <metaj...@gmail.com> | Owner: Richard Davies <richard.dav...@elastichosts.com> Status: new | Milestone: Component: Database layer (models, ORM) | Version: SVN Resolution: | Keywords: Stage: Design decision needed | Has_patch: 1 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 1 | --------------------------------------------------------+------------------- Comment (by iamseb):
Following up from nicferrier's patch, there's a corresponding issue when using transaction pooling which must be resolved. INSERT statements followed by SELECT CURRVAL for creating new objects may split the queries over two transactions, and therefore two sessions. The second session will not have the sequence value available. In this case, a far safer route is to use the RETURNING clause in INSERT statements to return the new value for the pk. The attached insertwithreturning.patch adds a new feature to BaseDatabaseFeatures, sets it to true for the psycopg2 backend, and conditionally creates an appropriate RETURNING clause for INSERT statements. This feature is supported for PostgreSQL 8+ with psycopg2 (tested), and Oracle (untested, currently not enabled). With these two patches, correct transaction isolation support for postgres is fully implemented, and scaling issues with lock concurrency and hanging transactions are mitigated. (We've seen >10k locks reduced to <100.) -- Ticket URL: <http://code.djangoproject.com/ticket/3460#comment:25> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---