Berkeley DB Reference Guide:
Locking Subsystem

PrevRefNext

Locking without transactions

If an application runs with locking specified, but not transactions (for example, DB_ENV->open is called with DB_INIT_LOCK or DB_INIT_CDB specified, but not DB_INIT_TXN), locks are normally acquired during each Berkeley DB operation and released before the operation returns to the caller. The only exception is in the case of cursor operations. Cursors identify a particular position in a file. For this reason, cursors must retain read locks across cursor calls to make sure that the position is uniquely identifiable during a subsequent cursor call, and so that an operation using DB_CURRENT will always refer to the same record as a previous cursor call. These cursor locks cannot be released until the cursor is either repositioned and a new cursor lock established (for example, using the DB_NEXT or DB_SET flags), or the cursor is closed. As a result, application writers are encouraged to close cursors as soon as possible.

(¸¸¾à ¾ÖÇø®ÄÉÀ̼ǿ¡ ¶ô¼³Á¤ÀÌ ÀÖ°í Æ®·¢Á§¼ÇÀÌ ¾øÀ»¶§( DB_ENV->open ÀÌ DB_INIT_TXN¾øÀÌ DB_INIT_LOCK or DB_INIT_CDB·Î ¼³Á¤µÇ¾î È£Ã⶧ ),¶ôÀº º¸Åë ¹öŬ¸®µðºñ ¿ÀÆÛ·¹À̼ÇÁß¿¡ ¾ò¾îÁö°í È£ÃâÀÚ¿¡°Ô ¸®ÅϵDZâ Àü¿¡ ³õ¿©Áø´Ù.ÀÌ°æ¿ì À¯ÀÏÇÑ ¿¹¿Ü´Â Ä¿¼­¿ÀÆÛ·¹À̼ÇÀÇ °æ¿ì´Ù.Ä¿¼­´Â ÆÄÀÏÀÇ Æ¯Á¤ÇÑ À§Ä¡¸¦ ÀνÄÇÑ´Ù.ÀÌ¿Í°°Àº ÀÌÀ¯·Î Ä¿¼­´Â  Ä¿¼­ÄÝÁß¿¡ Æ÷Áö¼ÇÀÌ À¯ÀϼºÀÖ°Ô ½Äº°µÇ¾î¾ß ÇÏ°í ÀÌ°ÍÀ» ÅëÇØ DB_CURRENT¸¦ »ç¿ëÇÏ´Â ¿ÀÆÛ·¹À̼ÇÀº Ç×»ó ÀÌÀüÀÇ Ä¿¼­Äݶ§¿Í °°Àº ·¹Äڵ带 ÂüÁ¶ÇØ¾ß µÇ±â¶§¹®¿¡ Ä¿¼­ÄÝ»çÀÌ¿¡¼­ Àбâ¶ôÀÌ °É·Á¾ß ÇÑ´Ù.ÀÌ Ä¿¼­¶ôÀº Ä¿¼­ÀÇ ¸®Æ÷Áö¼Å´×, »õ·Î¿îÄ¿¼­¶ôÀÌ ¼º¸³(DB_NEXT or DB_SET flags)ÁßÀÇ ÇÑ°¡Áö°¡ ¼³Á¤µÇ°Å³ª Ä¿¼­¸¦ ´Ý±â Àü±îÁö´Â ¸±¸®ÁîµÇÁö ¾Ê´Â´Ù.°á°úÀûÀ¸·Î ¾ÖÇø®ÄÉÀ̼ÇÀº Ä¿¼­¸¦ °¡´ÉÇÑ »¡¸® ´Ý¾Æ¾ß ÇÑ´Ù.

It is important to realize that concurrent applications that use locking must ensure that two concurrent threads do not block each other. However, because Btree and Hash access method page splits can occur at any time, there is virtually no way to guarantee that an application that writes the database cannot deadlock. Applications running without the protection of transactions may deadlock, and can leave the database in an inconsistent state when they do so. Applications that need concurrent access, but not transactions, are more safely implemented using the Berkeley DB Concurrent Data Store Product.

(¶ôÀ» »ç¿ëÇÏ´Â µ¿½Ã¼ºÀÖ´Â ¾ÖÇø®ÄÉÀ̼ÇÀº ¹Ýµå½Ã µÎ°³ÀÇ ¾²·¡µå°¡ ¼­·Î¸¦ ºí¶ô½ÃÅ°Áö ¾Êµµ·Ï Çϴ°ÍÀÌ Áß¿äÇÏ´Ù.±×·¯³ª Btree ¿Í Hash¿¢¼¼½º ¸Þ¼Òµå ÆäÀÌÁö ºÐÇÒÀº ¾î¶°ÇÑ ¼ø°£¿¡µµ ÀϾ ¼ö Àֱ⠶§¹®¿¡ °¡»óÀûÀ¸·Î µ¥µå¶ôÀ» ¹þ¾î³¯¼ö ÀÖ´Â ¹æ¹ýÀº ¾ø´Ù.Æ®·£Á§¼ÇÀÇ º¸È£¾øÀÌ µ¿ÀÛÇÏ´Â ¾ÖÇø®ÄÉÀ̼ÇÀº µ¥µå¶ô µÉ ¼ö ÀÖ´Ù.±×¸®°í µ¥µå¶ôÀÌ °É¸®¸é ºÒÀÏÄ¡»óÅ·Πµðºñ¸¦ ¶°³¯¼ö ÀÖ´Ù. Æ®·£Á§¼Ç¾÷½Ì µ¿½ÃÁ¢±ÙÀ» ¿øÇÏ´Â ¾ÖÇø®ÄÉÀ̼ÇÀº Berkeley DB Concurrent Data Store Product¸¦ »ç¿ëÇÏ¿© Á»´õ ¾ÈÁ¤¼ºÀÖ°Ô ±¸ÇöµÈ´Ù.)


PrevRefNext

Copyright (c) 1996-2003 Sleepycat Software, Inc. - All rights reserved.