Hi!
I'm using Captcha module on one of my sites. And recently i've noticed that overall database size has grown too much (more than 50mb). When dug into I've revealed that about half of that size is caused by Captcha_sessions table.

I've searched the site and google and found no clue on how to deal with this table. I wonder what this table stores in 220,391 lines and what will happen if I'll empty it.

Thanks a lot in advance!

Comments

soxofaan’s picture

Status: Active » Fixed

you have to run your Drupal site's cron script, which (among other things) truncates the captcha_sessions table.

you can run cron manually from the status report
but you should automate this, which depends on your setup
more info: http://drupal.org/getting-started/6/install/cron

davide1982’s picture

thanks very much for useful answer! it really helped!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

yakker’s picture

I have exactly the same problem, but cron isn't touching the table. Anyone else? Any thoughts?

We're using.
Captcha 6.x-2.2
ReCaptcha 6.x-1.4

ImageCaptcha module is turned on, so is ReCaptcha mailhide. We've done no config or setup changes for a couple of weeks, but are getting slammed with "Duplicate Entry" and "Incorrect Key for Table" errors in the watchdog, and captcha checks are failing 100% of the time.

yakker’s picture

Status: Closed (fixed) » Active

The captcha_sessions table had crashed. We're unsure why. We repaired it and truncated it manually, now everything's dandy. I'm not technical enough to really muse about what happened, but we've had a rash of spam this past week, and the table itself had a block of about 300 requests from a single IP address. Could it be that a bot out there is crashing that table with how it's attacking captcha?

soxofaan’s picture

cron isn't touching the table

Note that the CAPTCHA's cron function will only remove sessions older than one day. So there will still be sessions younger than one 24 hours.

but are getting slammed with "Duplicate Entry" and "Incorrect Key for Table" errors in the watchdog, and captcha checks are failing 100% of the time.

Please provide the precise error messages.

Could it be that a bot out there is crashing that table with how it's attacking captcha?

That is not easy to say. The most probable way an attacker could do to crash your table is making a lot of request in a short time. There are no real user "manipulatable" fields in that table that can help an attacker to crash the table.

yakker’s picture

Thanks for the speedy interest, soxofaan. I was posting in two threads and didn't update this one with details (apologies). It's been a few days now and we look okay so far, but here are the error messages that we were getting, and some more details.

(Original Message...)

Working with our host tech support, we discovered that the captcha_sessions table had crashed. Still no idea how or why. He repaired that table, I emptied it, and we're back in business.

Just in case it helps anyone else, the major watchdog errors were (I deleted the VALUES below):

Duplicate entry '411019' for key 1 query: INSERT into captcha_sessions (uid, sid, ip_address, timestamp, form_id, solution, status, attempts) VALUES (...) in /www/oursite.com/html/sites/default/modules/captcha/captcha.inc on line 92.

And:

Incorrect key file for table './opusdrupal/captcha_sessions.MYI'; try to repair it query: DELETE FROM captcha_sessions WHERE timestamp < 1279739702 in /www/oursite.com/html/sites/default/modules/captcha/captcha.module on line 152.

Other concomitant factors:

1. There was an attempt to access a PHPMyAdmin installation on our domain. It was systematic - trying all version names as potential directories, etc.
2. There seemed to be a block of about 300 entries in captcha_sessions all from the same IP address for many different requests (I didn't ask for more detail).
3. cron.php did NOT clear captcha_sessions
4. clearing the cache did not clear captcha_sessions
5. we are only using Drupal's caching system - no others present.

Thanks to everyone who took the time to post their issues - it helped give us direction really quickly!
:)
Chris

elachlan’s picture

Issue summary: View changes
Status: Active » Closed (outdated)