| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This ensures multiple threads inside a transactional test to see consistent
database state.
When a system test starts Puma spins up one thread and Capybara spins up
another thread. Because of this when tests are run the database cannot
see what was inserted into the database on teardown. This is because
there are two threads using two different connections.
This change uses the statement cache to lock the threads to using a
single connection ID instead of each not being able to see each other.
This code only runs in the fixture setup and teardown so it does not
affect real production databases.
When a transaction is opened we set `lock_thread` to `Thread.current` so
we can keep track of which connection the thread is using. When we
rollback the transaction we unlock the thread and then there will be no
left-over data in the database because the transaction will roll back
the correct connections.
[ Eileen M. Uchitelle, Matthew Draper ]
|
|
|
|
|
| |
Fixes #27826
Refer https://github.com/rails/rails/commit/f7b317175430a2d9300d9c4acfc1f34f4fdb2fbc
|
| |
|
| |
|
|
|
|
|
|
|
| |
active_connections
clearing AR::Base's active_connections on the "primary" pool loses connections to the in_memory DB
when running sqlite3_mem tests
|
| |
|
|\
| |
| | |
Add explicit testing for `uncached` vs. `cached`
|
| |
| |
| |
| |
| |
| | |
There are a ton of middleware related tests in this file, and it seems
like `cached vs. `uncached` is being neglected. Added in a test to
confirm the expected behavior.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
make sql statements frozen
dup if arel is not our string
expect runtime error
dont wrap runtime error in invalid
log errors will now be treated as runtime errors
update changelog
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
It doesn't make sense for the query cache to persist while a connection
moves through the pool and is assigned to a new thread.
[Samuel Cochran & Matthew Draper]
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This executor currently relies on `ActiveRecord::Base.connection` not
changing between `prepare` and `complete`. If something else returns
the current ActiveRecord connection to the pool early then this
`complete` call will fail to clear the correct query cache and restore
the original `query_cache_enabled` status.
This has for example been happening in Sidekiq:
https://github.com/mperham/sidekiq/pull/3166
We can just keep track of the connection as part of the exector state.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Query cache doesn't type cast bind parameters since it isn't
actually querying the database, so it can't pass those values in. Type
casting in the query cache method would cause the values to be type cast
twice in the case that there is a cache miss (since the methods it calls
will type cast *again*). If logging is disabled, then adding the type
cast code to the query cache method will needlessly typecast the values
(since the only reason those values are type cast is for display in the
logs).
Fixes #26828.
|
| |
| |
| |
| | |
https://bugs.ruby-lang.org/issues/12739
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This is fixed in 5.0 as an ancillary part of 574f255629a45cd67babcfb9bb8e163e091a53b8
but here I also add a test for the condition.
I'd previously backported the fix (and added a test) in the below
commit; this brings the fix back up to master.
(cherry picked from commit fce3dbf30241f2a65c777e192a7171b0eea81453)
|
| |
| |
| |
| |
| | |
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
|
| |
| |
| |
| |
| |
| | |
Follow up to #20818.
`retrieve_connection` is passed `spec_name` instead of `klass` since #24844.
|
|/
|
|
|
|
|
|
| |
This method appears to have been partially used in connection pool
caching, but it was introduced without much reasoning or any tests. One
edge case test was added later on, but it was focused on implementation
details. This method is no longer used outside of tests, and as such is
removed.
|
| |
|
|
|
|
|
|
| |
Before we enable query caching we check if the connection is
connected. Before this fix we were always checking against the main
connection, and not the model connection.
|
| |
|
|
|
|
|
|
|
|
| |
Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005
* Forward compat with new unified Integer class in Ruby 2.4+.
* Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3.
* Drops needless Fixnum distinction in docs, preferring Integer.
|
|
|
|
|
|
| |
These should allow external code to run blocks of user code to do
"work", at a similar unit size to a web request, without needing to get
intimate with ActionDipatch.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The type map was introduced in aafee23, but wasn't properly filled.
This mainly adjusts many locations, that expected strings instead of
integers or boolean.
add_pg_decoders is moved after setup of the StatementPool, because
execute_and_clear could potentially make use of it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit ff18049ca6f27deb7e7f955478e1464f8d756332.
This broke the AR build for every adapter:
1) Error:
AssociationCallbacksTest#test_dont_add_if_before_callback_raises_exception:
Exception: You can't add a post
2) Failure:
QueryCacheTest#test_query_cache_doesnt_leak_cached_results_of_rolled_back_queries [/Users/senny/Projects/rails/activerecord/test/cases/query_cache_test.rb:235]:
Expected: 1
Actual: 0
I'm reverting to get the build green again.
|
| |
|
| |
|
|
|
|
|
| |
[fixes #14361]
[related #13886]
|
|
|
|
|
|
|
|
|
|
|
|
| |
This solves order dependent issues where the last test
leaked the query cache state. This resulted in the following error:
```
QueryCacheExpiryTest#test_cache_is_expired_by_habtm_delete [test/cases/query_cache_test.rb:275]:
not all expectations were satisfied
unsatisfied expectations:
- expected exactly twice, invoked once: #<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x7f93e0c65838>.clear_query_cache(any_parameters)
```
|
|
|
|
|
|
| |
already have cache true.
This commit takes into account the last cache_enabled value, before clearing query_cache.
|
| |
|
|
|
|
| |
also DATABASE_URL.
|
| |
|
| |
|
|
|
|
|
|
|
| |
non-prepared statements
Conflicts:
activerecord/test/cases/query_cache_test.rb
|
|
|
|
| |
Fixes #867
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
prepared statement cache
|
| |
|
|
|
|
|
| |
This Sqlite3 should be in if block.
Was giving error because sqlite3 is not loaded
|
|
|
| |
for Sqlite3 in AR-JDBC.It's Jdbc::SQLite3::VERSION
|
| |
|
| |
|
|
|
|
| |
Rack::Sendfile to function properly. See issue #1761.
|