On Wednesday, September 28, 2016 at 3:58:10 AM UTC-7, Pierre wrote:
>
> Hi ,
>
>
> I noticed an unexpected behaviour when running two scheduler processes.
>
>
> The situation is this :
>
>
> A db  with a table  like :
>
>
> db.define_table('taba',
>  Field('fa', unique=True, requires = IS_NOT_IN_DB(db,'taba.fa')), 
>  Field('fb'))
>
>
>
> a task (same function different args) distributed to the processes which 
> contains a :
>
>
> ret = db.taba.validate_and_insert(fa='something', fb='somethingelse')
>
>
> this generates an exception like so :
>
>
> File "/opt/web2py/gluon/packages/dal/pydal/objects.py", line 737, in 
> validate_and_insert 
>  response.id = self.insert(**new_fields) 
>  File "/opt/web2py/gluon/packages/dal/pydal/objects.py", line 712, in 
> insert 
>  ret = self._db._adapter.insert(self, self._listify(fields)) 
>  File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 739, 
> in insert 
>
>  raise e 
> IntegrityError: duplicate key value violates unique constraint 
> "taba_fa_key" 
>
> DETAIL: Key (fa)=(something) already exists. 
>
>
>
> and task fails
>
>
> This doesn't happen when running a single scheduler process so I guess the 
> two scheduler processes collide(….they try to write the same value to the 
> db at the same time……)
>
>
> how do I fix this ? Why can't the two processes cooperate ? Am I limited 
> to running a single sched process ?
>

What do you mean by 2 sched processes?  Are you calling 
schedule=Scheduler(db, migrate=False)
twice?  I don't think you're supposed to do that.

There can be a variable number of workers, and ISTR that the default is 4.

If you aren't instantiating twice, then the next question is how are you 
queuing your tasks?  Are you queuing tasks from a controller?  From a 
script?

/dps



 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to