`
hillmover
  • 浏览: 34666 次
  • 性别: Icon_minigender_2
  • 来自: 上海
社区版块
存档分类
最新评论

Concurrent Access and Locking

阅读更多

1. A proper locking mechanism is necessary to ensure data consistency when there is a possibility of multiple clients accessing and possibly modifying the same data at the same time.
2. table-level locks, page-level locks, and row-level locks
3. MyISAM and MEMORY storage engines can only work with table-level locks. InnoDB supports row-level locks, and Berkeley DB supports page-level locks.
4. MyISAM - If the insert operation results in writing the record at the end of the datafile, reading can be done without a lock.
5. InnoDB Locking
There are two types of row-level locks: shared and exclusive.
InnoDB also uses so-called intension locks on a table. There are also two types of intension table locks, shared and exclusive.
Rocord locking
What InnoDB actually locks is the index entry, the space before it, and the space after the last record. This method is called next-key locking.
The next-key locking is necessary to avoid the phantom row problem in transactions. If we did not lock the space before the record, it would be possible for another transaction to insert another record in between. Thus, if we were to run the same query again, we would see the record that was not there the first time we ran the query. This would make it impossible to meet the requirement of the serializable read transaction isolation level.
InnoDB has an automatic deadlock detection lagorithm. It will usually roll back the last transaction involed in a deadlock.  Additionally, some transactions may be considered to be in a virtual deadlock. For example, if a query is written is such a way that it examines several billion records, it may not release its locks for weeks, although from a theoretical point of view it eventually will. For such situations InnoDB uses a lock timeout, which is controlled by the configuration variable innodb_lock_wait_timeout.

 Accessing records always in the same index order, writing properly optimized queries, and commiting transactions frequently are some of techniques that help prevent potential deadlocks.

分享到:
评论

相关推荐

    Oracle Database Transactions and Locking Revealed(Apress,2014).

    Transaction design in turn relies upon a good understanding of how the underlying database platform manages of the locking of resources so as to prevent access conflicts and data loss that might ...

    微软内部资料-SQL性能优化3

     Discuss lock compatibility and concurrent access.  Identify different types of lock resources.  Discuss dynamic locking and lock escalation.  Differentiate locks, latches, and other SQL ...

    multiprocessor_Synchronization_lecture19_0520.pdf

    接下来是“Concurrent threads need to coordinate”和“Shared data and other shared resources, e.g. devices”等内容。这意味着为了保证系统中多个并发执行的线程能够有序地工作,必须要有协调机制来管理对共享...

    UNIX Network Programming Volume 1, Third Edition (Unix网络编程卷1第3版英文版)

    TCP Port Numbers and Concurrent Servers Section 2.11. Buffer Sizes and Limitations Section 2.12. Standard Internet Services Section 2.13. Protocol Usage by Common Internet Applications ...

    Absolute Database for D7

    threaded applications Multi-User Zero-admin file-server Automatic record and table locking Automatic detection of changes made by other users Configurable limit of concurrent connections Easy ...

    H7 HAL驱动概要DM00392525_ENV2.pdf

    • Object locking mechanism: safe hardware access to prevent multiple spurious accesses to shared resources. • Timeout used for all blocking processes: the timeout can be a simple counter or a time...

    acpi控制笔记本风扇转速

    concurrent control method execution. An additional namespace race condition is known to exist between AcpiWalkNamespace and the Load/Unload ASL operators and is still under investigation. ...

    版本控制插件cvs

    CVS(Concurrent Versions System),即并发版本系统,是一种广泛使用的开源版本控制系统,尤其在软件开发领域中扮演着重要角色。它允许开发者在一个团队中协同工作,对代码进行修改、跟踪和管理,确保所有人的工作...

    MySQL 5.6 Reference Manual

    Table of Contents Preface, Notes, Licenses . . . . . . . . ....1. Licenses for Third-Party Components ....1.1. FindGTest.cmake License ....1.2. LPeg Library License ....1.3. LuaFileSystem Library License ....

Global site tag (gtag.js) - Google Analytics