Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

mysql/php deadlock problem... need efficient way to solve it

yeahman45yeahman45 Posts: 2Member
here my problem:

i am developing a web application allowing you to create modules(a piece of code to execute) and execute them. One particularity about the application is that you can make compositions of modules. i.e. a module can be composed of several other modules. I have designed a scenario below so that you can understand more easily:

i have 8 modules: 1,2,3, 4,5,6,7 and 8

I have my initial setup (Scenario 1)

[img]http://postimage.org/image/5cspmguc/[/img]

Module 1 is composed of module 2 and 3.
Module 2 is composed of module 4 and 6.
Module 5 is composed of module 1 and 7.
Module 8 is composed of module 5

[b]Execute module 1:[/b]
Now,e.g., if i execute module 1... it will execute module 2 + module 3.

As module 2 is composed of module 4 and 6, the latters will also be executed.

This is the execution chain. In the diagram, the left hand side shows all the modules that are actually executed


[b]The problem[/b]
In scenario 1, everything is ok and executes smoothly... but in scenario 2, i add module 5 to module 1.

When you execute module 1, it will execute module 2, 3 and 5. As module 2 is a composition, it will also executes module 4 and 6 found in module 2. And as module 5 is a composition too, it will execute module 1 and 7 found in 5.

The problem is that the module 1 found in module 5. It will also execute.... you can see that this will result in an [b]infinte loop[/b]!!! kind of a deadlock!

same thing happens in scenario 3 where i add module 8 to module 1. Module 8 has module 5 as child and the latter has module 1 as child. This will also result in a deadlock!!

[b]What is the solution??[/b]

My problem is how to detect such deadlocks?? When i am composing module 1, e.g., i should not be given the option to add module 5 or module 8 as they would cause a deadlock....

In my interface, when i am composing/editing a module, i am giving a list of all modules available (1,2,3,4,5,6,7,8) which i can click and add to the module i am composing/editing. I need to filter/hide all the modules that will cause a deadlock.

[b]database structure[/b]
Below is my database structure:

[img]http://imageshack.us/photo/my-images/840/tablesq.png[/img]

The values in the tables are for scenario 1.

and i am using javascript/html, php and mysql. I have idea how to efficiently detect these deadlocks... can it be done all in a query? (e.g. when i am editing module 1, i write a query to fetch only modules that will not cause deadlocks)

Your advices and tips are most welcomed.. thx for reading this lengthy topic.
Sign In or Register to comment.