Thread

  1. BUG #7594: "tuple concurrently updated" error on concurrent GRANT ON DATABASE statements

    Reinhard Max <max@suse.de> — 2012-10-10T16:02:05Z

    The following bug has been logged on the website:
    
    Bug reference:      7594
    Logged by:          Reinhard Max
    Email address:      max@suse.de
    PostgreSQL version: 9.1.6
    Operating system:   openSUSE
    Description:        
    
    Is it intentional, that concurrent GRANT statements for the same database
    may result in a "tuple concurrently updated" error?
    
    It can be reproduced by running the following loop from two shells at the
    same time:
    
    while true; do psql -c "GRANT ALL ON DATABASE foo TO foo" ; done
    
    I found that wrapping the GRANT statement in a transaction and explicitly
    locking pg_table in SHARE UPDATE EXCLUSIVE mode makes the error disappear.
    According to the documentation of the lock modes, statements like VACUUM
    acquire this lock by itself, so I wonder if GRANT ON DATABASE should do the
    same.