Hello there,
I've just lost a month's worth of data which is stored in Thing's infotable property. It happened to me few times and I cannot pinpoint what exactly is causing it.
Most often it happens in the 'edit' mode, though the work conducted has nothing to do with that infotable. The property is set as persistent. The infotable is part of the ThingShape which in turn is inherited by the ThingTemplate. An entry is made on an hourly basis by a service.
Does anyone know why it happens and how to prevent such events?
What happens when the service creates an entry in the infotable, the thing is in the 'edit' mode and the user clicks 'cancel'?
Tomcat 8.0.38, psql 9.4.11, Win 2012 r2
Thanks.
Solved! Go to Solution.
Ok the code it's wrong
Persistence on Infotable Properties only happens when there's a DataChange event, and the way you are adding rows doesn't throws data change event o that property.
To ensure a DataChange event it's thrown on a Infotable Property you must rewrite the whole property not just adding a row.
Then the correct code for interacting with a Persistent Infotable Property it's:
var copy = Resources["InfoTableFunctions"].Clone({ t1: me.myInfoTableProperty });
var newEntry = { };
copy.AddRow(newEntry);
// -- And this is the key to force persistence
me.myInfoTableProperty = copy;
First of all, Infotable properties aren't designed to store hourly basis data, that's a lot of data for a Infotable Property ( they keep in memory... )
Anyway, how it's your code that records hourly basis data on the infotable property?
Carles Coll, thanks for reply!
The code for creating an entry is pretty simple.
Scheduler->Service->'NewEntry' object->AddRow
var newEntry = new Object();
newEntry.someField = someValue;
...
me.HourlyTable.AddRow(newEntry);
Is there a figure for the infotable size limit? Making it a data-table, would it help? Cheers
Ok the code it's wrong
Persistence on Infotable Properties only happens when there's a DataChange event, and the way you are adding rows doesn't throws data change event o that property.
To ensure a DataChange event it's thrown on a Infotable Property you must rewrite the whole property not just adding a row.
Then the correct code for interacting with a Persistent Infotable Property it's:
var copy = Resources["InfoTableFunctions"].Clone({ t1: me.myInfoTableProperty });
var newEntry = { };
copy.AddRow(newEntry);
// -- And this is the key to force persistence
me.myInfoTableProperty = copy;
But as said before, better you go with Streams to store this kind of information.
That explains my 'vague' data loss problems. Could you please elaborate on the following point?! What will happen if I change 'infotable type' to stream? Will the infotable be still persisted only on datachange event? Would be there a corresponding entry created in the data storage, streams page? Perhaps I'm confusing both. Thanks.
You can't change Infotable property to Stream, what you will do it's remove the property and record historical data on the Stream.
Then, when using Streams everything you add to it will be persisted ( Asynchronously ) for sure ( at least if you don't record data points at the exact same timestamp - millisecond precision - ) . Streams are kind of traditional database tables, specially designed to store time series data, but writes are asynchronous, if you want synchronous writes then you will need a Data Table.
Best Regards,
Carles