Lec-80:Shared Exclusive Locking Protocol with Example in Hindi | Concurrency Control | DBMS | Part-1

Lec-80:Shared Exclusive Locking Protocol with Example in Hindi | Concurrency Control | DBMS | Part-1


Lec-80:Shared Exclusive Locking Protocol with Example in Hindi | Concurrency Control | DBMS | Part-1

👉Subscribe to our new channel:   / @varunainashots  

👉Link for DBMS Notes:
đź”—File 1: https://rb.gy/8g186
đź”—File 2: https://rb.gy/s7l18
🧑‍🎓Contributed by: Anurag Singhal

Lock Based Protocols in DBMS is a mechanism in which a transaction cannot Read or Write the data until it acquires an appropriate lock. Lock based protocols help to eliminate the concurrency problem in DBMS for simultaneous transactions by locking or isolating a particular transaction to a single user.

â–ş Database Management System(Complete Playlist):
   • DBMS (Database Management system) Com…  

Other subject-wise playlist Links:
--------------------------------------------------------------------------------------------------------------------------------------
â–şDesign and Analysis of algorithms (DAA):
   • Design and Analysis of algorithms (DAA)  
â–şComputer Architecture (Complete Playlist):
   • Computer Organization and Architectur…  
â–ş Theory of Computation
   • TOC(Theory of Computation)  
