Giter VIP home page Giter VIP logo

Comments (10)

mquan avatar mquan commented on May 29, 2024 1

thanks a lot for your quick responses, I'm closing the ticket since both problems originated from my side

from isolator.

palkan avatar palkan commented on May 29, 2024

I believe the first problem is the mailer adapter doesn't recognize

What is delay? Sidekiq delay extensions or delayed_job? If you use delayed_job then it shouldn't raise, since delaying the execution means storing the record in the DB, and thus it only "survives" if the transaction commits.

my expectation is error shouldn't be thrown because send_second_email it's done after the transaction in after_commit

Correct. The bug is probably with the transaction detection in test env. Have you tried to run the create code in dev mode (i.e., in rails c)? Do you use transactional_tests or DatabaseCleaner?

from isolator.

mquan avatar mquan commented on May 29, 2024

What is delay?

It's sidekiq delay extensions

Have you tried to run the create code in dev mode (i.e., in rails c)?

Yes, things are working as expected in dev (aside from delay problem above)

Do you use transactional_tests or DatabaseCleaner?

DatabaseCleaner. I dug a little deeper and found that before the actual test portion, Isolator.transactions_threshold is 2 and Thread.current.fetch(:isolator_transactions, 0) is also 2. So it makes sense that send_second_email triggers an error. I believe this is a problem on my side, there's one more layer of transaction wrapped in my test setup somewhere.

from isolator.

palkan avatar palkan commented on May 29, 2024

Isolator.transactions_threshold is 2

Could you share your DatabaseCleaner configuration?

Which Rails version do you use, btw?

It's sidekiq delay extensions

We probably need some tests for this case first)

from isolator.

mquan avatar mquan commented on May 29, 2024

Could you share your DatabaseCleaner configuration?

RSpec.configure do |config|
  config.around do |example|
    # this is for ar_after_transaction: https://github.com/grosser/ar_after_transaction#transactional-fixtures---normally_open_transactions
    ActiveRecord::Base.normally_open_transactions = 0

    example.run
    DatabaseCleaner.clean_with(:truncation, pre_count: true)
  end
end

Which Rails version do you use, btw?

5.1.7 (ruby 2.6.5)

from isolator.

palkan avatar palkan commented on May 29, 2024

Could you try disabling ar_after_transaction? They do some AR monkey-patching, probably, incompatible with Isolator.

P.S. Btw, there is a better alternative to this gem which uses AR API with zero monkey-patching: https://github.com/Envek/after_commit_everywhere.

from isolator.

mquan avatar mquan commented on May 29, 2024

Could you try disabling ar_after_transaction?

Disabling it didn't help. But I workaround it by adding 1 more to Isolator.transactions_threshold in test environment. It's not a permanent solution but at least it allows me to run tests and identify the true violations.

Any word on supporting sidekiq delay extensions (the first problem)?

from isolator.

palkan avatar palkan commented on May 29, 2024

Any word on supporting sidekiq delay extensions (the first problem)?

Couldn't reproduce (see the test).
Could you please try to write a single file reproduction script (e.g., using a Rails bug report template)?

from isolator.

palkan avatar palkan commented on May 29, 2024

Which version of DatabaseCleaner do you use? Is it 1.8.0+ (it has a lot of internal changes)?

from isolator.

mquan avatar mquan commented on May 29, 2024

I figured out the mystery with sidekiq delay extension problem. We have an override that defers delay call to after transaction, so it makes sense that isolator doesn't throw error when enqueuing jobs with .delay

from isolator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.