[Koha-bugs] [Bug 30172] BackGround jobs failing due to race condition

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Feb 25 00:48:25 CET 2022


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30172

--- Comment #9 from David Cook <dcook at prosentient.com.au> ---
(In reply to Nick Clemens from comment #7)
> Perhaps:
>  61         my $job = Koha::BackgroundJobs->find($args->{job_id});
>  62         $conn->nack({frame=>$frame}) unless $job;
>  63             process_job( $job, $args );
>  64         $conn->ack( { frame => $frame } ); # FIXME depending on success?
> 
> Though could we end up in a loop? The queue should expire eventually - and
> we could store soemthing in the job about retries when we send nack?

There's a few problems with that suggestion.

First, you'd need an if/else rather than an unless. Otherwise, you're nacking,
then trying to process the job, and then acking. I imagine that was just a typo
though.

Second, as you say, you'll end up in a loop if you nack. I don't think the
message expires either. (Of course, if the issue is just the race condition,
eventually the data should exist, so you'd only loop X times until the database
catches up. Not efficient, especially as you'd be blocking other messages being
processed, but technically functional.)

--

I think the best bet is just to make sure the data is committed to the database
before sending the message. 

(Alternatively, you can make sure that all the data you need is sent in the
message itself, so that there is no race condition, but that can be more
difficult to manage. In terms of managing the result store, you can generate a
UUID, store it in the job table, and use it for storing the result in a
result_store table, and then use the UUID to unite the two later, but that
would be a big refactor I imagine.)

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list