From: YoimiyaLoveMe (@YoimiyaLoveMe) <noreply+YoimiyaLoveMe@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #893: server process was terminated by signal 11: Segmentation fault WHEN SELECT
Date: Thu, 28 Aug 2025 16:45:07 +0000
Message-ID: <gh-pgvector-pgvector-893@github.com> (raw)
After importing the MSONG dataset, I used a .py to connect and search for and test it . There was a segment error when searching for the second vector. However, when I use this 'error' sql SELECT directly on the terminal, it can be executed normally. The same error occurs in the Glove1m dataset, but it is occasional, which means it sometimes works properly on Glove.
### .py
```
import sys
import numpy as np
def ivecs_read(fname):
a = np.fromfile(fname, dtype='int32')
d = a[0]
return a.reshape(-1, d + 1)[:, 1:].copy()
def fvecs_read(fname):
return ivecs_read(fname).view('float32')
def load_msong(): #(992272, 420)
basedir = './datasets/millionSong/'
xb = fvecs_read(basedir + "millionSong_base.fvecs")
xq = fvecs_read(basedir + "millionSong_query.fvecs")
gt = ivecs_read(basedir + "millionSong_groundtruth.ivecs")
xt = []
print("done", file=sys.stderr)
return xb, xq, xt, gt
xb, xq, xt, gt = load_msong()
nq, d = xq.shape
import psycopg
conn = psycopg.connect(
....
)
times = []
recall = []
efSearch = []
conn.execute('BEGIN')
for search_L in 10,20,30,40,50,60,70,80,90,100,200,300,400,500: # msong
print("search_L:", search_L)
sql="SET hnsw.ef_search = "+str(search_L)
conn.execute(sql)
k = 10
I=[]
t0 = time.time()
for q in xq:
embedding="'"+str(q.tolist())+"'"
sql="SELECT * FROM msong ORDER BY embedding <-> "+embedding+" LIMIT "+str(k)
results = conn.execute(sql).fetchall()
I.append([row[0]-1 for row in results])
t1 = time.time()
recall_at_1 = (I == gt[:, :1]).sum() / float(nq)
efSearch.append(search_L)
recall.append(float(format(recall_at_1, '.4f')))
times.append(float(format((t1-t0)*1000.0/nq, '.4f')))
if recall_at_1==1:break
```
conn.execute('COMMIT')
### log:
```
2025-08-29 00:02:12.484 CST [116568] LOG: database system is ready to accept connections
2025-08-29 00:02:28.918 CST [116568] LOG: server process (PID 117002) was terminated by signal 11: Segmentation fault
2025-08-29 00:02:28.918 CST [116568] DETAIL: Failed process was running: SELECT * FROM msong ORDER BY embedding <-> '[6.203939914703369, 6.7285919189453125, 5.577672958374023, 4.068037986755371, 4.304356098175049, 3.9737548828125, ....Omitted '
2025-08-29 00:02:28.919 CST [116568] LOG: terminating any other active server processes
2025-08-29 00:02:28.919 CST [116568] LOG: all server processes terminated; reinitializing
2025-08-29 00:02:28.938 CST [117003] LOG: database system was interrupted; last known up at 2025-08-29 00:02:12 CST
2025-08-29 00:02:30.003 CST [117003] LOG: database system was not properly shut down; automatic recovery in progress
2025-08-29 00:02:30.009 CST [117003] LOG: redo starts at 5/9A5A920
2025-08-29 00:02:30.009 CST [117003] LOG: invalid record length at 5/9A5A958: expected at least 24, got 0
2025-08-29 00:02:30.009 CST [117003] LOG: redo done at 5/9A5A920 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
2025-08-29 00:02:30.020 CST [117004] LOG: checkpoint starting: end-of-recovery immediate wait
2025-08-29 00:02:30.050 CST [117004] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.009 s, sync=0.004 s, total=0.035 s; sync files=2, longest=0.003 s, average=0.002 s; distance=0 kB, estimate=0 kB; lsn=5/9A5A958, redo lsn=5/9A5A958
2025-08-29 00:02:30.058 CST [116568] LOG: database system is ready to accept connections
```