pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #602: Memory allocation failure at CREATE EXTENSION.
8+ messages / 3 participants
[nested] [flat]

* [pgvector/pgvector] issue #602: Memory allocation failure at CREATE EXTENSION.
@ 2024-06-21 07:50  "pashkinelfe (@pashkinelfe)" <noreply+pashkinelfe@github.com>
  0 siblings, 0 replies; 8+ messages in thread

From: pashkinelfe (@pashkinelfe) @ 2024-06-21 07:50 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi!
I found the following error at trying create extension on one of the customers machine:
`not enough shared memory for data structure "hnsw LWLock ids" (4 bytes requested)`
called from the code block
```
/*
 * Assign a tranche ID for our LWLocks. This only needs to be done by one
 * backend, as the tranche ID is remembered in shared memory.
 *
 * This shared memory area is very small, so we just allocate it from the
 * "slop" that PostgreSQL reserves for small allocations like this. If
 * this grows bigger, we should use a shmem_request_hook and
 * RequestAddinShmemSpace() to pre-reserve space for this.
 */
void
HnswInitLockTranche(void)
{
	int		   *tranche_ids;
	bool		found;

	LWLockAcquire(AddinShmemInitLock, LW_EXCLUSIVE);
	tranche_ids = ShmemInitStruct("hnsw LWLock ids",
								  sizeof(int) * 1,
								  &found);
	if (!found)
		tranche_ids[0] = LWLockNewTrancheId();
	hnsw_lock_tranche_id = tranche_ids[0];
	LWLockRelease(AddinShmemInitLock);

	/* Per-backend registration of the tranche ID */
	LWLockRegisterTranche(hnsw_lock_tranche_id, "HnswBuild");
}
```

It's a rare error that I met only once. Could we not rely that the 'slop' has enough free space to do allocation? As I think PG user has little power to check or free this memory.

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

* Re: [pgvector/pgvector] issue #602: Memory allocation failure at CREATE EXTENSION.
@ 2024-06-21 17:31  "ankane (@ankane)" <noreply+ankane@github.com>
  6 siblings, 0 replies; 8+ messages in thread

From: ankane (@ankane) @ 2024-06-21 17:31 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@pashkinelfe It'd be good to understand how this happens, since Postgres allocates [an extra 100K bytes](https://github.com/postgres/postgres/blob/master/src/backend/storage/ipc/ipci.c#L112) for small allocations.

We could request the shared memory up front when the extension is part of `shared_preload_libraries` (without making it required), but I'm not sure if it's worth the complexity.

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

* Re: [pgvector/pgvector] issue #602: Memory allocation failure at CREATE EXTENSION.
@ 2024-06-23 03:23  "akorotkov (@akorotkov)" <noreply+akorotkov@github.com>
  6 siblings, 0 replies; 8+ messages in thread

From: akorotkov (@akorotkov) @ 2024-06-23 03:23 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@pashkinelfe, could we get the full config when the error happens? Probably it's related to the combination of multiple extensions.

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

* Re: [pgvector/pgvector] issue #602: Memory allocation failure at CREATE EXTENSION.
@ 2024-06-24 12:23  "pashkinelfe (@pashkinelfe)" <noreply+pashkinelfe@github.com>
  6 siblings, 0 replies; 8+ messages in thread

From: pashkinelfe (@pashkinelfe) @ 2024-06-24 12:23 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@akorotkov 
Non-default GUCs:
```
checkpoint_completion_target = 0.900
default_statistics_target = 100
effective_cache_size = '6GB'
effective_io_concurrency = 200
maintenance_work_mem = '512MB'
max_connections = 160
max_parallel_maintenance_workers = 1
max_parallel_workers = 2
max_parallel_workers_per_gather = 1
max_wal_size = '4GB'
max_worker_processes = 6
min_wal_size = '1GB'
max_wal_senders = 8
max_replication_slots = 8
random_page_cost = 1.100
shared_buffers = '2GB'
wal_buffers = '16MB'
work_mem = '12MB'
```
"Show all" contents: 
[1000.txt](https://github.com/user-attachments/files/15955627/1000.txt)


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

* Re: [pgvector/pgvector] issue #602: Memory allocation failure at CREATE EXTENSION.
@ 2024-06-28 00:57  "akorotkov (@akorotkov)" <noreply+akorotkov@github.com>
  6 siblings, 0 replies; 8+ messages in thread

From: akorotkov (@akorotkov) @ 2024-06-28 00:57 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Can't reproduce this yet. Could you also share exact PostgreSQL and pgvector versions?

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

* Re: [pgvector/pgvector] issue #602: Memory allocation failure at CREATE EXTENSION.
@ 2024-06-28 13:57  "pashkinelfe (@pashkinelfe)" <noreply+pashkinelfe@github.com>
  6 siblings, 0 replies; 8+ messages in thread

From: pashkinelfe (@pashkinelfe) @ 2024-06-28 13:57 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

PG 15.1 + pgvector 0.6.0
I also can't reproduce it.

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

* Re: [pgvector/pgvector] issue #602: Memory allocation failure at CREATE EXTENSION.
@ 2024-09-19 21:08  "ankane (@ankane)" <noreply+ankane@github.com>
  6 siblings, 0 replies; 8+ messages in thread

From: ankane (@ankane) @ 2024-09-19 21:08 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi @pashkinelfe, closing this out, but happy to revisit if the cause is identified.

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

* Re: [pgvector/pgvector] issue #602: Memory allocation failure at CREATE EXTENSION.
@ 2024-09-19 21:08  "ankane (@ankane)" <noreply+ankane@github.com>
  6 siblings, 0 replies; 8+ messages in thread

From: ankane (@ankane) @ 2024-09-19 21:08 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ankane closed this.

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


end of thread, other threads:[~2024-09-19 21:08 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-06-21 07:50 [pgvector/pgvector] issue #602: Memory allocation failure at CREATE EXTENSION. "pashkinelfe (@pashkinelfe)" <noreply+pashkinelfe@github.com>
2024-06-21 17:31 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-06-23 03:23 ` "akorotkov (@akorotkov)" <noreply+akorotkov@github.com>
2024-06-24 12:23 ` "pashkinelfe (@pashkinelfe)" <noreply+pashkinelfe@github.com>
2024-06-28 00:57 ` "akorotkov (@akorotkov)" <noreply+akorotkov@github.com>
2024-06-28 13:57 ` "pashkinelfe (@pashkinelfe)" <noreply+pashkinelfe@github.com>
2024-09-19 21:08 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-09-19 21:08 ` "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