Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Real concurrency spec for ActiveRecord #196

Closed

Conversation

marshall-lee
Copy link

This one should fail. It should prove that current implementation is not actually concurrent. It ignores :pool ActiveRecord parameter making ConnectionPool useless.

@marshall-lee marshall-lee changed the title Real concurrency spec for ActiveEecord Real concurrency spec for ActiveRecord Mar 18, 2015
@marshall-lee
Copy link
Author

It fails as expected. RSpec outputs just what i say in #190:

 Failure/Error: expect(Widget.connection_pool.connections.size).to eq(10)

   expected: 10
        got: 1

@marshall-lee
Copy link
Author

It happens because in current implementation current_connection_id is still Thread.current.object_id. Now lets try to change it to Fiber.current.object_id

@marshall-lee
Copy link
Author

Not it fails too but for another reason:

 ActiveRecord::ConnectionTimeoutError:
   could not obtain a database connection within 5.000 seconds (waited 5.000 seconds)

So current connection pool just sucks

@marshall-lee
Copy link
Author

Sorry, it works. I just realized that ActiveRecord's connection pool contains only one connection but this connection is actually a pool itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant