title: truncate on one table blocked by select of another
body: <p><strong>Postgres 9.4, Ubuntu 10</strong></p>
  
  <p>I have been unable to find this exact problem here, so here it goes:</p>
  
  <p>For each table t in my database, I have a table t_audit. Each delete, insert, and update on table t triggers a function that inserts a record to table t_audit.</p>
  
  <p>Each night, a process truncates each t_audit table.</p>
  
  <p>Last night, a select on table t prevented the truncate on t_audit from proceeding. I did not save what was in pg_stat_activity at the time, but I did save the output from blocking_locks().</p>
  
  <ol>
  <li>Blocking pid: RowExclusiveLock, t, select * from t where ..., </li>
  <li>Waiting pid: AccessExclusiveLock, t_audit, truncate table t_audit,</li>
  </ol>
  
  <p>I am uncertain as to why a select on t would block the truncate on t_audit. As I did not save pg_stat_activity, the best that I can assume is that the select was "idle in transaction". I asked the person who was running the query at the time, and he said he was not running the update as part of a transaction. He did update table t just prior to the select. He did not close his connection as the pid was still active until I ran pg_terminate_backend on the pid.</p>
  
  <p>Has anyone experienced this issue before? Is there a recommended procedure for this other than running pg_terminate_backend on any pids which are "idle in transaction" just prior to calling truncates?</p>
  
  <p>Thank you for reading and taking time to respond.</p>