Skip to main content
17-Peridot
September 11, 2019
Question

[1,018] Data store unknown error: [Error occurred while accessing the model provider. ?

Hi ,

When creating DataTable with service dynamically,  I sometimes get the error "[1,018] Data store unknown error: [Error occurred while accessing the model provider." . 

 

var params = {
name: dataTableName,
description: "",
thingTemplateName: "DataTable",
};

Resources["EntityServices"].CreateThing(params);

Things[dataTableName].SetDataShape({ name: shapeName });
//Things[dataTableName].SetProjectName({ projectName: "ABCD" });

Things[dataTableName].EnableThing();
Things[dataTableName].RestartThing();

Things[dataTableName].SetPersistenceProvider({
name: persistentProvider
});

Resources["EntityServices"].AddShapeToThing({
name: dataTableName /* THINGNAME */,
thingShapeName: "LockableThing" /* THINGSHAPENAME */
});

Things[dataTableName].EnableThing();
Things[dataTableName].RestartThing();

 

And, if error occurs, I have the following exception handling to rollback: 

 

 var params = {
name: dataTableName /* THINGNAME */
};
try{
Resources["EntityServices"].DeleteThing(params);
logger.debug("Rollback data table "+dataTableName + "finished");
}catch(error2){
logger.debug("fail to rollback data table "+dataTableName + ". Error: " + error2 ); // result: INFOTABLE dataShape: "EntityReference"
var existingGhostEntities =
Resources["GhostEntitiesResource"].GetGhostEntities({
deleteGhosts: true /* BOOLEAN */
});
}

 

Even though,  if the error "Data store unknown error" occurs then it will always occur unless restart tomcat .  Any suggestion ? 

 

Thingworx 8.4.2 + Postgresql 10.x

 

Regards,

Sean

12 replies

22-Sapphire I
September 11, 2019

Is this creation service execution in a set security context?

Data store unknown could be a visibility permission problem.

ie. the security context (user) that is executing the service may not have permissions to see the Persistence Provider associated with the DataTable you are creating

Translate
seanccc17-PeridotAuthor
17-Peridot
September 12, 2019

@PaiChung ,

 

No,  I'm currently using Administrator to run the creation service.  It will be executed in a security context when my project go live , but for now it's only executed by Administrator.   

The strange thing is that the error occurs randomly , about 1 time out of 5~20 executions.  

Translate
raluca_edu
17-Peridot
September 12, 2019

Hi,

 

You can try to look into Tomcat logs (stderr), sometimes there is another error behind Data Store Unknown Error, and get a hint. 

 

Thanks,

Raluca Edu

Translate
18-Opal
September 12, 2019

Hello Sean,

 

I'm sorry for not answering your question, just wondering what is your use case for creating data tables programmatically -- is that for visibility purposes?

 

/ Constantine

Translate
17-Peridot
September 12, 2019

@seanccc , 

 

Have you looked at this Article CS239982 This article discuss how to enable a stack trace which may provide more information on what action is causing the problem.

Translate