Обсуждение: [ADMIN] postgresql : could not serialize access due to read/writedependencies among transactions
[ADMIN] postgresql : could not serialize access due to read/writedependencies among transactions
От
Neslisah Demirci
Дата:
Hi ,
I have problem about this issue ;
could not serialize access due to read/write dependencies among transactions
A message app like whatsapp i decided to use isolation level serializable if i use other transaction levels many conversations started with same number (think about whatsapp web sidebar multipling with same number every message).
I also add an index to my query and my query's execution plan don't use seq scan .
How can i solve this issue ? Can i solve this on db orr on app ?
Neslişah Demirci | Veritabanı Yöneticisi
Ayazağa cad. No:4 Uniq İstanbul Plaza
B2 /Kat:3 34396 Ayazağa-SARIYER-İstanbul
T. (+90) 212 453 16 00 – 5516
F. (+90) 212 453 16 16
www.markafoni.com
www.facebook.com/markafoni
T. (+90) 212 453 16 00 – 5516
F. (+90) 212 453 16 16
www.markafoni.com
www.facebook.com/markafoni
blog.markafoni.com
On Tue, Jan 17, 2017 at 10:54 PM, Neslisah Demirci <neslisah.demirci@markafoni.com> wrote: > could not serialize access due to read/write dependencies among > transactions > I also add an index to my query and my query's execution plan > don't use seq scan . These two issues are likely to be somewhat related -- if a sequential scan is used, then any write to that table by another connection causes a read-write dependency (a/k/a rw-conflict), which can eventually contribute to a serialization failure. If you can cause narrower access through indexes, you may see a significant drop in the frequency of these serialization failures. You might want to post the query and its execution plan with all the information suggested here (exact pg version, configuration information, machine descriptions, etc.): https://wiki.postgresql.org/wiki/SlowQueryQuestions On the other hand, if you are going to use serializable transactions (or even repeatable read transactions) you should probably be using some framework that can retry the transaction from the start on a serialization failure. You might be interested in this set of examples of how serializable transactions differ from repeatable read: https://wiki.postgresql.org/wiki/SSI And of course, if you haven't already read the fine manual on the topic: https://www.postgresql.org/docs/current/static/mvcc.html -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Re: [ADMIN] postgresql : could not serialize access due to read/writedependencies among transactions
От
"Gunnar \"Nick\" Bluth"
Дата:
Am 01/18/2017 um 05:54 AM schrieb Neslisah Demirci: > Hi , > > > I have problem about this issue ; > > > could not serialize access due to read/write dependencies among transactions That's something you have to expect when using SERIALIZABLE isolation level. Maybe re-read https://www.postgresql.org/docs/current/static/transaction-iso.html#XACT-SERIALIZABLE > A message app like whatsapp i decided to use isolation level > serializable if i use other transaction levels many conversations > started with same number (think about whatsapp web sidebar multipling > with same number every message). Are you not using a sequence for generating these IDs? As those are counting independent of transaction visibility... What you say sounds more like "SELECT max(conversation_id) + 1 AS new_conversation_id FROM ..." > I also add an index to my query and my query's execution plan don't use > seq scan . > > > How can i solve this issue ? Can i solve this on db orr on app ? a) switch to a sequence for generating these IDs (you can go back to a lower isolation level then). You may get holes in the IDs then (on rolled back transactions), but I don't see how that would not be acceptable for conversation IDs b) deal with it in the app (probably not what you want, think roud-trip time) > Neslişah Demirci | Veritabanı Yöneticisi > > Ayazağa cad. No:4 Uniq İstanbul Plaza > B2 /Kat:3 34396 Ayazağa-SARIYER-İstanbul > T. (+90) 212 453 16 00 – 5516 > F. (+90) 212 453 16 16 > www.markafoni.com <http://www.markafoni.com/> > www.facebook.com/markafoni <http://www.facebook.com/markafoni> > blog.markafoni.com > > > Regards, -- Gunnar "Nick" Bluth DBA ELSTER Tel: +49 911/991-4665 Mobil: +49 172/8853339