Unable to drop postgres database?

You probably have pending transactions which need to be rolled back.

Run this to see them:

SELECT database, gid FROM pg_prepared_xacts;

Now roll each one back:

ROLLBACK PREPARED 'the_gid';

 

Alternatively run this psql script to roll them all back en masse:

t

a

o /tmp/remove-transactions.sql

SELECT 'ROLLBACK PREPARED ''' || gid || ''';' AS cmd

FROM pg_prepared_xacts

WHERE database=current_database();

o

i /tmp/remove-transactions.sql