Buggy SELEC ... FROM UPDATE ?
От | Patrice Espié |
---|---|
Тема | Buggy SELEC ... FROM UPDATE ? |
Дата | |
Msg-id | 008101c0c1ca$c47d8990$0400a8c0@univlyon2.fr обсуждение исходный текст |
Ответы |
Re: Buggy SELEC ... FROM UPDATE ?
Re: Buggy SELEC ... FROM UPDATE ? |
Список | pgsql-novice |
Hello, (bis) I try to use SELECT FOR UPDATE, but it seems to be buggy, hum ? Perhaps it's my algorythm... My syslock table: --------------- id integer used boolean --------------- Here is the algo: --------------- boolean Got = false while Got == false Start transaction SELECT * FROM syslock WHERE id=%d AND used='f' FOR UPDATE if SELECT returns a row then UPDATE syslock SET used='t' WHERE id=%d Commit transaction Got = true else Rollback transaction continue // yes, active wait ... I'm testing ! end if end while Trace "I get the syslock number %d !!" Do something with the syslock %d which is now reserved UPDATE syslock SET used='f' WHERE id=%d --------------- When a lot of threads (well, I tried 20, 5 and 2) used this algo, more than one thread get the syslock %d at the same time. What is the problem ? Thanks Patrice Espié -- Le Monde, c'est comme un éléphant qui va à la pêche
В списке pgsql-novice по дате отправления: