Autovacuuming process holds RowExclusiveLock and ShareUpdateExclusiveLock on the table, which I want to drop. I read that autovacuum should be canceled automatically, when submitting DROP TABLE command, but it doesn't happen. Maybe I have wrong configuration of postgresql? Furthermore I don't have any delete or update operations of those tables — only inserts and drops. Can I disable autovacuum on those particular tables?
If no delete or update happened, autovacuum shouldn't process the table, per
autovacuum_analyze_threshold. See Automatic Vacuuming for the relevant configuration parameters.
You may set
log_autovacuum_min_duration to zero to help figure out what's being autovacuumed.
In any case, it is possible to completely disable autovacuum for a particular table, with:
ALTER TABLE tablename SET (autovacuum_enabled = false, toast.autovacuum_enabled = false);
This is documented in Storage parameters.
Is the autovac "to prevent wraparound" (as reported in pg_stat_activity)? If so, PostgreSQL considers that an emergency and refuses to yield the lock.
Which is rather unfortunate in this case, as once you drop the table the situation will be resolved. But it doesn't know why you want the lock.
If You use Linux you should list processes with
ps aux and find Autovacuum process. Then just kill it(autovacuum should be working as another process if it's turned on).
"In any case, it is possible to completely disable autovacuum for a particular table."
No, you can not disable autovacuum if it is to prevent transaction ID wraparound.