title: Acquiring advisory locks in postgres
body: <p>I think there must be something basic I'm not understanding about advisory locking in postgres. If I enter the following commands on the psql command line client, the function returns true both times:</p>
  
  <pre><code>SELECT pg_try_advisory_lock(20); --&gt; true
  SELECT pg_try_advisory_lock(20); --&gt; true
  </code></pre>
  
  <p>I was expecting that the second command should return false, since the lock should already have been acquired. Oddly, I do get the following, suggesting that the lock has been acquired twice:</p>
  
  <pre><code>SELECT pg_advisory_unlock(20); --&gt; true
  SELECT pg_advisory_unlock(20); --&gt; true
  SELECT pg_advisory_unlock(20); --&gt; false
  </code></pre>
  
  <p>So I guess my question is, how does one acquire an advisory lock in a way that stops it being acquired again?</p>