-
Notifications
You must be signed in to change notification settings - Fork 565
BUG REPORT: Transaction Rollback Not Triggered (COMMIT Instead of ROLLBACK) #1332
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
Comments
Do you need any additional information? @aidanharan |
@maxingjia1314 Could you reproduce the issue using a script? See https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/How-to-report-a-bug#minimal-reproducible-script |
I used the same configuration information as my development environment in the test code, but it reported an error and cannot continue execution: # minimal_repro.rb
require "bundler/inline"
gemfile(true) do
source 'https://gems.ruby-china.com'
gem "tiny_tds", "2.1.7"
gem "activerecord", '7.0.8.6'
gem "activerecord-sqlserver-adapter", "7.0.7"
end
require "active_record"
require "minitest/autorun"
require "logger"
ActiveRecord::Base.establish_connection(
adapter: "sqlserver",
timeout: 5000,
pool: 100,
encoding: "utf8",
database: "SWtest20240416",
username: "sa",
password: "3one@2024!",
host: "192.168.28.102",
port: 1433
)
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
drop_table(:bug_tests) rescue nil
create_table :bug_tests, force: true do |t|
t.bigint :external_id
t.string :name
end
end
class BugTest < ActiveRecord::Base
end
class TestBugTest < Minitest::Test
def setup
@bug_test = BugTest.create!(name: "Test Record")
end
end |
Include gemfile(true) do
source 'https://gems.ruby-china.com'
gem "logger"
gem "tiny_tds", "2.1.7"
gem "activerecord", '7.0.8.6'
gem "activerecord-sqlserver-adapter", "7.0.7"
end Also, note that support for v7.0 of the adapter has ended. See https://github.com/rails-sqlserver/activerecord-sqlserver-adapter?tab=readme-ov-file#about-the-adapter |
BUG REPORT: Transaction Rollback Not Triggered (COMMIT Instead of ROLLBACK)
1. Problem Description
When using
activerecord-sqlserver-adapter
, transactions are not rolled back as expected when an exception (ActiveRecord::Rollback
or standard exceptions) is raised within a transaction block. Instead, the transaction is committed (log showsCOMMIT TRANSACTION
), leading to data inconsistency.
2. Steps to Reproduce
3. Expected Behavior
ActiveRecord::Rollback
or any other exception), the transaction should be rolled back (log showsROLLBACK TRANSACTION
), and no changes should persist in the database.
4. Actual Behavior
COMMIT TRANSACTION
), and data is persisted in the database despite the exception.
5. Environment Information
7.0.7
7.0.8.6
3.3.3
2014
config/database.yml
:
6. Logs
Provide the full log snippet (redact sensitive info):
7. Solutions Already Tried
begin_transaction
/commit_transaction
withActiveRecord::Base.transaction
.ActiveRecord::Rollback
explicitly.options: "XACT_ABORT=true"
todatabase.yml
.activerecord-sqlserver-adapter
to the latest version (runbundle update activerecord-sqlserver-adapter
).
8. Additional Notes
9. Attachments
10. Request for Help
Please help confirm:
activerecord-sqlserver-adapter
?XACT_ABORT
configuration or transaction isolation levels?
The text was updated successfully, but these errors were encountered: