提交 30e4c199 编写于 作者: E Edouard CHIN

Don't run concurrent transaction test on sqlite3:

- #37798 had to be reverted because a new flakyness appeared ([see
  CI build](https://buildkite.com/rails/rails/builds/65467#efaa1dd5-aaf4-43a1-a204-d1c42abf614d))

  This failure isn't related to the change itself.
  If you apply this diff, the test will some time to time fail.
  Even without my changes.

  ```diff
  diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb
index b5c1cac3d9..09fe0ddd7f 100644
--- a/activerecord/test/cases/transactions_test.rb
+++ b/activerecord/test/cases/transactions_test.rb
@@ -1127,7 +1127,6 @@ def test_no_automatic_savepoint_for_inner_transaction
   end
 end if Topic.connection.supports_savepoints?

-if ActiveRecord::Base.connection.supports_transaction_isolation?
   class ConcurrentTransactionTest < TransactionTest
     # This will cause transactions to overlap and fail unless they are performed on
     # separate database connections.
@@ -1198,4 +1197,3 @@ def test_transaction_isolation__read_committed
       assert_equal original_salary, Developer.find(1).salary
     end
   end
-end
  ```

  SQlite3 isn't safe to run in a multi threaded environment unless
  sqlite is compiled with a special flag which isn't our case.
  Ref https://www.sqlite.org/threadsafe.html
上级 28d77fa5
......@@ -75,7 +75,7 @@ def exec_delete(sql, name = "SQL", binds = [])
alias :exec_update :exec_delete
def begin_isolated_db_transaction(isolation) #:nodoc
raise ArgumentError, "SQLite3 only supports the `read_uncommitted` transaction isolation level" if isolation != :read_uncommitted
raise TransactionIsolationError, "SQLite3 only supports the `read_uncommitted` transaction isolation level" if isolation != :read_uncommitted
raise StandardError, "You need to enable the shared-cache mode in SQLite mode before attempting to change the transaction isolation level" unless shared_cache?
Thread.current.thread_variable_set("read_uncommitted", @connection.get_first_value("PRAGMA read_uncommitted"))
......
......@@ -19,7 +19,7 @@ class SQLite3TransactionTest < ActiveRecord::SQLite3TestCase
test "raises when trying to open a transaction in a isolation level other than `read_uncommitted`" do
with_connection do |conn|
assert_raises(ArgumentError) do
assert_raises(ActiveRecord::TransactionIsolationError) do
conn.transaction(requires_new: true, isolation: :something) do
conn.transaction_manager.materialize_transactions
end
......
......@@ -10,8 +10,6 @@ class Tag < ActiveRecord::Base
end
test "setting the isolation level raises an error" do
skip if current_adapter?(:SQLite3Adapter)
assert_raises(ActiveRecord::TransactionIsolationError) do
Tag.transaction(isolation: :serializable) { Tag.connection.materialize_transactions }
end
......
......@@ -1127,7 +1127,7 @@ def test_no_automatic_savepoint_for_inner_transaction
end
end if Topic.connection.supports_savepoints?
if ActiveRecord::Base.connection.supports_transaction_isolation? && !in_memory_db?
if ActiveRecord::Base.connection.supports_transaction_isolation? && !current_adapter?(:SQLite3Adapter)
class ConcurrentTransactionTest < TransactionTest
# This will cause transactions to overlap and fail unless they are performed on
# separate database connections.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册