106
GB
What is the next-key lock in MySQL InnoDB and how does it combine gap lock and record lock?
IN
MySQL InnoDB में नेक्स्ट-की लॉक क्या है और यह गैप लॉक और रिकॉर्ड लॉक को कैसे संयोजित करता है?
A
A lock that advances to the next available record
एक लॉक जो अगले उपलब्ध रिकॉर्ड की ओर बढ़ता है
B
A combination of a gap lock + record lock that locks both the index record AND the gap before it; used as the standard locking unit in InnoDB for REPEATABLE READ - e.g. next-key lock on value 20 locks the record 20 AND the gap (10 20)
गैप लॉक + रिकॉर्ड लॉक का एक संयोजन जो इंडेक्स रिकॉर्ड और उसके पहले के गैप दोनों को लॉक करता है; बार-बार पढ़ने के लिए InnoDB में मानक लॉकिंग यूनिट के रूप में उपयोग किया जाता है - उदाहरण के लिए। मान 20 पर अगली-कुंजी लॉक रिकॉर्ड 20 और अंतर (10 20) को लॉक कर देता है
C
A lock on the next transaction in the queue
कतार में अगले लेन-देन पर ताला
D
A lock on the next row in the table
तालिका में अगली पंक्ति पर एक ताला
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English)
Next-key lock = gap lock on (prev_val, current_val) + record lock on current_val. For index (10, 20, 30): next-key locks are (-inf,10], (10,20], (20,30], (30,+inf). A range query locks all next-key locks in the range. Prevents both modification of existing rows AND insertion of new rows in the range.
व्याख्या (हिन्दी)
नेक्स्ट-की लॉक = गैप लॉक ऑन (prev_val, current_val) + करंट_वैल पर रिकॉर्ड लॉक। इंडेक्स (10, 20, 30) के लिए: नेक्स्ट-की लॉक (-inf,10], (10,20], (20,30], (30,+inf) हैं। एक रेंज क्वेरी रेंज में सभी नेक्स्ट-की लॉक को लॉक कर देती है। रेंज में मौजूदा पंक्तियों के संशोधन और नई पंक्तियों के सम्मिलन दोनों को रोकता है।