Hi,
I am trying to use the Queue access method for an in-memory database
with no backing file. Here is the how I've created the environment and
the database.
int env_flags_create = DB_CREATE | DB_INIT_LOG | DB_INIT_LOCK |
DB_INIT_MPOOL |DB_INIT_TXN |
DB_SYSTEM_MEM | DB_RECOVER | DB_THREAD ;
..
..
ret = env->set_shm_key(env, 17);
ret = env->open(env, R_"in-mem-env", env_flags, 0644);
int db_flags = DB_CREATE | DB_THREAD | DB_AUTO_COMMIT;
..
..
DB_MPOOLFILE *mpf = subs_db->get_mpf(subs_db);
mpf->set_flags(mpf, DB_MPOOL_NOFILE, 1);
ret = queue_db->set_re_len(queue_db, 512);
ret = queue_db->open(queue_db, NULL, NULL, "queue", DB_QUEUE,
db_flags, 0644);
My application has one reader threads and one writer thread. The
writer write to the queue with the "DB_APPEND" flag and the reader
consumes the queue using the "DB_CONSUME_WAIT" flag.
After inserting a few thousand messages the database fails to insert
any new records and starts returning the following error.
"unable to allocate space from the buffer cache"
Quote:
From the db_stat -e output (attached below) I can see that the none of
the buffer cache pages are ever being freed up.
|
..
..
149907 Requested pages found in the cache (99%)
3 Requested pages not found in the cache
2004 Pages created in the cache
0 Pages read into the cache
0 Pages written from the cache to the backing file
0 Clean pages forced from the cache
0 Dirty pages forced from the cache
0 Dirty pages written by trickle-sync thread
2004 Current total page count
0 Current clean page count
2004 Current dirty page count
4099 Number of hash buckets used for page location
153851 Total number of times hash chains searched for a page
..
..
BDB reference manual (http://www.oracle.com/technology/documentation/
berkeley-db/db/api_c/frame.html) says that the pages associated with a
queue can only be reclaimed by setting a queue extent by using the
"set_q_extentsize" method. When I try to use this method on my in-
memory database I get the following error.
" Extent size may not be specified for in-memory queue database"
Does this mean that I can never use the queue access method for in-
memory database? Because no matter how big of a shared memory pool I
allocate to the in-memory database it will eventually get used up by
the queue (if I'm inserting and consuming records) and there is no way
to free up the pages associated with the deleted records.
~ thx