title: PostgreSQL - how to unlock table record AFTER shutdown
body: <p>Sorry I looked for this everywhere but cannot find a working solution :/
  I badly needed this for abnormal testing.</p>
  
  <p>What I'm trying to do here is:</p>
  
  <ol>
  <li>Insert row in TABLE A</li>
  <li>Lock this record</li>
  <li>(At separate terminal) service postgresql-9.6 stop</li>
  <li>Wait a few moments</li>
  <li>(At separate terminal) service postgresql-9.6 start</li>
  <li>"try" to unlock the record by executing "COMMIT;" in the same terminal as #2.</li>
  </ol>
  
  <p>How i did #2 is like this:</p>
  
  <pre><code>BEGIN;
  SELECT * FROM TABLE A WHERE X=Y FOR UPDATE;
  </code></pre>
  
  <p>Problem is that once I did #6, this error shows up:</p>
  
  <pre><code>DB=# commit;
  FATAL:  terminating connection due to administrator command
  server closed the connection unexpectedly
          This probably means the server terminated abnormally
          before or while processing the request.
  The connection to the server was lost. Attempting reset: Succeeded.
  </code></pre>
  
  <p>So when I execute "COMMIT;" again, it only shows:</p>
  
  <pre><code>DB=# commit;
  WARNING:  there is no transaction in progress
  COMMIT
  </code></pre>
  
  <p><strong>Now the record cannot be unlocked.</strong> </p>
  
  <p>I've tried getting the PID of that locking thing, and then execute pg_terminate (or cancel), but it just doesn't work.</p>
  
  <pre><code>DB=# select pg_class.relname,pg_locks.* from pg_class,pg_locks where pg_class.relfilenode=pg_locks.relation;
  DB=# select pg_terminate_backend(2450);
  FATAL:  terminating connection due to administrator command
  server closed the connection unexpectedly
          This probably means the server terminated abnormally
          before or while processing the request.
  The connection to the server was lost. Attempting reset: Succeeded.
  DB=# select pg_cancel_backend(3417);
  ERROR:  canceling statement due to user request
  </code></pre>
  
  <p>Please help. Does anyone have any ideas? :/
  ..Or is this even possible?</p>
  
  <p>My specs:</p>
  
  <ul>
  <li>Postgresql-9.6</li>
  <li>RedHat Linux </li>
  </ul>