I noticed our key_value_expirable table growing and growing. The vast majority of entries were honeypot_time_restriction with an "expire" of "2147483647" the column default.

In honeypot.module, shouldn't the calls to
\Drupal::service('keyvalue.expirable')->get('honeypot_time_restriction')->set($identifier, REQUEST_TIME, 3600*24)
be
\Drupal::service('keyvalue.expirable')->get('honeypot_time_restriction')->setWithExpire($identifier, REQUEST_TIME, 3600*24)
??

Comments

krlucas created an issue. See original summary.

krlucas’s picture

Title: Honeypot key value entries never expire » Honeypot key value entries never expire (effectively)
StatusFileSize
new1.34 KB

Here's a starting patch
...without tests nor any update hook to clean up the existing entries.

j.b’s picture

Hello, this issue causes our database to keep growing in size considerably.

geerlingguy’s picture

Link to the docs for setWithExpire. This looks like a bit of an oversight when I converted the code from D7!

geerlingguy’s picture

Status: Active » Needs review
geerlingguy’s picture

Just noting for myself that the default value for honeypot_expire in D7 was 300 seconds. The patch in #2 sets the expiry for one day... any thoughts on what the best sane default would be? 5 minutes is probably pretty short and many (most) sites don't even run cron every 5 minutes, so the keys wouldn't be expired then anyways...

darkstartom’s picture

I'm having the same problem. Is it safe to manually remove the honeypot_time_restriction rows from the key_value_expire table?

nitnac23’s picture

I have been emptying the key_value_expire table manually once a month to get rid of this issue. @DarkstarTom it is fine to empty the table it stores private and shared temp store. For example, you may lose unsaved changes to a view or form.

geerlingguy’s picture

Status: Needs review » Needs work

Ideally I'd like a test added. Additionally, an update hook that clears out any existing entries, maybe?

nick_vh’s picture

We faced this issue with more than 3 million rows. Clearing the rows caused the database to completely fail and needed a reboot. I agree a update hook is required before this can go in. But that said, any new installs using this module are exposed to this bug. Therefor I suggest you get this in the dev version and work on 2 new issues, 1 is a test + 1 is a update hook.

j.b’s picture

I had 12 million of entries related to honeypot_time_restriction in my database and my website has been online for 1.5 years.
I had to put in place a batch process which gets executed at night for a total duration of 5 hours to clean up my database gradually over a period of 1 week.

geerlingguy’s picture

Status: Needs work » Reviewed & tested by the community

Makes sense; let's stop the bleeding, and then I'll open a follow-up ticket to add the update hook.

geerlingguy’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.4 KB

Had to update the patch.

  • geerlingguy committed 7be9671 on 8.x-1.x
    Issue #2931611 by geerlingguy, krlucas: Honeypot key value entries never...
geerlingguy’s picture

Status: Needs review » Fixed
geerlingguy’s picture

Status: Fixed » Closed (fixed)

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