Skip to content

Instantly share code, notes, and snippets.

/lock.diff Secret

Created June 25, 2017 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/ba26328aa96b7c823976d44c7b221a14 to your computer and use it in GitHub Desktop.
Save anonymous/ba26328aa96b7c823976d44c7b221a14 to your computer and use it in GitHub Desktop.
diff --git a/lib/Minion/Backend/Pg.pm b/lib/Minion/Backend/Pg.pm
index 86d73d1..0817e10 100644
--- a/lib/Minion/Backend/Pg.pm
+++ b/lib/Minion/Backend/Pg.pm
@@ -949,7 +949,9 @@ begin
if (select count(*) >= $3 from minion_locks where name = $1) then
return false;
end if;
- insert into minion_locks (name, expires) values ($1, new_expires);
+ if new_expires > now() then
+ insert into minion_locks (name, expires) values ($1, new_expires);
+ end if;
return true;
end;
$$ language plpgsql;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment