Project

General

Profile

Actions

Defect #36395

open

Mailer.with_synched_deliveries is not thread-safe

Added by Holger Just almost 3 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Email notifications
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

The Mailer.with_synched_deliveries method sets global state (that is: the queue adapter used to queue new jobs) for the duration of the block.

This affects the global state of all concurrent threads, rather than just the current thread. If a multi-threaded application server or queueing system is in use (such as puma or resque), this can result in unintended consequences such as jobs not scheduled to the "normal" queuing system or errors being raised (if a job is supposed to be scheduled for a fixed later time which is not supported by the InlineAdapter).

As such, the method should be updated to only have a thread-local effect. This may possibly be achieved by introducing a fixed queue adapter wrapper which forwards requests to enqueue jobs to either the "normal" async adapter or the inline adapter based on a thread-local variable set by Mailer.with_synched_deliveries.


Related issues

Related to Redmine - Defect #36393: Mailer.with_synched_deliveries doesn't correctly detect other async Queue adaptersClosedGo MAEDA

Actions
Actions

Also available in: Atom PDF