Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Couchbase | Couchbase Server 1.8.x

recent issues with couchbase; eviction of php sessions and expired keys

8 replies [Last post]
  • Login or register to post comments
Tue, 06/26/2012 - 15:49
rtwheato
Offline
Joined: 06/26/2012
Groups: None

i have two (1.8.2) cache servers in a cluster, with two vbuckets (one for app, one for php sessions) on separate ports, each using 8GB ram. and, i'm using moxi to communicate with the cluster. i recently had some issues with the cache servers where one was reporting as down / couldn't communicate because one of them had run out of RAM. i restarted the servers, and added a third to avoid any further issues. One week later, the cluster is responsive, but no cache keys are found, and those that are attempted to be set aren't written. no amount of restarting or waiting fixed the issue. i've since started over with a new cluster and all is well for now, but i suspect that the servers were full because php wasn't doing any garbage collection on the sessions, and they were not being expired by the server. i've done a bit of research, and found others that have similar problems, but can't find a clear workaround...

is the issue because this setting tells the server to never expire?

[r@couchbase01 bin]# ./cbstats localhost:11210 all|grep min_data_age
ep_min_data_age: 0

if i set this to 86400, using something like:

cbflushctl localhost:11210 set min_data_age 86400

will the items expire after one day? Is there a way to configure it per bucket? Do I have to set it on each server? Will this setting persist across server restarts?

Do you have any other suggestions on how to properly clean this unneeded info out to avoid any future complications? Is vacuuming the sqllite db still required?

thanks,

-rtw

Top
  • Login or register to post comments
Tue, 06/26/2012 - 21:53
mikew
Offline
Joined: 03/14/2011
Groups:

You definitely don't want to set min_data_age to that high of a value. When Couchbase grabs your items out of memory to persist them it compares how long they have been in memory (and not persisted) to the min_data_age. If they have been sitting in memory for a smaller time than min_data_age then it holds off persisting them and I don't think that that is what you want and it will likely make your problems much worst.

The issue you are likely having is that your items aren't expiring and this is likely an issue in your application code. Check that you are actually sending an expiration time with each request. Also, the expiry pager runs once per hour to clean up expired items. It can be configured to run at different intervals, but I sense that the problem is that the items in your database are set to never expire.

If you feel that your application code is correct then can you post a code snippet here?

Top
  • Login or register to post comments
Wed, 06/27/2012 - 14:03
rtwheato
Offline
Joined: 06/26/2012
Groups: None

i'm checking with our developers on how the application is caching it's information, but i do believe that there are expires times set there.

but, my main concern right now is the bucket where php is storing its sessions. from what i've read thus far, there's something with the php session handler that allows it to garbage collect from file based sessions, but doesn't handle cleanup well when using the memcached extension. we're using the PECL memcache extension. here's some relvant settings we're using in php though,

memcache:
memcache support => enabled
memcache.allow_failover => 1 => 1
memcache.chunk_size => 8192 => 8192
memcache.compress_threshold => 20000 => 20000
memcache.default_port => 11211 => 11211
memcache.hash_function => crc32 => crc32
memcache.hash_strategy => consistent => consistent
memcache.lock_timeout => 15 => 15
memcache.max_failover_attempts => 20 => 20
memcache.protocol => ascii => ascii
memcache.redundancy => 1 => 1
memcache.session_redundancy => 2 => 2
Registered save handlers => files user memcache

session:
session.auto_start => Off => Off
session.bug_compat_42 => Off => Off
session.bug_compat_warn => Off => Off
session.cache_expire => 180 => 180
session.cache_limiter => nocache => nocache
session.cookie_domain => example.com => example.com
session.cookie_httponly => Off => Off
session.cookie_lifetime => 0 => 0
session.cookie_path => / => /
session.cookie_secure => Off => Off
session.entropy_file => no value => no value
session.entropy_length => 0 => 0
session.gc_divisor => 1000 => 1000
session.gc_maxlifetime => 21600 => 21600
session.gc_probability => 1 => 1
session.hash_bits_per_character => 5 => 5
session.hash_function => 0 => 0
session.name => PHPSESSID => PHPSESSID
session.referer_check => no value => no value
session.save_handler => memcache => memcache
session.save_path => tcp://localhost:11211 => tcp://localhost:11211
session.serialize_handler => php => php
session.use_cookies => On => On
session.use_only_cookies => On => On
session.use_trans_sid => 0 => 0

where is the expiry pager configured? are there some ways to configure that to remove the old un-needed sessions? looks like there may be a way to use tap.py to script an explicit deletion (or update of expiry keys), but that really seems like overkill.

thanks,

-rtw

Top
  • Login or register to post comments
Wed, 06/27/2012 - 14:13
mikew
Offline
Joined: 03/14/2011
Groups:

You can set the interval for the expiry pager to run by doing the following:

./cbflushctl localhost:11210 set exp_pager_stime 60

This would set the expiry pager to run every 60 seconds. If your items don't have an expiry time then changing the expiry pager run interval is not likely to do much. I suspect that the issue is either in the sdk or in your application. I will email our PHP developer and have him take a look at this.

Top
  • Login or register to post comments
Wed, 06/27/2012 - 16:15
ingenthr
Offline
Joined: 03/16/2010
Groups:

Keep in mind that cbflushctl would need to be run once per node in the cluster, so running that on one system on "localhost" will just change the configuration for that one node. Tuning these variables would need to be redone after each restart as well-- we have an open enhancement request to have the cluster persist and reapply these as needed.

Top
  • Login or register to post comments
Thu, 06/28/2012 - 16:53
rtwheato
Offline
Joined: 06/26/2012
Groups: None

yea, i'm not sure changing the setting would have any effect because there aren't expire times on the sessions.

i've done a bit more digging and found that our application cache (in a separate bucket) sets an expire on the key itself, as well as an extra "expire" key (the key appended with _expire, done by cakephp).

i've also looked at a few sessions keys, and don't think i see any expiration set.

though, it does make some sense that php can't do garbage collection - because it can't get the expire time on the keys without getting them... but, if the expire time was set on them, then the expiry pager should pick them up, correct? any suggestions on setting expire times on items?

Top
  • Login or register to post comments
Tue, 07/03/2012 - 11:27
rtwheato
Offline
Joined: 06/26/2012
Groups: None

bump. anyone find anything?

Top
  • Login or register to post comments
Thu, 07/05/2012 - 20:21
mikew
Offline
Joined: 03/14/2011
Groups:

What you set as the expiry time is totally dependent on the application. Users who use Couchbase as a session store for example typically use an expiration time of 20 minutes. I'm going to file an issue for you problem and have our PHP developer take a look at it to see if he can find anything wrong.

Top
  • Login or register to post comments
Tue, 09/18/2012 - 08:48
ingenthr
Offline
Joined: 03/16/2010
Groups:

We verified that the Couchbase client is in fact setting expirations and working appropriately as part of http://www.couchbase.com/issues/browse/PCBC-81

The thing is, from this thread it seems to be pecl/memcached and there are some settings in the framework which we're not familiar with. Based on verification, it looks like the server is doing the right thing and I believe pecl/memcached probably is, so some digging in the framework will probably be needed.

Have you looked in there rtwheato?

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker