Skip to content

Add database backend for ActiveJob delayed job handling and use it #2193

Closed
@david-a-wheeler

Description

@david-a-wheeler

We need to add a database backend for delayed job handling and then use it. I believe this will address some caching problems as well as improve scaling. This description goes over the issues.

First: Every once in a great while a cached image is not updated in a timely way. E.g.: #2186 and #2072 . When we update a value, we do send out a cache invalidation for that badge image. I've been trying to track down the problem, and I don't think there's a race condition inside the application. So I believe there's a race outside. I think what's happening is that packets sent from our application to our CDN (Fastly) are being sent in parallel, and in some circumstances the first one sent is the second received (from the point of view of "will be acted on"). Basically, someone requests an image and we send a cache invalidation. The CDN receives the cache invalidation and then the old image, which is now considered the good image. There's also a possibility of races within the CDN, too. I don't control the entire Internet, and I certainly don't control packet ordering on it :-).

Our framework (Rails) has a mechanism for supporting delayed jobs called ActiveJob. It has many methods for enqueing. See ActiveJob basics. We use ActiveJob somewhat, but currently its configuration (its default) is RAM-based, which means that any jobs scheduled in it (as currently configured) get lost on a reboot. This has made me hesitant to use it more, e.g., as suggested in #1199 .
ActiveJob supports lots of backends, but if we want it to be backed by a database, we must pick a backend. It's possible to switch backends, but it's a pain (you need to "flip" it), so it's better to pick well the first time.

ActiveJob has a few built-in adapters for backends. However, that's not a complete list, in fact, they no longer accept new adapters because backends can provide their adapters. Another backend that looks promising is GoodJob.

Once we add a database-based backend for jobs, we can do more delayed email deliveries as suggested in #1199 .

I will follow this up with some initial analysis of the backend options I've identified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions