postgresql - Can postgres auto-vacuum block another process trying to run ALTER or CREATE queries on the same table? - Stack Ove

A process is trying to ALTER a table (to set default column value) in a workflow. It is getting blocked

A process is trying to ALTER a table (to set default column value) in a workflow. It is getting blocked due to postgres auto-vacuum process not releasing a lock (It might be holding a ShareUpdateExclusiveLock).

The following logs are seen in postgres -

LOG:  automatic vacuum to prevent wraparound of table "my_db.public.event_spl_1740300900": index scans: 0
 pages: 0 removed, 16591962 remain, 0 skipped due to pins, 16300723 skipped frozen
 tuples: 0 removed, 1244397113 remain, 0 are dead but not yet removable, oldest xmin: 1410720248
 buffer usage: 2361602 hits, 6947399 misses, 291262 dirtied
 avg read rate: 3.879 MB/s, avg write rate: 0.163 MB/s
 system usage: CPU: user: 83.69 s, system: 135.74 s, elapsed: 13990.91 s

LOG:  process 113323 acquired AccessExclusiveLock on relation 181282787 of database 180669275 after 5823314.224 ms

Is there enough evidence here to suggest auto-vacuum might be the culprit? If not, what could be the other blocking process?

A process is trying to ALTER a table (to set default column value) in a workflow. It is getting blocked due to postgres auto-vacuum process not releasing a lock (It might be holding a ShareUpdateExclusiveLock).

The following logs are seen in postgres -

LOG:  automatic vacuum to prevent wraparound of table "my_db.public.event_spl_1740300900": index scans: 0
 pages: 0 removed, 16591962 remain, 0 skipped due to pins, 16300723 skipped frozen
 tuples: 0 removed, 1244397113 remain, 0 are dead but not yet removable, oldest xmin: 1410720248
 buffer usage: 2361602 hits, 6947399 misses, 291262 dirtied
 avg read rate: 3.879 MB/s, avg write rate: 0.163 MB/s
 system usage: CPU: user: 83.69 s, system: 135.74 s, elapsed: 13990.91 s

LOG:  process 113323 acquired AccessExclusiveLock on relation 181282787 of database 180669275 after 5823314.224 ms

Is there enough evidence here to suggest auto-vacuum might be the culprit? If not, what could be the other blocking process?

Share Improve this question edited Mar 6 at 12:23 Laurenz Albe 250k21 gold badges298 silver badges373 bronze badges asked Mar 6 at 11:09 Yashodhan AgnihotriYashodhan Agnihotri 254 bronze badges 4
  • to prevent wraparound How did you get into this situation? To avoid this issue, it's better to optimize the configuration of your database first before making changes to tables. – Frank Heikens Commented Mar 6 at 14:36
  • I am using a database with high volume of inserts and hence had autovacuum turned on with the setting - autovacuum_freeze_min_age = 0, ""autovacuum_freeze_max_age = 100000 – Yashodhan Agnihotri Commented Mar 6 at 16:43
  • That's a very unusual setting, also for high-volume systems. That might also be the reason why your disk system is so slow: avg read rate: 3.879 MB/s, avg write rate: 0.163 MB/s – Frank Heikens Commented Mar 6 at 17:38
  • What should be the ideal setting here? – Yashodhan Agnihotri Commented Mar 7 at 5:12
Add a comment  | 

1 Answer 1

Reset to default 3

Yes, a VACUUM will place a SHARE UPDATE EXCLUSIVE table lock on the table, which conflicts with the ACCESS EXCLUSIVE lock the ALTER TABLE statement needs.

Normal autovacuum processes will silently die after deadlock_timeout if they are blocking a user statement, but an autovacuum “to prevent wraparound” has business to attent to and won't back down.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744980783a4604429.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信