It's an old question but recently something similar happened to me. A couple of points that can help.
Removing a layer
from geoserver does not delete the table. A layer
is just a certain representation of a data source (a shapefile, a raster, a view, a table, ...) in geoserver. Deleting it does not eliminate the data source.
In these situations, there is most likely a lock on the table. That is, a query or a session that is using it exclusively.
The grossest solution is usually to restart. If it is not feasible, you have to find out if the table is indeed blocked:
SELECT pid, relname
FROM pg_locks l
JOIN pg_class t ON l.relation = t.oid AND t.relkind = 'r'
WHERE t.relname = 'MI_TABLA';
If a result comes out, it is blocked and the blocking process can be killed with:
kill -9 EL_PID
As indicated in this answer , there may also be a pending prepared transaction
:
SELECT database, gid FROM pg_prepared_xacts;
ROLLBACK PREPARED 'EL_GID'