Problem/Motivation

We noticed the log can become unreasonably large if a lot of files are being purged.

Large logs by itself are not the problem but the fact that this is serialized and written to a single row in
the key_value table causes some issues. The 3 main issues we experienced are.

1) Purge jobs become slower as the serialized string get larger (in our case about 100mb in serialized string)
2) Cannot visit the log page anymore because the string is to large for memory
3) If you have slow query logs turned on this can grow exponentially (350gb log in one day in our case)

This can be partially mitigated by setting the retention if the logs to a much smaller time at the cost of having less log history

Proposed resolution

My proposed solution is to not use the key_value table / Drupal::state to log purges but to add its own logging table so updates
won't have to be done in one single large serialized string.

Remaining tasks

Refactor code to use own logging table/ logging entity

Data model changes

Remove the akamai.purge_status state and move logs to own table.
Old data will need to be migrated to this new table

Comments

melvinlouwerse created an issue. See original summary.

smustgrave’s picture

Assigned: Unassigned » smustgrave

Giving this a shot. So far I've

  1. Created a custom table
  2. Wrote an update that will move the current statues out of the key_value table into the new table
  3. Updated the StatusLogController to read from the new table vs pulling from key_value
  4. Updated cron to delete from the table and not load that string
  5. This is where I'm not too sure. I created 2 new files PurgeStatusNew and StatusStorageDB to work with the table. Reason I didn't alter the files already there. Didn't think I could because I needed them to stay the same for the transfer from key_value to the new table

Where I'm at so far just wanted to share.

smustgrave’s picture

StatusFileSize
new25.61 KB

Ok this is my first crack at it. Think I'm going down the right track but any feedback would be greatly appreciated. Somewhat hard to test so I was relying on the prewritten tests.

I still left the old PurgeState and StatusStorage files as I'm not sure what to do with those.

smustgrave’s picture

StatusFileSize
new27.78 KB

Fixed a few things.

smustgrave’s picture

StatusFileSize
new22.42 KB

Was able to replace the old status and statusStorage files while still being able to move over the old records to the new table.

smustgrave’s picture

Status: Active » Needs review
smustgrave’s picture

I've neglected this ticket some what sorry about that. Has anyone had a chance to review?

WidgetsBurritos’s picture

Assigned: smustgrave » pobster
Priority: Normal » Critical
Status: Needs review » Needs work

@smustgrave, Sorry for the silence on this. I meant to get to this a while ago, but my priorities have been a bit all over the place.

I can confirm this is a big issue. In fact, I'm labeling this as "critical", as I think it's a blocker for a stable release. We have plans to try to fully evaluate the solution and see if we can't finalize something here within the next few weeks.

smustgrave’s picture

I'd be happy to help where I can. Is there a way to setup a fake akamai account for testing?

WidgetsBurritos’s picture

To be honest, I'm unsure. Might be worth reaching out to akamai to find out. If you do, let me know what they say. I can do it too, but can't right at the moment.

smustgrave’s picture

pobster’s picture

StatusFileSize
new15.85 KB

Try this...

pobster’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 12: akamai-status-table-3001392-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

pobster’s picture

Hmmm I was worried about this, the collating of results by purge IDs no longer works. Needs more thinking about...

Then again, maybe the test is wrong;

https://developer.akamai.com/api/core_features/fast_purge/v3.html

purgeId String ○ Unique identifier for the purge request.

Now I've no idea what to do...

pobster’s picture

https://community.akamai.com/customers/s/question/0D50f00005RtqL4CAJ/how...

Okay so ... what I might do then, seeing as how this purely exists for checking the status of purges and as https://www.drupal.org/project/akamai/issues/3160840 exists ... I might just chop out status logging entirely? There's no need to store them, Akamai themselves are saying so. This has ceased to be a log for status checking, and now it's just a watchdog for purges.

This only existed previously in the D7 version as a means to "force a status check" to see if something has purged. But ... that code doesn't even exist anymore, previously it used to check on a cron (!) https://git.drupalcode.org/project/akamai/-/blob/7.x-3.x/akamai.cron.inc...

pobster’s picture

Status: Needs work » Needs review
StatusFileSize
new16.67 KB

For test... (and I'll refactor in the "remove CCUv2" issue).

Status: Needs review » Needs work

The last submitted patch, 17: akamai-status-table-3001392-17.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

smustgrave’s picture

So if you're getting rid of statues all together. Should this ticket be repurposed to delete any code centered around statues and clear out the key_value entries.

pobster’s picture

I'll need to check what needs to be removed/ changed (mainly to avoid confusion). And obviously for debug it'll be best to leave in the the purge logs and still have cron expire them - I'll do it today, it's now part of my sprint work.

pobster’s picture

Okay ... I've gone over the Remove CCUv2 Support ticket, and can confirm that this ticket is now a duplicate. The status log only existed for the sake of CCUv2 - and in removing it, I've also removed all the status log code as well.

Note, I've also realised that there's no need to implement a purge log (which I'd considered might be useful), as there's already the facility to turn on;

DEVELOPMENT OPTIONS
Log requests
Log all requests and responses.

...which logs to watchdog anyway.

Once that ticket is reviewed/ merged, I'll close this one too.

pobster’s picture

Status: Needs work » Postponed

Currently testing in production, will merge ... next week? Then we can close these two tickets.

pobster’s picture

Status: Postponed » Closed (won't fix)

Okay, we can consider the CCUv2 patch very well tested, and as such I've merged it and am closing this issue.

Thank you!