Coder Social home page Coder Social logo

deadlock in delete_from_account about forget HOT 3 CLOSED

codl avatar codl commented on August 11, 2024
deadlock in delete_from_account

from forget.

Comments (3)

stale avatar stale commented on August 11, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from forget.

codl avatar codl commented on August 11, 2024

hello. i think i've figured this out. it looks like postgres does not lock all the rows in a SELECT .. FOR UPDATE at once atomically. since we order rows by random(), this means one transaction might lock post A and then post B, while another locks post B and then post A

one way to fix this, since we only need a random sample of posts and don't necessarily need all 100 posts that were picked, would be to SELECT ... FOR UPDATE SKIP LOCKED which would just skip rows that were already locked, and avoid a deadlock

however i think there is a larger problem here. it seems unwise to lock a hundred rows and then go off making potentially slow http requests, up to 101 of them in mastodon's case

from forget.

codl avatar codl commented on August 11, 2024

btw the reason why we lock those rows FOR UPDATE is because of an other similar deadlock that would happen without that explicit lock. not sure why that one would happen but it is likely that it was because of locking in random order as well

06bf189

from forget.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.