EasyPost / pystalk

Simple python Beanstalkd client
ISC License
12 stars 4 forks source link

Multiple workers reserved the same tickets #13

Open tfMovamo opened 4 years ago

tfMovamo commented 4 years ago

Hello, Unfortunately, I can't tell if it's a general beanstalk problem, a bug in here, or in my script.

I have 20 or more workers running (Python 3.6) who get tickets from a tube.


self.beanstalkdConnection.use('imageupload')
self.beanstalkdConnection.watch('imageupload')
self.beanstalkdConnection.ignore('default')

ticket = self.beanstalkdConnection.reserve(1)

if ticket is None:
            print('no jobs')
            return None
else:
            ticketId = ticket.stats().get('id')

            if self.mclient.get(str(ticketId)) == None:
                self.mclient.set(str(ticketId), 'in_work', 60)
            else:
                print('no jobs - ticket ' + str(ticketId) + " in progress")
                return None

            ticket.touch()
            self.progress(ticket)
            ticket.delete()

worker 1 reserved the ticket, but all other (19 workers) will reserved this ticket too and give out: 'no jobs - ticket xxxx in progress".

The ttl for an ticket is 500 when i put it into the queue.

Am I doing something wrong? Or is there actually a bug?

greets Timo

Roguelazer commented 3 years ago

Most likely either you've found a beanstalk bug, or something is making you block for long enough to break the TTR.

One thing I'll note is that this library isn't fork-safe, so if you're connecting to beanstalk prior to forking you may have unusual issues.

Justintime50 commented 1 year ago

@tfMovamo it's been a bit since this was reported. Were you able to find a fix or is this still an issue for you?