Code Monkey home page Code Monkey logo

Comments (4)

dvarrazzo avatar dvarrazzo commented on September 7, 2024

Reading this issue: wouldn't be enough to take a "ACCESS SHARE" lock, which doesn't conflict with anything except the ACCESS EXCLUSIVE taken by ALTER TABLE?

See lock compatibility table.

from pg_reorg.

schmiddy avatar schmiddy commented on September 7, 2024

Yeah, that thought had crossed my mind as well.

The only obstacle is that the LOCK TABLE ... IN ACCESS SHARE MODE would have to be performed in a separate connection, since we want the lock to be held throughout pg_reorg's multiple transactions of work. Then, when it's time to release the ACCESS SHARE lock so that the other connection's ACCESS EXCLUSIVE could go through, we'll have to be careful that there's no one else waiting for a lock on the table who could succeed in altering the table before we acquire our desired ACCESS EXCLUSIVE lock.

It looks like lock_exclusive() is called in two places: first during initial set-up, and lastly before the table swap. We'd want to avoid a race between releasing the first EXCLUSIVE lock and acquiring the ACCESS SHARE lock in the second connection.

from pg_reorg.

schmiddy avatar schmiddy commented on September 7, 2024

I've got a rough implementation of this idea, in my fork at pg_reorg-1.

The basic idea is to set up a second connection which will (asynchronously) try to grab an AccessShare lock while the primary connection still holds AccessExclusive lock during the setup phase. This AccessShare lock is held until step #5, the table swap, when it is bumped to AccessExclusive lock, and the second connection performs the table swapping.

I may well have missed something obvious, and I'll do some more testing and cleanup in the next day or two. If I haven't screwed anything up too badly, perhaps this project could be moved into a branch in reorg master after that.

from pg_reorg.

schmiddy avatar schmiddy commented on September 7, 2024

I tagged this issue with milestone Rel 1.2, since presumably we wouldn't want to shoehorn it into 1.1.x. I'll try to make a branch off the main git repository with these changes. If these changes are OK to merge into master at some point, we could get rid of the forbid_truncate branch and idea, since this feature would of course take care of TRUNCATE as well.

from pg_reorg.

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.