Skip to content

Add comprehensive locking around DB transactions - #28726

Merged
matthewd merged 1 commit into
rails:masterfrom
matthewd:transaction-locking
Apr 12, 2017
Merged

Add comprehensive locking around DB transactions#28726
matthewd merged 1 commit into
rails:masterfrom
matthewd:transaction-locking

Conversation

@matthewd

Copy link
Copy Markdown
Member

Transactional-fixture using tests with racing threads and inter-thread synchronisation inside transaction blocks will now deadlock... but without this, they would just crash.

In 5.0, the threads didn't share a connection at all, so it would've worked... but with the main thread inside the fixture transaction, they wouldn't've been able to see each other.

So: as far as I can tell, the set of operations this "breaks" never had a compelling use case. Meanwhile, it provides an increased level of coherency to the operational feel of transactional fixtures.

If this does cause anyone problems, they're probably best off disabling transactional fixtures on the affected tests, and managing transactions themselves.

Fixes #28197

Transactional-fixture using tests with racing threads and inter-thread
synchronisation inside transaction blocks will now deadlock... but
without this, they would just crash.

In 5.0, the threads didn't share a connection at all, so it would've
worked... but with the main thread inside the fixture transaction, they
wouldn't've been able to see each other.

So: as far as I can tell, the set of operations this "breaks" never had
a compelling use case. Meanwhile, it provides an increased level of
coherency to the operational feel of transactional fixtures.

If this does cause anyone problems, they're probably best off disabling
transactional fixtures on the affected tests, and managing transactions
themselves.
@matthewd
matthewd requested a review from eileencodes April 10, 2017 22:51
@matthewd matthewd added this to the 5.1.0 milestone Apr 10, 2017
@matthewd

Copy link
Copy Markdown
Member Author

@benoitongit @KeithP are either of you able to confirm this solves the problem in your respective apps? It seemed to make #28197 (comment) happier, at least.

@benoitongit

Copy link
Copy Markdown

Thanks @matthewd! works like a charm for me :)

@KeithP

KeithP commented Apr 12, 2017

Copy link
Copy Markdown
Contributor

Looks okay so far when running tests locally.
But on the build server most tests fail due to a "PG UndefinedTable" error.
Local PostgreSQL version is 9.3; Build server PostgreSQL version is 9.2.

@KeithP

KeithP commented Apr 12, 2017

Copy link
Copy Markdown
Contributor

When combined with PR #28740 this solves the issue for us. Thanks @matthewd

@matthewd
matthewd merged commit 92ba89d into rails:master Apr 12, 2017
matthewd added a commit that referenced this pull request Apr 12, 2017
Add comprehensive locking around DB transactions
@matthewd

Copy link
Copy Markdown
Member Author

90a3ce2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rails 5.1.0.beta1: PG::SEInvalidSpecification: ERROR: no such savepoint

5 participants