Skip to main content
1-Visitor
April 21, 2017
Question

Async service not able to fetch data table entry

  • April 21, 2017
  • 3 replies
  • 6874 views

Hi All,

We are facing unexpected behavior of Async service when called from sync service.

While calling Async thingworx service, database related operations were not functioning well when called from sync service after logging entry in Data table. When async service tries to fetch the entry from data table using primary ID, no result is getting returned.

Logic details:

Sync service A adds entry in data table and calls Async service B (pass primary ID of same data table entry) for further processing of request.

But this seems to be working windows platform and issue encountered on linux ONLY.

As per the understanding, this could be due to the way platform handles multi-threading as async execute on separate thread or may be accessing data table before commit operation pf previous update.

Please let us know in case anybody faced this issue and what all options resolutions are available.

3 replies

esirohi1-VisitorAuthor
1-Visitor
April 25, 2017

[Update]

Just to update that we have analyzed further on this issue and tried to reproduce the same issue on local Linux VM using same client VM configuration and things are working fine.

I am not sure what exactly the issue is and there might be some difference in the installed packages. We are still working on this and update further on this thread if I get some more details.

1-Visitor
April 25, 2017

You are facing what you are saying here:

"As per the understanding, this could be due to the way platform handles multi-threading as async execute on separate thread or may be accessing data table before commit operation pf previous update."

As async operation it's executed before you sync process ends ( the transactions start when your services starts and ends when your service ends ).


esirohi1-VisitorAuthor
1-Visitor
April 25, 2017

Hello Carles Coll​,

On client VM (RHEL 7.2 version, 64 bit arch), using one service I am inserting a data in data table and using async to retrieve the already inserted record using the same ID, I am not able to perform or fetch the data entry made sync service and getting message that record doesn't exist.

This works well when tested locally on windows platform but facing issue when the same is deployed on Linux VM. My understanding was that this could be due to different platforms multi-threading capability.

But another update provided above as per further analysis, this problem is not due to different platforms and everything is working fine even with linux VM when tested locally. There might be some difference in installed packages on both the Linux VMs.

I am still analyzing this and I am not sure what exactly is the problem. It could be configuration differences.

1-Visitor
April 25, 2017

You never know when a async process will be called ( at the same time, after, sometimes at the same time some times after,..), then it may act differently depending on the platform, but you should avoid this kind of situation, it's a shame but you will need to execute it synchronously or put on a queue ( there's no queues system on TW you will have to build your own or import a queue system as an extension ).

esirohi1-VisitorAuthor
1-Visitor
April 29, 2017

Just a workaround,

We have added pause function (seconds of delay) on async thread to avoid race condition for time being. Ideally, there should be only one triggering point for async call but we designed it as per our use case requirement. We are still looking for better implementation and might re-design this solution accordingly.

We have dona a good amount of analysis for this and anyone can contact if required.

1-Visitor
April 29, 2017

Hi Eklavya,

Not, with pause you don't solve anything, you will face exactly the same problem, as your async process starts at the same time as the other transaction it's running, then on the starting point of the Async process the Database status it's without data.

You don't control the transaction, the transaction it's controlled by TW and it starts at Service Call.

Carles.