Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#45277 closed defect (bug) (duplicate)

Garbage collect transients

Reported by: dartiss's profile dartiss Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.1
Component: Options, Meta APIs Keywords:
Focuses: Cc:

Description

5 years later, I would like to re-open the discussion about the fact that transients are not correctly housekept (see #20316).

The issue... expired transients are only housekept if the transient is read. If it is not read, it remains in the database.

The solution... perform a daily garbage collection on expired transients

This was not implemented 5 years ago because "we don't want a core update to be blamed for breaking a site that incorrectly assumes transients aren't transient". I would like this discussion to take place again - during this time, I have implemented the housekeeping solution with my own plugin (https://wordpress.org/plugins/artiss-transient-cleaner/), which has had over 73,000 downloads and not a single person reporting issues (in fact, it's known to fix some issues for some users). I'd really like to see this issue resolved and my plugin becoming redundant!

I'd also like to take the conversation further than before, where the solution was via MySQL. This works where transients are stored on the database, but isn't the case for object caching. I have an alternative solution that will work for all storage methods...

  • Enhance the set_transient function (and set_site_transient) so that all transients with an expiry are also stored inside an array, stored on the options table. This array will contain the transient name and expiry.
  • Introduce a daily garbage collection task, which will look through this array, looking for expired transients
  • For all expired transients, use the existing functions (e.g. delete_transient) to remove the relevant transient.

By using this method, no SQL is required, so object cache will be correctly housekept too.

Change History (5)

#1 follow-up: @dimadin
6 years ago

  • Keywords close added

But isn't this already fixed in [41963] and [42008]?

What is a point in having transients garbage collector for object cache when object cache should already handle that?

#2 follow-up: @SergeyBiryukov
6 years ago

Sounds like a duplicate of #41699.

#3 in reply to: ↑ 2 @dartiss
6 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Replying to SergeyBiryukov:

Sounds like a duplicate of #41699.

Yes, you're right - I missed that. Apologies.

#4 in reply to: ↑ 1 @dartiss
6 years ago

Replying to dimadin:

What is a point in having transients garbage collector for object cache when object cache should already handle that?

Ah, that may be my misunderstanding of object cache - will the expired transients be automatically flushed in object cache, in this case?

#5 @SergeyBiryukov
6 years ago

  • Component changed from Database to Options, Meta APIs
  • Keywords needs-patch close removed
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.