* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
*
- * Copyright (c) 2003-2022 PgPool Global Development Group
+ * Copyright (c) 2003-2023 PgPool Global Development Group
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
(errmsg("pool_discard_oid_maps: discarded memqcache oid maps")));
pool_hash_init(pool_config->memqcache_max_num_cache);
+
+ pool_init_whole_cache_blocks();
}
#ifdef USE_MEMCACHED
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
*
- * Copyright (c) 2003-2022 PgPool Global Development Group
+ * Copyright (c) 2003-2023 PgPool Global Development Group
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
pool_discard_oid_maps();
pool_hash_reset(pool_config->memqcache_max_num_cache);
+
+ pool_init_whole_cache_blocks();
}
PG_CATCH();
{
}
/*
- * Initialize new block
+ * Initialize whole cache blocks
*/
+void
+pool_init_whole_cache_blocks(void)
+{
+ int blocks = pool_get_memqcache_blocks();
+ int i;
+
+ for (i = 0; i < blocks; i++)
+ {
+ pool_init_cache_block(i);
+ }
+}
/*
* Free space management map
* For example, if the value is 2, the free space can be between 64
* bytes and 95 bytes.
*
- * value free space(in bytes)
+ * value free space (in bytes)
* 0 0-31
* 1 32-63
* 2 64-95
reused_block = *pool_fsmm_clock_hand;
p = block_address(reused_block);
+ /* Remove all items in this block from hash table */
for (i = 0; i < bh->num_items; i++)
{
cip = item_pointer(p, i);
if (p[i] >= encode_value)
{
/*
- * This block *may" have enough space. We need to make sure it
+ * This block may not have enough space. We need to make sure it
* actually has enough space.
*/
bh = (POOL_CACHE_BLOCK_HEADER *) block_address(i);
{
/* If not, reuse next victim block */
blockid = pool_reuse_block();
- pool_init_cache_block(blockid);
}
/* Get block address on shmem */
pool_hash_delete(&key);
/*
- * If the deleted item is last one in the block, we add it to the free
+ * If the deleted item is the last one in the block, we add it to the free
* space.
*/
if (cacheid->itemid == (bh->num_items - 1))
bh->free_bytes += size;
ereport(DEBUG1,
(errmsg("memcache deleting item data"),
- errdetail("deleted %d bytes, freebytes is = %d",
+ errdetail("deleted %d bytes, freebytes is %d",
size, bh->free_bytes)));
bh->num_items--;