Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Hi,
I wonder how the thingworx prevent from the deadlock ?
Do I need to take care of the deadlock during developing the javascript service ?
Does the Query* / Get* / Find* service of Thing generate SQL like select xxx for update ?
Regards,
Sean
For your questions:
1. Deadlock does happen a lot in production environment if the Javascript is not carefully managed (long script, for loops, etc) . And if deadlock happens, the CPU will go high and Tomcat server down in a short time. So to decrease that happening, carefully design the code, use some try catch block, leave some padding time between connected services and don't call the complex script too frequently.
2. the function are the same, and it searches data from the exact table in Persistence provider. Since Database like MSSQL and PGsql only accepts SQL command input, so yes, the API points to the Select commands
Just my two cents:
No, I mean a queue system for executing services on a queue where you have control of what's going on, what's executing and what's going on in parallel and whats not.
Do you mean something like ActiveMQ ?
Sorry I don't know if thingworx has a built-in queue system, for example, if I want several services get executed in serialization, how to do it in thingworx ?
@zyuan1 ,
Is it SELECT or SELECT ... FOR UPDATE ?
If it's SELECT only, then the dead lock occurs if the purpose of SELECT is for Updating. For example:
process A: SELECT * FROM purchases WHERE processed = false;
--- process B updates the data while process A is processing it
process B: SELECT * FROM purchases;
process B: UPDATE purchases SET ...;
process A: UPDATE purchases SET ...;
If it's SELECT ... FOR UPDATE then it's possible to mitigate the above case .
BEGIN;
SELECT * FROM purchases WHERE processed = false FOR UPDATE;
-- * application is now processing the purchases *
UPDATE purchases SET ...;
COMMIT;
Regards,
Sean