Thank you for your attention.
I have provided a python script in the attachment to minimize the reproduction of the issue. The specific reproduction steps are as follows: 1. Initialize the data ``` DROP TABLE IF EXISTS tbl_part; CREATE TABLE tbl_part (a integer) PARTITION BY RANGE (a); CREATE TABLE tbl_part_p1 PARTITION OF tbl_part FOR VALUES FROM (0) TO (10); CREATE INDEX ON tbl_part(a); ``` 2. session1 reindex and gdb break at index.c:3585 ``` REINDEX INDEX tbl_part_a_idx; ``` 3. session2 drop index succeed ``` DROP INDEX tbl_part_a_idx; ``` 4. session1 gdb continue |
import psycopg2 import os import threading import time dbname = 'postgres' user = 'postgres' host = '127.0.0.1' port = 5432
conn1 = psycopg2.connect(database=dbname, user=user, host=host, port=port)
conn1.autocommit = True
conn2 = psycopg2.connect(database=dbname, user=user, host=host, port=port)
conn2.autocommit = True
def execute_sql(conn, sql):
cur = conn.cursor()
cur.execute(sql)
try:
res = cur.fetchall()
except psycopg2.ProgrammingError as e:
# ddl, dml will raise 'no results to fetch'
if 'no results to fetch' in str(e):
res = []
cur.close()
return res
def init_data():
conn = psycopg2.connect(database=dbname, user=user, host=host, port=port)
conn.autocommit = True
for sql in [
'DROP TABLE IF EXISTS tbl_part',
'CREATE TABLE tbl_part (a integer) PARTITION BY RANGE (a)',
'CREATE TABLE tbl_part_p1 PARTITION OF tbl_part FOR VALUES FROM (0) TO (10)',
'CREATE INDEX ON tbl_part(a)'
]:
execute_sql(conn=conn1, sql=sql)
conn.close()
def session1():
conn = psycopg2.connect(database=dbname, user=user, host=host, port=port)
conn.autocommit = True
pg_backend_pid = execute_sql(conn, 'select pg_backend_pid()')[0][0]
gdb_cmd = "gdb --quiet --batch -p {} -ex 'b index.c:3585' -ex 'c' -ex 'shell sleep 5' &".format(pg_backend_pid)
os.system(gdb_cmd)
time.sleep(1)
execute_sql(conn, 'REINDEX INDEX tbl_part_a_idx')
time.sleep(5)
conn.close()
def session2():
conn = psycopg2.connect(database=dbname, user=user, host=host, port=port)
conn.autocommit = True
time.sleep(3)
execute_sql(conn, 'DROP INDEX tbl_part_a_idx')
conn.close()
# init table
init_data()
t1 = threading.Thread(target=session1)
t2 = threading.Thread(target=session2)
t1.start()
t2.start()
t1.join()
t2.join()
Best Regards, Fei Changhong Alibaba Cloud Computing Ltd. |
