Skip to main content
1-Visitor
July 24, 2015
Question

Unable to cleanup value stream in loop

  • July 24, 2015
  • 2 replies
  • 6391 views

Hi,

 

I have multiple properties of thing enabled for logging using value stream. after testing, I want to purge all properties value stream data. So I executed purgepropertyhistory for each property in loop. It does not work. I then notice below error in application error log.

 

"Unable to process purgeBetweenNow Request for MoldMachineVars : Another request for this thing is active"

 

Is there simple way of purging all properties valuestream data?

 

Regards

Satish

    2 replies

    1-Visitor
    July 27, 2015

    Did you try this using the Immediate option?

    satish1-VisitorAuthor
    1-Visitor
    July 28, 2015

    No Pai. Immediate option was set to false. Also once I receive error, I can not even purge manually by calling purge for each individual property. I simply have to drop value stream and recreate to cleanup data.

    Sent from my iPhone

    1-Visitor
    July 28, 2015

    I would try this with Immediate set to true, it is there for this type of use case I believe.

    If you get 'hung up' you should re-start Tomcat to flush the memory and you should be able to continue.

    5-Regular Member
    November 9, 2015

    I found that the OOTB PurgePropertyHistory ​has limitations, you gotta input property name and end date.

    So I wrote a service like following code to clean all properties history during a given period.

    Service inputs: startDate, endDate (you must input endDate while testing the service)

    var params = {

    type: undefined /* BASETYPENAME */

    };

    // result: INFOTABLE dataShape: "PropertyDefinition"

    var LoggedPropertiesIT = me.GetLoggedProperties(params);

    var tableLength = LoggedPropertiesIT.rows.length;

    for (var x = 0; x < tableLength; x++) {

    var row = LoggedPropertiesIT.rows;

    //Your code here

       

        var params = {

    propertyName: row.name /* STRING */,

    endDate: endDate /* DATETIME */,

    immediate: true /* BOOLEAN */,

    startDate: startDate /* DATETIME */

        };

    me.PurgePropertyHistory(params);

    }

    1-Visitor
    November 12, 2015

    I used this method, but I have a strange problem. "me.GetLoggedProperties(params)" give me a table of 20 properties (automatically in alphabetical order). Sometime, the last one is not purged. And the service blocks !

    5-Regular Member
    November 13, 2015

    This service worked perfect for my case.

    I put this service in ThingTamplate, and tested the service on several Thing instance.

    First, did GetLoggedProperties(params) returned the right logged properties infotable?

    Second, you can try to test the OOTB PurgePropertyHistory service with the last property name and endDate input, see if it got problems.