Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Add LockedUntil column #1

Merged
merged 3 commits into from
Apr 17, 2015
Merged

Add LockedUntil column #1

merged 3 commits into from
Apr 17, 2015

Conversation

lmars
Copy link

@lmars lmars commented Apr 12, 2015

If a job's connection dies, then the advisory lock will be released and another worker can lock the job and start working it, leading to a situation where multiple workers could be working the same job.

This change minimises that risk by adding a locked_until column which is bumped in a goroutine whilst a job is being worked, so even if the advisory lock goes away, the job can remain locked until it is done.

Signed-off-by: Lewis Marshall <lewis@lmars.net>
There is no guarantee that the `finished` variable will get set by the
goroutine before it is checked in the test, so wait for a channel close
instead.

Signed-off-by: Lewis Marshall <lewis@lmars.net>
@lmars
Copy link
Author

lmars commented Apr 16, 2015

@titanous updated to use the time from the server, plus some test fixes.

go func() {
for {
stat := c.pool.Stat()
if stat.AvailableConnections == 0 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if c.pool.Stat().AvailableConnections == 0

If a job's connection dies, then the advisory lock will be released and
another worker can lock the job and start working it, leading to a
situation where multiple workers could be working the same job.

This change minimises that risk by adding a locked_until column which is
bumped in a goroutine whilst a job is being worked, so even if the
advisory lock goes away, the job can remain locked until it is done.

Signed-off-by: Lewis Marshall <lewis@lmars.net>
@lmars
Copy link
Author

lmars commented Apr 17, 2015

@titanous comments addressed

@titanous
Copy link

LGTM

lmars added a commit that referenced this pull request Apr 17, 2015
@lmars lmars merged commit c79d63e into master Apr 17, 2015
@lmars lmars deleted the locked_until branch April 17, 2015 00:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants