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

[Transactions issue] #destroy hanging after another action inside a transaction #73

Open
arturantonnikau opened this issue Mar 7, 2024 · 0 comments

Comments

@arturantonnikau
Copy link
Contributor

arturantonnikau commented Mar 7, 2024

Hello!
When we have document class like this

class Document
  include Mongoid::Document
  include Mongoid::Paranoia

  store_in collection: 'documents'

  field :timestamps, type: Array, default: []
end

and then we want to perform some actions wrapped in a transaction

document = Document.create

document.with_session do |session|
  session.with_transaction(write_concern: {w: :majority}) do
    document.push(timestamps: Time.now)
    document.destroy
  end
end

when we try to perform this code after occurring document.destroy this will hanging ~ 30 seconds and then we see an error
Снимок экрана 2024-03-08 в 01 25 02

it happens coz we should perform all operations inside the transaction using the same session

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

No branches or pull requests

1 participant