Hi! I found concurrency bug in amcheck running on replica. When btree_xlog_unlink_page() replays changes to replica, deleted page is left with no items. But if amcheck steps on such deleted page palloc_btree_page() expects it would have items.
(lldb_on_primary) b btbulkdelete primary=# drop table test; primary=# create table test as (select random() x from generate_series(1,1000000) i); primary=# create index test_x_idx on test(x); primary=# delete from test; primary=# vacuum test; (lldb_on_replica) b bt_check_level_from_leftmost replica=# select bt_index_check('test_x_idx'); # skip to internal level (lldb_on_replica) c (lldb_on_replica) b palloc_btree_page # skip to non-leftmost page (lldb_on_replica) c (lldb_on_replica) c # concurrently delete btree pages (lldb_on_primary) c # continue with pages (lldb_on_replica) c Finally replica gets error. ERROR: internal block 289 in index "test_x_idx" lacks high key and/or at least one downlink Proposed fix is attached. Spotted by Konstantin Knizhnik, reproduction case and fix from me. ------ Alexander Korotkov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company
fix_amcheck_concurrency.patch
Description: Binary data