Final blog post about datapatch cleanup and purge?

Uh … this was a long journey. In September 2022 Jannes Arends contacted me showing me his growing SYSTEM tablespace with every patch cycle. And not only for the CDB$ROOT only but in every PDB. Over time, I wrote some blog posts I link at the end of this blog post. But finally, we should have a working solution without any additional risk. So, I am hoping that this will be my final blog post about datapatch cleanup and purge.

Final blog post about datapatch cleanup and purge?

Photo by Clay Banks on Unsplash

What’s the point (summary)?

With every patch run, datapatch stores the entire collection of rollback scripts (sql and plsql) in a zip file in the SYSTEM tablespaces. The previous zips aren’t needed anymore since the newest always contains the previous ones. But since this zip grows unavoidably with every patch run, more and more space is wasted. And this waste-curve grows.

Here you can find queries and more.

Santosh and the datapatch team then developed a solution. It took a bit since we also needed to ensure to release the space. All looked fine – until the regression testing team gave a red alert. In one of the tests there was an issue with some check queries in the mechanism. They had to be taken out – and the patch got pulled from the RU content.

The same did happen with the next attempt since it turned out that the purge of this metadata which was supposed to happen automatically took over 7 hours on a heavy regression testing environment which had gotten a lot of patches over time.

A decision then was taken by Santosh and the datapatch team to add a flag instead of making the purge the default. This way, you can decide when you want to run it.

 

Finally, relief

Lots of back and forth. And finally, this is the patch number you need:

One-off patches are available for 19.25.0, 19.26.0 and 23.7.0 currently.

It adds a new flag:

  • ./datapatch -purge_old_metadata

This will trigger the cleanup. And you can decide when you want to do it. The fix is supposed to be included in the July 2025 Release Updates (19.28.0).

 

Did I write FINAL?

Added July 14, 2025

Thanks to Andreas Groetz, I learned today:
There is a new fix available:

  • Bug 37738908 – SEPARATE PURGE_OLD_METADATA FROM PATCHING ACTIVITY IN DATAPATCH

What does the fix for Bug 37738908 do differently than the previous one for Bug 37352486?

It simply decouples the purge/cleanup from patching. This means, when you call:

./datapatch -purge_old_metadata

with the previous fix, bug 37352486, it will cleanup AND patch.

But when you applied the fix for bug 37738908, it will ONLY cleanup with the above call, and WON’T patch.

As usual, thanks Andreas!

 

Did I REALLY write FINAL?

Added July 31, 2025

The fix was supposed to be included in 19.28, and it still isn’t.

Why is that? There was one final change which had to be done:
Decouple the cleanup from the patch run. So, you either “patch” or you “cleanup” but not both at the same time.

This decoupling lead to missing the cutoff time for 19.28. The fix will be actually in 19.29. Sorry for all the inconvenience.

 

More to add …

Added June 8, 2026

A customer pointed me to this MOS note:
(KB153775) Can Folders/Files under $ORACLE_HOME/sqlpatch/<DB RU Patch Number> be deleted to regain free space? which explains when and how you can manually cleanup.

 

And even more …

Added June 10, 2026

See KB813695: Applying 19.29 DB RU which has fix of Bug 37738908 does not reduce the REGISTRY$SQLPATCH_RU_INFO Size about the decoupling of purge and patch apply which was done in regards to not harm performance.

 

Further Links and Information

 

–Mike