Skip to content

March SFPUG: Foreign Key Locks and their Discontents

Photo of Josh Berkus
Hosted By
Josh B. and Miho
March SFPUG: Foreign Key Locks and their Discontents

Details

What: how to avoid FK deadlocks

Who: CB, DBA at Etsy.com

When: 7pm Tuesday March 15th

Where: EZRez offices (address will be updated)

Food & drink Sponsored by EZRez, but only if you RSVP!

EzRez: the leader in online travel booking services: http://ezrez.com

Description:

I am a Database Engineer at Etsy.com, a major online consumer retail site. We've long experienced problems with deadlocks that involved ShareLocks that the application was not explicitly making. It turns out that Postgres itself was creating the ShareLocks, as part of the way it enforces referential integrity of foreign key constraints. This is not well documented, and little understood amongst Postgres users, but it has caused us grief, and no doubt others; this can be a problem even with very simple schemas and applications. Our own experience at Etsy has led us to gain an understanding of how Postgres creates these ShareLocks, and how to recognize that they may be causing deadlocks. We have found that once recognized, these deadlocks can be avoided with relatively small changes to the application code. The presentation will describe the phenomoenon, and how to recognize its signature pattern in the postgres logs, and how to design or update an application to avoid the problem.

Photo of The San Francisco Bay Area PostgreSQL Meetup Group group
The San Francisco Bay Area PostgreSQL Meetup Group
See more events
ezRez Software, Inc
601 Montgomery Street, 17th Floor · San Francisco, CA