â–şArtificial Intelligence:
   • Artificial Intelligence (Complete Pla…  
â–şComputer Networks (Complete Playlist):
   • Computer Networks (Complete Playlist)  
â–şOperating System:
   • Operating System (Complete Playlist)  
â–şStructured Query Language (SQL):
   • Structured Query Language (SQL)  
â–şDiscrete Mathematics:
   • Discrete Mathematics  
â–şCompiler Design:
   • Compiler Design (Complete Playlist)  
â–şNumber System:
   • Number system  
â–şCloud Computing \u0026 BIG Data:
   • Cloud Computing \u0026 BIG Data  
â–şSoftware Engineering:
   • Software Engineering  
â–şData Structure:
   • Data Structure  
â–şGraph Theory:
   • Graph Theory  
â–şProgramming in C:
   • C Programming  
â–şDigital Logic:
   • Digital Logic(Complete Playlist)  

---------------------------------------------------------------------------------------------------------------------------------------
Our social media Links:
► Subscribe to us on YouTube:    / gatesmashers  
►Subscribe to our new channel:    / @varunainashots  
â–ş Like our page on Facebook: https://www.facebook.com/gatesmashers
â–ş Follow us on Instagram: https://www.instagram.com/gate.smashers
â–ş Follow us on Instagram: https://www.instagram.com/varunainashots
â–ş Follow us on Telegram: https://t.me/gatesmashersofficial
â–ş Follow us on Threads: https://www.threads.net/@gate.smashers
--------------------------------------------------------------------------------------------------------------------------------------
â–şFor Any Query, Suggestion or notes contribution:
Email us at: [email protected]
#WhatisSharedExclusiveLocking#DBMS


Content

0.407 -> Hello friends, Welcome to Gate smashers
2.92 -> In this video we're going to talk about concurrency control protocol
6.652 -> concurrency control protocol basic aim
10.133 -> is to achieve serializabity
12.787 -> and achieving recover-ability
14.652 -> and what are serializabity and recover-ability we had already discussed
19.372 -> Conflict serializabity, view serializabity
21.88 -> and in that we've discussed that how to check
25.052 -> that which schedule is serializable or which one is not
28.212 -> But
29.067 -> Aim of concurrency control protocol
31.827 -> is not to check but how to make them
35.513 -> that how to make it serializable
37.167 -> or how to make it recoverable
38.987 -> Schedule are concurrent
40.4 -> but how to make them recoverable and serializable
43.933 -> that comes under concurrency control protocol
46.732 -> and how we achieve this
48.8 -> By using the locking protocols
50.772 -> We've various locking protocols
52.74 -> Simple locking protocol under which comes Shared Exclusive locking protocol
56.74 -> There are 2 PL
57.82 -> Rigorous 2 PL
58.9 -> Strict 2 PL
59.987 -> Time stamp protocol so there are various protocols
61.972 -> But among these the shared exclusive protocol
64.2 -> and time stamp
65.253 -> are the most important ones
66.667 -> So like the video
68.5 -> Subscribe the channel who has not done yet and press the bell button
72.173 -> So that you'll be getting all notifications
75.927 -> Will start with Shared-Exclusive locking
78.853 -> It is very basic and the first locking protocol
82.94 -> or we can call simplest locking protocol
84.853 -> that is shared-exclusive locking
86.78 -> and here if we discuss we're using two types of lock
89.852 -> Shared lock
90.967 -> and exclusive lock
92.02 -> We use shared lock when if the transaction locked the data item
95.62 -> in the shared more then it is allowed to read only
98.56 -> and if in exlusive mode data is locked
102.812 -> then read and write both can be done, it means
105.767 -> Lets say transaction is T1
107.787 -> And Transaction has to perform Read(A)
111 -> A only want perform read
113.06 -> so what we'll do
114.887 -> We'll take shared lock on A
117.607 -> Now in this case there is no benefit of taking exclusive
120.293 -> Why? If only read is to be done
122.513 -> then we can achieve our work with shared mood only
125.932 -> and when is work is over
127.767 -> Then what we'll do
129.532 -> We'll unlock it
130.57 -> So S means shared and U means unlock
133.467 -> A means on which data item you're taking A,B,C you can take anything
138.052 -> Same if we talk about transaction T2
141.207 -> Read(A) and Write (A) both
144.487 -> If transaction has to perform Read(A) and Write (A) both
147.68 -> and in this case if I say that we've to take shared lock
150.573 -> That won't apply
151.972 -> What will apply in this case ?
153.947 -> In this there will be exclusive lock on A
156.812 -> What we can do in exclusive lock case
159.692 -> Read and Write both
161.867 -> and on shared lock case what we'll do
164.667 -> only read
165.72 -> and now if you are only read in exclusive
167.993 -> you can do that also but there is no benefit of that, by default we set the algorithm
172.42 -> or set software in such a way
174.727 -> that if want to read take shared
176.692 -> and if want Read and Write both
178.913 -> Then use exclusive lock
180.972 -> and when its work is over means when read and
183.792 -> write is done then it will perform unlock A
186.612 -> Like if someone else request they can get the lock
190.327 -> because in a transaction there is work done on multiple data items
193.567 -> So it is not unnecessary that only T1 need lock
196.06 -> There is T2, T3, T4
198.292 -> everyone acquires lock
200.28 -> so they will request for lock
202.092 -> so the concurrency control component
204.68 -> that will check
205.755 -> It will check compatibility table
208.212 -> and here the compatibility table is important
210.767 -> Questions may come on this
212.852 -> There is simple thing is compatibility table
215.773 -> On one side we're saying grant
218.413 -> and on other side we're saying request
221.153 -> As we know there are only 2 locks- Shared and exclusive
224.332 -> so how many case can form
225.653 -> 4 case, Shared - Shared
227.547 -> Shared- exclusive
228.607 -> Exclusive-Shared
229.927 -> Exclusive- exclusive
231.16 -> So same we are doing here
232.62 -> Let's say grant means
234.347 -> If on this side grant is there and on other side request
236.773 -> so lets say we already grant shared lock
240.492 -> Means concurrency control component
242.8 -> shared lock on A
244 -> I'm taking about A data item, not separately A, B, C
247.332 -> Lets say we're only taking about A data component
251.107 -> and I've given shared lock (A)
253.247 -> and if someone else also request that I also want shared lock(A)
257.407 -> means on same data item
258.773 -> and will be allowing the request
262.22 -> obviously yes
263.881 -> Reason I've just told you what we do in shared mode
266.852 -> Only Read is done
268.447 -> and there is never a conflict between read and read
271.132 -> No
271.713 -> As I've already told you
273.692 -> Conflict serializibity
276.567 -> all these conflict read, read, read, read, write
278.899 -> what are they that I already made videos about
281.467 -> Link of that I've mentioned in description box, do check it once
285.907 -> As there are many things in this that we had already discussed
288.732 -> and we're using it directly here
291.492 -> So there is no conflict in Read and Read
293.812 -> we're only checking data
295.467 -> So here you can grant
297.292 -> Let's say we already granted shared lock
300.813 -> and request came on exclusive lock
303.34 -> Means A needs exclusive lock
305.498 -> So will that be granted ? No we'll not what we'll do
309.527 -> We can no it, as I've written X here, so here I'm doing yes
314.17 -> and here I'll write no
316.092 -> No means that we won't grant it and reason is
319.473 -> Means if a transaction has taken shared lock let's say it R(A)
324.252 -> Read(A)
325.72 -> and second transaction is saying that I need exclusive lock
328.333 -> means what it want to do Read(A) and Write (A) both
331.852 -> and if we allow
333.607 -> here in future there can be Read(A) and Write(A) conflict
337.652 -> So to prevent that what we'll do is No
340.353 -> So next is
341.833 -> if we had already granted exclusive lock
345.052 -> already we granted exclusive lock (A)
348.147 -> and if someone ask for share lock, So will we give ?
351.053 -> No, same
352.24 -> Write and read, means we're already doing read and write
355.68 -> one transaction is already doing
357.547 -> and second one is saying that I've to read
359.573 -> so same Write, read problem so we won't allow
362.313 -> and on 4th case also we won't allow
365.207 -> Write- write problem, one is already doing Read-Write
368.167 -> and second one is saying that I want to perform same on Read-write on same item
372.667 -> so if we allow that
374.412 -> So again problem on inconsistency can come so to prevent what we'll do is no
379.332 -> So basically our Shared-exclusive locking protocol
383.5 -> It's main purpose is that we are trying to achieve serializabity
387.46 -> because of which we are trying to achieve consistency
391.48 -> if we achieve this so the acid property that we discussed earlier
395.172 -> In that C which is consistency
397.547 -> we are trying to achieve that
399.532 -> So this compatibility table is very important you should know this

Source: https://www.youtube.com/watch?v=94C0V7f2zm4