Article
· Oct 30 2m read

EnsLib.SQL.Snapshot not cleaned during purge messages when used in Response Message

Hi All,

First I want give a Shout Out to @Theo Stolker  and @Rupert Young. Because they helped me with the solution.

 When you're using the EnsLib.SQL.Snapshot as a Property in the Response Message to return Snapshot data (,e.g.: from Business Operation to Business Process,) the Snapshot data won't be cleaned with the Purge messages task/service.

Class ResponseMessage Extends Ens.Response

{

    Property SnapshotProp As EnsLib.SQL.Snapshot;

}

The data will be stuck in the global: ^Ens.AppData. You can find it with this query in System>Globals:  ^Ens.AppData("EnsLib.SQL.Snapshot",

The reference is recored in the class:  EnsLib.SQL.Snapshot you can query it with SQL: SELECT * FROM EnsLib_SQL.Snapshot ORDER BY ID asc

These data won't be deleted during the Purging task. So the Data will be growing over time. When you have this issue, you can clean all the data manually with the following method:

  • Clean Global: ^Ens.AppData:
    • Stop Production
    • Run on terminal: do ##class(Ens.Adapter).ClearStaticAppData("EnsLib.SQL.Snapshot")
    • Start Production
  • Clean EnsLib_SQL.Snapshot :
    • Delete with SQL: TRUNCATE TABLE EnsLib_SQL.Snapshot

But this is not ideal, especially in PRD evironment.

Solution:

This issue only happens when you're returning data from BO to BP, or maybe from BP to BS. Because the idea is the same. 

One solution is not to use EnsLib_SQL.Snapshot as a property in the return message. But to map the data to another objectType (e.g.: JSON as String, other classTypes).

Another solution is to make the Purging task purge the Snapshot data with  %OnDelete method:

https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=GO...

So:

Class ResponseMessage Extends Ens.Response
{

    Property SnapshotProp As EnsLib.SQL.Snapshot;

   ClassMethod %OnDelete(oid As %ObjectIdentity) As %Status [ Private, ServerOnly = 1 ]
   {
   
      set id = $$$oidPrimary(oid)
      set obj = ..%OpenId(id)
    
      return ##class(EnsLib.SQL.Snapshot).%DeleteId(obj.SnapshotProp.%Id())
   }

}

Hope it wil help you as it's helped me!


 

Discussion (0)1
Log in or sign up to continue