Technique | Kaise Kaam Karta Hai | Jethalal's Example | Pros/Cons |
---|---|---|---|
🔑 Resource Ordering | Resources ko hamesha same order mein allocate karo | Pehle hamesha Daya, phir Babita - ulta nahi! | ✅ Simple | ❌ Restrictive |
⏰ Timeout | Zyada der wait karo to query cancel kar do | 5 minute wait kiya, ab chhod do intezaar! | ✅ Practical | ❌ May lose work |
⚡ Short Transactions | Jaldi-jaldi kaam khatam kar do | Babita se 2 minute baat, phir chhod do! | ✅ Reduces deadlock chance | ❌ May need multiple txns |
🔍 Auto Detection | System khud deadlock pakad ke resolve kare | Database samjh gaya - ek query ko rollback kar diya! | ✅ Automatic | ❌ Some work lost |
Scenario | Deadlock Situation | How it Happens | Solution |
---|---|---|---|
🏦 Banking System | Two accounts transfer kar rahe hain | Account A locks Account 1, Account B locks Account 2, dono ek-dusre ka wait | Resource ordering - hamesha lower account number first |
🛒 E-commerce | Inventory update aur order processing | Order locks product, inventory locks order table | Short transactions, proper lock ordering |
📱 Phone System | Do calls simultaneously connect | Call A dials B, Call B dials A at same time | Call queueing, timeout mechanism |
🚗 Traffic Intersection | Chaar taraf se cars aa gayi | Sabko straight jaana hai, koi peeche nahi hat sakta | Traffic signals, roundabouts |
💻 File System | Two processes file access kar rahe | Process 1 ne File A lock kiya, File B chahiye. Process 2 ulta | File locking hierarchy, deadlock detection |