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

fix(locks): Stop enqueuing duplicates job because of default lock TTL #3017

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/jobs/bill_subscription_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class BillSubscriptionJob < ApplicationJob
end
end

unique :until_executed, on_conflict: :log, lock_ttl: 12.hours

retry_on Sequenced::SequenceError, ActiveJob::DeserializationError

def perform(subscriptions, timestamp, invoicing_reason:, invoice: nil, skip_charges: false)
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/invoices/finalize_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class FinalizeJob < ApplicationJob
end
end

unique :until_executed, on_conflict: :log, lock_ttl: 6.hours
unique :until_executed, on_conflict: :log, lock_ttl: 12.hours

retry_on Sequenced::SequenceError, wait: :polynomially_longer

Expand Down
2 changes: 1 addition & 1 deletion app/jobs/wallets/refresh_ongoing_balance_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Wallets
class RefreshOngoingBalanceJob < ApplicationJob
queue_as 'wallets'

unique :until_executed, on_conflict: :log
unique :until_executed, on_conflict: :log, lock_ttl: 12.hours
nudded marked this conversation as resolved.
Show resolved Hide resolved

retry_on ActiveRecord::StaleObjectError, wait: :polynomially_longer, attempts: 6

Expand Down
3 changes: 1 addition & 2 deletions spec/scenarios/subscriptions/free_trial_billing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ def create_usage_event!
expect(customer.reload.invoices.count).to eq(0)

plan.update! trial_period: 0 # disable trial to force billing
BillSubscriptionJob.perform_now(customer.subscriptions, Time.current, invoicing_reason: :subscription_starting)

BillSubscriptionJob.perform_now(customer.subscriptions.to_a, Time.current, invoicing_reason: :subscription_starting)
expect(customer.reload.invoices.count).to eq(1)

plan.update! trial_period: 10
Expand Down
Loading