Abstract:On the basis of the study of SQLite and other concurrency control mechanisms in memory database, an adaptive concurrency control mechanism is proposed according to the operating environment of SQLite in intelligent mobile devices. The function and concrete flow of improved concurrency control are introduced and discussed. The data structure and the main functions of each part are analyzed. The function and performance of the improved concurrency control mechanism are tested. The results verify the correctness and validity of the adaptive concurrency control.
IntroductionIn recent years, concurrency control, as one of the performance indicators of memory, has also gained rapid development, from the traditional lock-based pessimistic control mechanism to the current multi-granularity model, from the original optimistic concurrency control mechanism to a variety of improved optimistic concurrency control Mechanism, which all contributes to the upgrade of the memory database concurrency and efficiency. But SQLite is progressing slowly in concurrency control, still using traditional locking-based concurrency protocols, database-level locking granularity becomes a shackle of concurrency and results in lower degrees of concurrency. Considering the shortcomings of the original concurrency control mechanism and the characteristics of its operating environment, combined with the advantages of other concurrency control mechanisms, the original mechanism can be improved and a new concurrency control mechanism can be designed to improve the concurrency and efficiency of SQLite database[1,2].
2.SQLite Concurrency Control 2.1 Lock Mechanism of SQLite. SQLite uses extensive database granularity locking, using a harsh two-stage blocking protocol. If a transaction applies for a lock, the lock is released only when the transaction completes, and the transaction cannot perform any conflicts with the lock until the lock is released. At the same time, all the blocking requests in each transaction precede all unlock requests, the two phases refer to the lock growth phase and the lock shrink phase, 1) the lock growth phase: before any data is read and written, the transaction first obtains the data of the blockade; 2) lock shrink phase: after the release of a blockade, the transaction no longer get any lock. The SQLite system manages a lock table that enables the transaction to be locked at the last minute to ensure maximum concurrency and efficiency [3,4].SQLite contains 5 different lock states: unlocked state, shared state, hold status, pending state, and exclusive status, each transaction can only be in one of the states at the same time. In addition to the unlocked state, each state has a lock corresponding to it: 1) shared locks; 2) reserved locks; 3) pending locks; 4) exclusive locks,. A file can only have an exclusive lock, any other lock and exclusive lock cannot coexist.2.2 Analysis of Lock Mechanism. At present, SQLite is widely used in intelligent mobile devices, in such an environment, the database concurrency is l...