1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 ***************************************************************************/
19 #include<CatalogTables.h>
20 #include<Transaction.h>
24 Bucket
* LockManager::getLockBucket(void *tuple
)
26 int noOfBuckets
= LOCK_BUCKET_SIZE
;
27 Bucket
* buckets
= systemDatabase_
->getLockHashBuckets();
28 unsigned long key
=(unsigned long)tuple
;
29 int bucketNo
= HashIndex::computeHashBucket(typeULong
, &key
, noOfBuckets
);
31 Bucket
*bucket
= &(buckets
[bucketNo
]);
32 printDebug(DM_Lock
, "getLockBucket bucketno:%d bucket:%x",bucketNo
, bucket
);
36 void LockManager::printUsageStatistics()
38 Bucket
* buckets
= systemDatabase_
->getLockHashBuckets();
40 LockHashNode
*lockNode
;
41 int nodeCount
=0, bucketCount
=0;
42 for (int i
=0; i
< LOCK_BUCKET_SIZE
; i
++)
44 bucket
= &(buckets
[i
]);
45 lockNode
= (LockHashNode
*) bucket
->bucketList_
;
46 if (lockNode
) bucketCount
++; else continue;
47 while (NULL
!= lockNode
) { nodeCount
++; lockNode
= lockNode
->next_
; }
49 printf("<LockTable>\n");
50 printf(" <TotalBuckets> %d </TotalBuckets>\n", LOCK_BUCKET_SIZE
);
51 printf(" <UsedBuckets> %d </UsedBuckets>\n", bucketCount
);
52 printf(" <TotalLockNodes> %d </TotalLockNodes>\n", nodeCount
);
53 printf("</LockTable>\n");
57 void LockManager::printDebugInfo()
59 Bucket
* buckets
= systemDatabase_
->getLockHashBuckets();
61 LockHashNode
*lockNode
;
62 int nodeCount
=0, bucketCount
=0;
63 printf("<LockTable>\n");
64 for (int i
=0; i
< LOCK_BUCKET_SIZE
; i
++)
67 bucket
= &(buckets
[i
]);
68 //if (bucket) bucketCount++; else continue;
69 lockNode
= (LockHashNode
*) bucket
->bucketList_
;
71 while (NULL
!= lockNode
)
75 lockNode
= lockNode
->next_
;
79 printf(" <LockBucket> \n");
80 printf(" <BucketNo> %d </BucketNo> \n", i
);
81 printf(" <TotalNodes> %d </TotalNodes>\n", nodeCount
);
82 printf(" <LockBucket>\n");
86 printf(" <TotalUsedBuckets> %d </TotalUsedBuckets>\n", bucketCount
);
87 Chunk
*chunk
= systemDatabase_
->getSystemDatabaseChunk(LockTableId
);
88 printf(" <TotalPages> %d </TotalPages>\n", chunk
->totalPages());
89 printf("</LockTable>\n");
93 DbRetVal
LockManager::getSharedLock(void *tuple
, Transaction
**trans
)
96 //take the bucket mutex for read
97 //go the the next level bucket list
98 //get the bucket iterator
99 //go the node where the lock info resides
100 //check which mode the lock is taken
102 // upgrade the bucket mutex to write
103 // take it and increment the readers count
104 // release bucket mutex and exit
107 // upgrade the bucket mutex to write
108 // increment waitReaders count
109 // release the bucket mutex
110 // wait for timeout period or (takes shared lock and release it ) till it becomes free.
112 // take bucket mutex for write
113 // decrement waitReaders count
114 // releaese bucket mutex
117 // if it becomes free
118 // take bucket mutex for write
120 // releaese bucket mutex
124 linfo
.noOfReaders_
= 1;
125 //keeping it ready for the allocation, because when
126 //lock node is not present in the list, then it means we are the first
127 //to acquire lock so for sure we will get it.
128 printDebug(DM_Lock
, "LockManager::getSharedLock Begin");
129 Bucket
*bucket
= getLockBucket(tuple
);
130 int lockRet
= bucket
->mutex_
.getLock(systemDatabase_
->procSlot
);
133 printDebug(DM_Lock
, "LockManager::getSharedLock:End-Unable to get mutex");
134 printError(ErrLockTimeOut
,"Unable to acquire bucket mutex");
135 return ErrLockTimeOut
;
137 LockHashNode
*lockNode
= (LockHashNode
*) bucket
->bucketList_
;
138 if (NULL
== lockNode
)
141 LockHashNode
*node
= allocLockNode(linfo
, tuple
, &rv
);
144 printError(rv
, "Could not allocate Lock node");
147 printDebug(DM_Lock
, "Bucket list is null: Allocating new LockHashNode %x", node
);
148 bucket
->bucketList_
= (void*)node
; //make it as head
149 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
152 rv
= (*trans
)->insertIntoHasList(systemDatabase_
, node
);
153 if (rv
!=OK
) linfo
.noOfReaders_
--;
154 printDebug(DM_Lock
, "LockManager::getSharedLock End");
157 LockHashNode
*cachedLockNode
= NULL
;
159 LockHashNode
*iter
= lockNode
;
160 //Iterate though the list and find the element's lock info
163 if(iter
->ptrToTuple_
== tuple
)
165 if (iter
->lInfo_
.noOfReaders_
== -1)
168 iter
->lInfo_
.waitReaders_
++;
169 cachedLockNode
= iter
;
170 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
171 if (trans
!= NULL
) (*trans
)->updateWaitLock(iter
);
172 printDebug(DM_Lock
, "lock node:%x exclusive locked",iter
);
175 else if (iter
->lInfo_
.noOfReaders_
== 0)
177 if(iter
->lInfo_
.waitWriters_
>0)
179 iter
->lInfo_
.waitReaders_
++;
180 cachedLockNode
= iter
;
181 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
182 if (trans
!= NULL
) (*trans
)->updateWaitLock(iter
);
183 printDebug(DM_Lock
, "lock node:%x Writers waiting.",iter
);
188 iter
->lInfo_
.noOfReaders_
++;
189 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
192 rv
= (*trans
)->insertIntoHasList(systemDatabase_
, iter
);
193 if (rv
!= OK
) iter
->lInfo_
.noOfReaders_
--;
194 printDebug(DM_Lock
, "lock node:%x First to take shared lock",
196 printDebug(DM_Lock
, "LockManager::getSharedLock End");
201 iter
->lInfo_
.noOfReaders_
++;
202 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
205 rv
= (*trans
)->insertIntoHasList(systemDatabase_
, iter
);
206 if (rv
!= OK
) iter
->lInfo_
.noOfReaders_
--;
207 printDebug(DM_Lock
, "lock node:%x incr readers",iter
);
208 printDebug(DM_Lock
, "LockManager::getSharedLock End");
212 printDebug(DM_Lock
, "Finding the lock node. iter:%x",iter
);
215 if (NULL
== cachedLockNode
)
218 LockHashNode
*node
= allocLockNode(linfo
, tuple
, &rv
);
221 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
222 printError(rv
, "Could not allocate Lock node");
223 if (trans
!= NULL
) (*trans
)->removeWaitLock();
226 printDebug(DM_Lock
,"Not Found.Created new lock node:%x",node
);
227 LockHashNode
*it
= lockNode
;
228 while (NULL
!= it
->next_
) it
= it
->next_
;
230 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
233 rv
= (*trans
)->insertIntoHasList(systemDatabase_
, node
);
234 if (rv
!= OK
) linfo
.noOfReaders_
--;
235 if (trans
!= NULL
) (*trans
)->removeWaitLock();
236 printDebug(DM_Lock
, "LockManager::getSharedLock End");
239 //bucket->mutex_.releaseLock();
242 struct timeval timeout
;
243 timeout
.tv_sec
= Conf::config
.getLockSecs();
244 timeout
.tv_usec
= Conf::config
.getLockUSecs();
246 //printDebug(DM_Lock, "Trying to get mutex: for bucket %x\n", bucket);
247 while (tries
< Conf::config
.getLockRetries())
249 lockRet
= bucket
->mutex_
.getLock(systemDatabase_
->procSlot
);
252 printDebug(DM_Lock
, "Mutex is waiting for long time:May be deadlock");
253 printDebug(DM_Lock
, "LockManager::getSharedLock End");
254 printError(ErrLockTimeOut
, "Unable to get bucket mutex");
255 if (trans
!= NULL
) (*trans
)->removeWaitLock();
256 return ErrLockTimeOut
;
258 if (cachedLockNode
->lInfo_
.noOfReaders_
== 0)
260 //if there are waiters allow then to take the lock
261 if (cachedLockNode
->lInfo_
.waitWriters_
<0)
263 cachedLockNode
->lInfo_
.noOfReaders_
++;
264 cachedLockNode
->lInfo_
.waitReaders_
--;
265 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
268 rv
= (*trans
)->insertIntoHasList(systemDatabase_
, cachedLockNode
);
270 cachedLockNode
->lInfo_
.noOfReaders_
--;
271 cachedLockNode
->lInfo_
.waitReaders_
++;
272 if (trans
!= NULL
) (*trans
)->removeWaitLock();
275 if (trans
!= NULL
) (*trans
)->removeWaitLock();
276 printDebug(DM_Lock
, "LockManager::getSharedLock End");
279 } else if (cachedLockNode
->lInfo_
.noOfReaders_
== -1)
281 if (trans
!=NULL
&& (*trans
)->findInHasList(systemDatabase_
, cachedLockNode
))
283 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
284 if (trans
!= NULL
) (*trans
)->removeWaitLock();
285 printDebug(DM_Lock
, "LockManager::getSharedLock End");
290 cachedLockNode
->lInfo_
.noOfReaders_
++;
291 cachedLockNode
->lInfo_
.waitReaders_
--;
292 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
295 rv
= (*trans
)->insertIntoHasList(systemDatabase_
, cachedLockNode
);
297 cachedLockNode
->lInfo_
.noOfReaders_
--;
298 cachedLockNode
->lInfo_
.waitReaders_
++;
300 if (trans
!= NULL
) (*trans
)->removeWaitLock();
301 printDebug(DM_Lock
, "LockManager::getSharedLock End");
305 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
306 os::select(0, 0, 0, 0, &timeout
);
308 printDebug(DM_Lock
, "Trying to lock the lock node:%x iteration:%d",cachedLockNode
, tries
);
310 printDebug(DM_Lock
, "Mutex is waiting for long time:May be deadlock");
311 printDebug(DM_Lock
, "LockManager::getSharedLock End");
312 printError(ErrLockTimeOut
, "Unable to acquire lock for long time.Timed out");
313 if (trans
!= NULL
) (*trans
)->removeWaitLock();
314 return ErrLockTimeOut
;
318 DbRetVal
LockManager::getExclusiveLock(void *tuple
, Transaction
**trans
)
321 linfo
.noOfReaders_
= -1;
322 printDebug(DM_Lock
, "LockManager::getExclusiveLock Begin");
323 //keeping it ready for the allocation, because when
324 //lock node is not present in the list, then it means we are the first
325 //to acquire lock so for sure we will get it.
327 Bucket
*bucket
= getLockBucket(tuple
);
328 int lockRet
= bucket
->mutex_
.getLock(systemDatabase_
->procSlot
);
331 printDebug(DM_Lock
, "Unable to acquire bucket mutex:May be deadlock");
332 printError(ErrLockTimeOut
, "Unable to acquire bucket mutex");
333 return ErrLockTimeOut
;
335 LockHashNode
*lockNode
= (LockHashNode
*) bucket
->bucketList_
;
336 if (NULL
== lockNode
)
339 LockHashNode
*node
= allocLockNode(linfo
, tuple
, &rv
);
342 printError(rv
, "Could not allocate Lock node");
345 printDebug(DM_Lock
, "No head. So new lock node allocated:%x",node
);
346 bucket
->bucketList_
= (void*)node
; //make it as head
347 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
350 rv
= (*trans
)->insertIntoHasList(systemDatabase_
, node
);
351 if (rv
!=OK
) linfo
.noOfReaders_
= 0;
352 printDebug(DM_Lock
, "LockManager::getExclusiveLock End");
356 LockHashNode
*cachedLockNode
= NULL
;
358 LockHashNode
*iter
= lockNode
;
359 //Iterate though the list and find the element's lock info
362 if(iter
->ptrToTuple_
== tuple
)
364 if (iter
->lInfo_
.noOfReaders_
!= 0)
366 iter
->lInfo_
.waitWriters_
++;
367 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
368 if (trans
!= NULL
) (*trans
)->updateWaitLock(iter
);
369 cachedLockNode
= iter
;
370 printDebug(DM_Lock
, "Either some one has exclusive or shared lock:%x",iter
);
375 iter
->lInfo_
.noOfReaders_
= -1;
376 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
379 rv
= (*trans
)->insertIntoHasList(systemDatabase_
, iter
);
380 if (rv
!= OK
) iter
->lInfo_
.noOfReaders_
= 0;
381 printDebug(DM_Lock
, "LockManager::getExclusiveLock End");
385 printDebug(DM_Lock
, "Finding the lock node. iter:%x",iter
);
388 if (NULL
== cachedLockNode
)
391 LockHashNode
*node
= allocLockNode(linfo
, tuple
, &rv
);
394 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
395 if (trans
!= NULL
) (*trans
)->updateWaitLock(NULL
);
396 printError(rv
, "Could not allocate Lock node");
399 printDebug(DM_Lock
, "Not Found:Creating new lock node:%x",node
);
400 LockHashNode
*it
= lockNode
;
401 while (NULL
!= it
->next_
) it
= it
->next_
;
403 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
406 rv
= (*trans
)->insertIntoHasList(systemDatabase_
, node
);
407 if (rv
!= OK
) linfo
.noOfReaders_
= 0;
408 if (trans
!= NULL
) (*trans
)->removeWaitLock();
409 printDebug(DM_Lock
, "LockManager::getExclusiveLock End");
412 //bucket->mutex_.releaseLock();
415 struct timeval timeout
;
416 timeout
.tv_sec
= Conf::config
.getLockSecs();
417 timeout
.tv_usec
= Conf::config
.getLockUSecs();
419 while (tries
< Conf::config
.getLockRetries())
421 lockRet
= bucket
->mutex_
.getLock(systemDatabase_
->procSlot
);
424 printError(ErrLockTimeOut
, "Unable to get bucket mutex");
425 return ErrLockTimeOut
;
427 if (cachedLockNode
->lInfo_
.noOfReaders_
== 0)
429 cachedLockNode
->lInfo_
.noOfReaders_
= -1;
430 cachedLockNode
->lInfo_
.waitWriters_
--;
431 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
434 rv
= (*trans
)->insertIntoHasList(systemDatabase_
, cachedLockNode
);
435 if (trans
!= NULL
) (*trans
)->removeWaitLock();
436 printDebug(DM_Lock
, "LockManager::getExclusiveLock End");
438 }else if ( cachedLockNode
->lInfo_
.noOfReaders_
== 1)
440 if (trans
!=NULL
&& (*trans
)->findInHasList(systemDatabase_
, cachedLockNode
))
442 printDebug(DM_Lock
, "upgrading shared to exclusive lock:%x",
444 //upgrade it to exclusive lock
445 cachedLockNode
->lInfo_
.noOfReaders_
= -1;
446 cachedLockNode
->lInfo_
.waitWriters_
--;
447 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
448 if (trans
!= NULL
) (*trans
)->removeWaitLock();
449 printDebug(DM_Lock
, "LockManager::getExclusiveLock End");
452 if (trans
==NULL
&& ProcessManager::hasLockList
.exists(cachedLockNode
->ptrToTuple_
))
454 printDebug(DM_Lock
, "upgrading shared to exclusive lock:%x",
456 //upgrade it to exclusive lock
457 cachedLockNode
->lInfo_
.noOfReaders_
= -1;
458 cachedLockNode
->lInfo_
.waitWriters_
--;
459 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
460 if (trans
!= NULL
) (*trans
)->removeWaitLock();
461 printDebug(DM_Lock
, "LockManager::getExclusiveLock End");
464 }else if ( cachedLockNode
->lInfo_
.noOfReaders_
== -1)
466 if (trans
!=NULL
&& (*trans
)->findInHasList(systemDatabase_
, cachedLockNode
))
468 printDebug(DM_Lock
, "You already have exclusive lock:%x",
470 cachedLockNode
->lInfo_
.waitWriters_
--;
471 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
472 if (trans
!= NULL
) (*trans
)->removeWaitLock();
473 printDebug(DM_Lock
, "LockManager::getExclusiveLock End");
476 if (trans
==NULL
&& ProcessManager::hasLockList
.exists(cachedLockNode
->ptrToTuple_
))
478 printDebug(DM_Lock
, "You already have exclusive lock:%x",
480 cachedLockNode
->lInfo_
.waitWriters_
--;
481 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
482 if (trans
!= NULL
) (*trans
)->removeWaitLock();
483 printDebug(DM_Lock
, "LockManager::getExclusiveLock End");
487 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
488 os::select(0, 0, 0, 0, &timeout
);
490 printDebug(DM_Lock
, "Trying to lock the lock node:%x iteration:%d",cachedLockNode
, tries
);
492 printDebug(DM_Lock
, "LockManager::getExclusiveLock End");
493 if (trans
!= NULL
) (*trans
)->removeWaitLock();
494 printError(ErrLockTimeOut
, "Unable to acquire lock for long time.Timed out");
495 return ErrLockTimeOut
;
498 DbRetVal
LockManager::releaseLock(void *tuple
)
501 linfo
.noOfReaders_
= 0;
502 //keeping it ready for the allocation, because when
503 //lock node is not present in the list, then it means we are the first
504 //to acquire lock so for sure we will get it.
505 printDebug(DM_Lock
, "LockManager:releaseLock Start");
506 Bucket
*bucket
= getLockBucket(tuple
);
507 printDebug(DM_Lock
,"Bucket is %x", bucket
);
508 int lockRet
= bucket
->mutex_
.getLock(systemDatabase_
->procSlot
);
511 printDebug(DM_Lock
, "Mutex is waiting for long time:May be deadlock");
512 printDebug(DM_Lock
, "LockManager:releaseLock End");
513 printError(ErrLockTimeOut
, "Unable to get bucket mutex");
514 return ErrLockTimeOut
;
516 LockHashNode
*lockNode
= (LockHashNode
*) bucket
->bucketList_
;
517 if (NULL
== lockNode
)
519 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
520 printDebug(DM_Lock
, "LockManager:releaseLock End");
521 printError(ErrSysFatal
, "Lock Element Not found: Probable Data Corruption.\n");
525 LockHashNode
*iter
= lockNode
;
526 //Iterate though the list and find the element's lock info
529 if(iter
->ptrToTuple_
== tuple
)
532 if (iter
->lInfo_
.noOfReaders_
== -1)
534 iter
->lInfo_
.noOfReaders_
= 0;
535 if (iter
->lInfo_
.waitWriters_
== 0 || iter
->lInfo_
.waitReaders_
==0)
537 deallocLockNode(iter
, bucket
);
538 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
539 printDebug(DM_Lock
, "Releasing exclusive lock and dealloc node:%x",
541 printDebug(DM_Lock
, "LockManager:releaseLock End");
546 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
547 printDebug(DM_Lock
, "Releasing exclusive lock");
548 printDebug(DM_Lock
, "LockManager:releaseLock End");
552 else if (iter
->lInfo_
.noOfReaders_
== 1)
554 iter
->lInfo_
.noOfReaders_
= 0;
555 if (iter
->lInfo_
.waitWriters_
== 0 || iter
->lInfo_
.waitReaders_
==0)
557 deallocLockNode(iter
, bucket
);
558 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
559 printDebug(DM_Lock
, "Releasing read lock and dealloc node:%x",iter
);
560 printDebug(DM_Lock
, "LockManager:releaseLock End");
566 iter
->lInfo_
.noOfReaders_
--;
567 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
568 printDebug(DM_Lock
, "Decrementing read lock:%x",iter
);
569 printDebug(DM_Lock
, "LockManager:releaseLock End");
574 printDebug(DM_Lock
, "Finding the lock node. iter:%x",iter
);
577 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
578 printError(ErrSysFatal
, "Lock Element Not found: Probable Data Corruption");
582 DbRetVal
LockManager::isExclusiveLocked(void *tuple
, Transaction
**trans
, bool &status
)
584 Bucket
*bucket
= getLockBucket(tuple
);
585 printDebug(DM_Lock
,"Bucket is %x", bucket
);
586 int lockRet
= bucket
->mutex_
.getLock(systemDatabase_
->procSlot
);
589 printDebug(DM_Lock
, "Mutex is waiting for long time:May be deadlock");
590 printDebug(DM_Lock
, "LockManager:releaseLock End");
591 printError(ErrLockTimeOut
, "Unable to get bucket mutex");
592 return ErrLockTimeOut
;
594 LockHashNode
*lockNode
= (LockHashNode
*) bucket
->bucketList_
;
595 if (NULL
== lockNode
)
597 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
598 printDebug(DM_Lock
, "bucketList is empty. so data element not locked");
603 LockHashNode
*iter
= lockNode
;
604 //Iterate though the list and find the element's lock info
605 //Only exclusive locks are checked. shared locks are not considered for this
608 if(iter
->ptrToTuple_
== tuple
)
610 if (iter
->lInfo_
.noOfReaders_
== -1)
612 if (trans
!= NULL
&& (*trans
)->findInHasList(systemDatabase_
, iter
))
614 printDebug(DM_Lock
, "You already have exclusive Lock: %x", iter
);
619 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
623 printDebug(DM_Lock
, "Finding the lock node. iter:%x",iter
);
626 bucket
->mutex_
.releaseLock(systemDatabase_
->procSlot
);
631 LockHashNode
* LockManager::allocLockNode(LockInfo
&info
, void *tuple
, DbRetVal
*rv
)
634 Chunk
*chunk
= systemDatabase_
->getSystemDatabaseChunk(LockTableId
);
635 LockHashNode
*node
= (LockHashNode
*)chunk
->allocate(systemDatabase_
, rv
);
638 printError(*rv
, "Could not allocate Lock node");
641 node
->ptrToTuple_
= tuple
;
647 void LockManager::deallocLockNode(LockHashNode
*node
, Bucket
*bucket
)
649 Chunk
*chunk
= systemDatabase_
->getSystemDatabaseChunk(LockTableId
);
650 LockHashNode
*nodeList
= (LockHashNode
*) bucket
->bucketList_
;
651 LockHashNode
*iter
= nodeList
, *prev
= nodeList
;
652 if (NULL
== nodeList
)
654 printError(ErrSysFatal
, "Lock Bucket corrupted");
657 //If it is the first node, then make the bucket point to the next node
659 if (nodeList
== node
)
661 bucket
->bucketList_
= node
->next_
;
662 chunk
->free(systemDatabase_
, node
);
670 //delete the node by making previous element point to the next element
671 //of the deleted element in the list
672 prev
->next_
= iter
->next_
;
673 chunk
->free(systemDatabase_
, node
);