文章目录
环境
系统平台:N/A
版本:10.3
症状
对表执行vaccum操作时,提示索引相关的错误,信息如下:
testdb=# vacuum testtable01;
ERROR: left link changed unexpectedly in block 73592 of index "index_col01"
testdb=# vacuum freeze testtable01;
ERROR: left link changed unexpectedly in block 73592 of index "index_col01"
问题原因
index_col01索引文件损坏,导致在73592 块上获取到的索引页的链表结构被破坏了,需要重建索引修复。
解决方案
重建索引解决。命令如下:
方式一:不开并行重建索
sql
testdb=# reindex index index_col01;
注:PostgreSQL 10.3不支持并行重建索引,这样重建索引会锁表会阻塞DML操作,建议在业务空闲期间操作。
方式二:先建立新索引,再删掉老的索引
sql
testdb=# create index CONCURRENTLY index_col02 on testtable01(col1);
CREATE INDEX
testdb=# drop index index_col01;
DROP INDEX
注:因为postgresql10.3 不能并发的重建旧的索引,可以通过先建后删的方法在postgresql10.3下可以避免reindex阻塞其他DML。
报错编码
left link changed unexpectedly in block of index