pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #714: Cannot Concurrently Create HNSW Index for Cohere-MEDIUM-1M dataset with dynamic_shared_memory_type set to POSIX  
4+ messages / 2 participants
[nested] [flat]

* [pgvector/pgvector] issue #714: Cannot Concurrently Create HNSW Index for Cohere-MEDIUM-1M dataset with dynamic_shared_memory_type set to POSIX  
@ 2024-11-18 18:46  "JoshInnis (@JoshInnis)" <noreply+JoshInnis@github.com>
  0 siblings, 0 replies; 4+ messages in thread

From: JoshInnis (@JoshInnis) @ 2024-11-18 18:46 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hello,

I am trying to using [VectorDBBench](https://github.com/zilliztech/VectorDBBench) with the HNSW index on pgVector v0.7.4 on Postgres branch RHEL_17_STABLE and master. I am receiving the following error: `ERROR:  could not resize shared memory segment "/PostgreSQL.2200591728" to 34357121056 bytes: No space left on device`

I have been able to recreate the error on Ubuntu on WSL, RedHat, and Fedora. 

The error happens during the index construction phase. I am trying to run VectorDBBench with the Performance768D1M dataset.

After I receive the error while running VectorDBBench I use psql and run the following command to recreate the error.

`CREATE INDEX CONCURRENTLY v_idx1 ON public.pg_vector_collection USING hnsw (embedding vector_l2_ops);`

Non default postgres.conf settings (The server was restarted after changes):
max_connections = 200  
max_worker_processes = 32               # (change requires restart)
max_parallel_workers_per_gather = 16    # limited by max_parallel_workers
max_parallel_maintenance_workers = 16   # limited by max_parallel_workers
max_parallel_workers = 32               # number of max_worker_processes that
autovacuum_max_workers = 16             # max number of autovacuum subprocesses
shared_buffers = 16GB
work_mem = 32GB                         # min 64kB
maintenance_work_mem = 32GB             # min 64kB


Hardware for Linux Box:
![image](https://github.com/user-attachments/assets/f55931b4-56f0-4dfc-be41-2a1619f04fcc)

Stack Trace:
```
#0  errstart (elevel=21, domain=0x0) at elog.c:346
#1  0x00000000009bb756 in dsm_impl_posix (op=DSM_OP_CREATE, handle=3285676758, request_size=34357121056, impl_private=0x2869048, mapped_address=0x2869050, mapped_size=0x2869058, elevel=21) at dsm_impl.c:307
#2  0x00000000009bb3a4 in dsm_impl_op (op=DSM_OP_CREATE, handle=3285676758, request_size=34357121056, impl_private=0x2869048, mapped_address=0x2869050, mapped_size=0x2869058, elevel=21) at dsm_impl.c:171
#3  0x00000000009b9b9a in dsm_create (size=34357121056, flags=1) at dsm.c:576
#4  0x000000000056b208 in InitializeParallelDSM (pcxt=0x28627b8) at parallel.c:323
#5  0x00007f1689d3076c in BuildIndex () from /home/josh/vectors/postgres/lib/vector.so
#6  0x00007f1689d30cd2 in hnswbuild () from /home/josh/vectors/postgres/lib/vector.so
#7  0x00000000005cce1e in index_build (heapRelation=0x7f1689d70738, indexRelation=0x7f1689d7c2e8, indexInfo=0x28d8900, isreindex=false, parallel=true) at index.c:3047
#8  0x00000000005ca605 in index_concurrently_build (heapRelationId=16709, indexRelationId=16719) at index.c:1523
#9  0x00000000006c66ab in DefineIndex (tableId=16709, stmt=0x281c870, indexRelationId=16719, parentIndexId=0, parentConstraintId=0, total_parts=-1, is_alter_table=false, check_rights=true, check_not_in_use=true, skip_build=false, 
    quiet=false) at indexcmds.c:1685
#10 0x00000000009ff5ae in ProcessUtilitySlow (pstate=0x2849c30, pstmt=0x281c980, queryString=0x281bbc0 "CREATE INDEX CONCURRENTLY v_idx1 ON public.pg_vector_collection USING hnsw (embedding vector_l2_ops);", 
    context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0, dest=0x281cd40, qc=0x7fff757ef6e0) at utility.c:1545
#11 0x00000000009fe5f4 in standard_ProcessUtility (pstmt=0x281c980, queryString=0x281bbc0 "CREATE INDEX CONCURRENTLY v_idx1 ON public.pg_vector_collection USING hnsw (embedding vector_l2_ops);", readOnlyTree=false, 
    context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0, dest=0x281cd40, qc=0x7fff757ef6e0) at utility.c:1070
#12 0x00000000009fd7b6 in ProcessUtility (pstmt=0x281c980, queryString=0x281bbc0 "CREATE INDEX CONCURRENTLY v_idx1 ON public.pg_vector_collection USING hnsw (embedding vector_l2_ops);", readOnlyTree=false, 
    context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0, dest=0x281cd40, qc=0x7fff757ef6e0) at utility.c:523
#13 0x00000000009fc248 in PortalRunUtility (portal=0x28c4e90, pstmt=0x281c980, isTopLevel=true, setHoldSnapshot=false, dest=0x281cd40, qc=0x7fff757ef6e0) at pquery.c:1158
#14 0x00000000009fc4a2 in PortalRunMulti (portal=0x28c4e90, isTopLevel=true, setHoldSnapshot=false, dest=0x281cd40, altdest=0x281cd40, qc=0x7fff757ef6e0) at pquery.c:1315
#15 0x00000000009fb9db in PortalRun (portal=0x28c4e90, count=9223372036854775807, isTopLevel=true, run_once=true, dest=0x281cd40, altdest=0x281cd40, qc=0x7fff757ef6e0) at pquery.c:791
#16 0x00000000009f5026 in exec_simple_query (query_string=0x281bbc0 "CREATE INDEX CONCURRENTLY v_idx1 ON public.pg_vector_collection USING hnsw (embedding vector_l2_ops);") at postgres.c:1283
#17 0x00000000009f9b11 in PostgresMain (dbname=0x2877400 "vectordb", username=0x28773e8 "josh") at postgres.c:4798
#18 0x00000000009f1547 in BackendMain (startup_data=0x7fff757ef9e8 "", startup_data_len=4) at backend_startup.c:107
#19 0x0000000000918d85 in postmaster_child_launch (child_type=B_BACKEND, child_slot=2, startup_data=0x7fff757ef9e8 "", startup_data_len=4, client_sock=0x7fff757efa20) at launch_backend.c:274
#20 0x000000000091e98d in BackendStartup (client_sock=0x7fff757efa20) at postmaster.c:3377
#21 0x000000000091c5b8 in ServerLoop () at postmaster.c:1663
#22 0x000000000091bf84 in PostmasterMain (argc=3, argv=0x2815f30) at postmaster.c:1361
#23 0x00000000007db36e in main (argc=3, argv=0x2815f30) at main.c:196
```

Please note that I created the errors for WSL and RedHat on a different machine. I could provide details from those machines too if necessary.

Workaround Found:
When I switch dynamic_shared_memory_type from posix to mmap I am able to build the index. 

I believe that in [Postgres parallel.c on InitializeParallelDSM on line 321](https://github.com/postgres/postgres/blob/18ea6b3d0da357b5874ab9cf41350d4473b01ee9/src/backend/acces...), the segsize is being set to 34357121056 due to the ParallelContext that pgVector is passing to the Postgres code, due to my configuration settings.

I am not sure if this is an error, or if I am setting configuration settings poorly, however this configuration works and creates the index if dynamic_shared_memory_type is setting to mmap.


^ permalink  raw  [nested|flat] 4+ messages in thread

* Re: [pgvector/pgvector] issue #714: Cannot Concurrently Create HNSW Index for Cohere-MEDIUM-1M dataset with dynamic_shared_memory_type set to POSIX  
@ 2024-11-18 18:58  "JoshInnis (@JoshInnis)" <noreply+JoshInnis@github.com>
  2 siblings, 0 replies; 4+ messages in thread

From: JoshInnis (@JoshInnis) @ 2024-11-18 18:58 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@JoshInnis renamed this.

^ permalink  raw  [nested|flat] 4+ messages in thread

* Re: [pgvector/pgvector] issue #714: Cannot Concurrently Create HNSW Index for Cohere-MEDIUM-1M dataset with dynamic_shared_memory_type set to POSIX  
@ 2024-11-18 18:58  "ankane (@ankane)" <noreply+ankane@github.com>
  2 siblings, 0 replies; 4+ messages in thread

From: ankane (@ankane) @ 2024-11-18 18:58 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi @JoshInnis, this error occurs when `maintenance_work_mem` is greater than the shared memory limit for your system (try decreasing `maintenance_work_mem` or increasing the shared memory limit).

^ permalink  raw  [nested|flat] 4+ messages in thread

* Re: [pgvector/pgvector] issue #714: Cannot Concurrently Create HNSW Index for Cohere-MEDIUM-1M dataset with dynamic_shared_memory_type set to POSIX  
@ 2024-11-18 18:58  "ankane (@ankane)" <noreply+ankane@github.com>
  2 siblings, 0 replies; 4+ messages in thread

From: ankane (@ankane) @ 2024-11-18 18:58 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ankane closed this.

^ permalink  raw  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2024-11-18 18:58 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-11-18 18:46 [pgvector/pgvector] issue #714: Cannot Concurrently Create HNSW Index for Cohere-MEDIUM-1M dataset with dynamic_shared_memory_type set to POSIX   "JoshInnis (@JoshInnis)" <noreply+JoshInnis@github.com>
2024-11-18 18:58 ` "JoshInnis (@JoshInnis)" <noreply+JoshInnis@github.com>
2024-11-18 18:58 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-11-18 18:58 ` "ankane (@ankane)" <noreply+ankane@github.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox