CN101615203A - Concurrency control method and device - Google Patents

Concurrency control method and device Download PDF

Info

Publication number
CN101615203A
CN101615203A CN200910160804A CN200910160804A CN101615203A CN 101615203 A CN101615203 A CN 101615203A CN 200910160804 A CN200910160804 A CN 200910160804A CN 200910160804 A CN200910160804 A CN 200910160804A CN 101615203 A CN101615203 A CN 101615203A
Authority
CN
China
Prior art keywords
lock
affairs
granted
control method
described affairs
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN200910160804A
Other languages
Chinese (zh)
Other versions
CN101615203B (en
Inventor
印和平
常二鹏
卢勤元
丁奇鹏
陈河堆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZTE Corp
Original Assignee
ZTE Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ZTE Corp filed Critical ZTE Corp
Priority to CN2009101608047A priority Critical patent/CN101615203B/en
Priority to PCT/CN2009/076082 priority patent/WO2011009274A1/en
Publication of CN101615203A publication Critical patent/CN101615203A/en
Application granted granted Critical
Publication of CN101615203B publication Critical patent/CN101615203B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/526Mutual exclusion algorithms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2308Concurrency control
    • G06F16/2336Pessimistic concurrency control approaches, e.g. locking or multiple versions without time stamps
    • G06F16/2343Locking methods, e.g. distributed locking or locking implementation details

Abstract

The invention provides a kind of concurrency control method, may further comprise the steps: judge according to the lock relation table whether the operating position for the treatment of of affairs has and the phase-locked lock that conflicts to be granted, the relation that the lock relation table is used to preserve affairs and lock; To the affairs granted lock, and carry out affairs according to judged result; When affairs are carried out end, discharge the lock that affairs are held, and the lock that need not in the lock that will discharge to continue to wait for is authorized other concurrent transactions.The present invention also provides a kind of concurrent control device, comprising: judge module; Execution module; Release module.It is lower to the concurrency of affairs control that the present invention has overcome the concurrency control method in the correlation technique, the problem that system performance is relatively poor, and then improved the concurrency of affairs controls, improved concurrent control effect.

Description

Concurrency control method and device
Technical field
The present invention relates to database field, in particular to a kind of concurrency control method and device.
Background technology
Database is a shared resource, and may there be the affairs of a plurality of concurrent execution in synchronization in Database Systems.When a plurality of user concurrents ground carries out accessing operation to database, will cause the situation of the same database of a plurality of affairs access simultaneously.May there be following three kinds of conflicts such as affairs T1, T2 when the concurrent execution:
1) WR (Write/Read writes-read) conflict, promptly T2 reads in the data of just being revised by T1 and not submitting to as yet, and what T2 read in like this is dirty data, is also referred to as " dirty reading ";
2) RW (Read/Write reads-write) conflict, promptly T2 revises the data and the T1 end as yet of just having been read in by T1, and T1 is if read in same target once more like this, and then its value can change, and is also referred to as " non-repeatable read ";
3) WW (Write/Write writes-write) conflict, promptly T2 overrides value and the T1 end of just having been revised by T1 as yet, can cause the inconsistency of data like this.
Serial scheduling can guarantee the consistance of data, but is unfavorable for system performance, so DBMS (Database Management System, data base management system (DBMS)) must provide the transaction concurrency controlling mechanism.Serializability is the criterion of concurrent transaction correctness, thus a given concurrent control, and if only if it when being serializability, be only correct control.
Strict 2PL (Strict 2-Phase Locking, strict two-stage lock) agreement has guaranteed the serializability of concurrent control, and its content is: 1) before the object of read/write data storehouse, must add the read/write lock earlier; 2) affairs execute (submitting to or rollback), discharge the lock that it has again.
A kind of concurrency control method is provided in the correlation technique, and this method is by locking to operated data-base recording, and allows other concurrent transactions wait in line, and prevents that this record is simultaneously by other transactions modify.
The inventor finds that other concurrent transactions that the concurrency control method in the correlation technique makes all requests operate same data-base recording all enter waiting list, after being finished to lock release by last lock-based transaction execution, other concurrent transactions just are able to database be operated again, cause the concurrency of affairs control lower, concurrent control effect is relatively poor.
Summary of the invention
The present invention aims to provide a kind of concurrency control method and device, can solve other concurrent transactions that concurrency control method in the correlation technique makes all requests operate same data-base recording and all enter waiting list, after being finished to lock release by last lock-based transaction execution, other concurrent transactions just are able to database be operated again, cause the concurrency of affairs control lower, the problem that system performance is relatively poor.
In an embodiment of the present invention, provide a kind of concurrency control method, may further comprise the steps: judged according to the lock relation table whether the operating position for the treatment of of affairs has and the phase-locked lock that conflicts to be granted, the relation that the lock relation table is used to preserve affairs and lock; To the affairs granted lock, and carry out affairs according to judged result; When affairs are carried out end, discharge the lock that affairs are held, and the lock that need not in the lock that will discharge to continue to wait for is authorized other concurrent transactions.
Preferably, in above-mentioned concurrency control method, the lock relation table specifically comprises: transaction list is used to the affairs of preserving concurrent execution and not submitting to; The lock Hash table is used to follow the tracks of the lock of waiting in line; The chain table is used for association affairs and lock.
Preferably, in above-mentioned concurrency control method,, and carry out affairs and specifically comprise the affairs granted lock according to judged result:,, and carry out affairs the affairs granted lock if the operating position for the treatment of of affairs does not have lock.
Preferably, in above-mentioned concurrency control method, to the affairs granted lock, and carry out affairs and specifically comprise according to judged result: if affairs treat the existing lock of operating position, checking whether existing lock exists with lock to be granted conflicts; To the affairs granted lock, and carry out affairs according to check result.
Preferably, in above-mentioned concurrency control method, to the affairs granted lock, and carry out affairs and specifically comprise according to check result: if not existing with lock to be granted, existing lock do not conflict, to the affairs granted lock, and the execution affairs.
Preferably, in above-mentioned concurrency control method,, and carry out affairs and specifically comprise the affairs granted lock according to check result:, transaction queue's wait is set, until regaining lock to be granted if existing lock conflicts with to be granted being latched in; Carry out affairs.
Preferably, in above-mentioned concurrency control method, carry out affairs comprise following one of at least: increase operation, carry out deletion action, the operation of making amendment, carry out read operation.
Preferably, in above-mentioned concurrency control method, affairs are carried out and finished to comprise: affairs are finished submission or affairs are finished rollback.
Preferably, in above-mentioned concurrency control method, authorize other concurrent transactions with the lock that need not in the lock that discharges to continue to wait for and specifically comprise:, detect whether the sign of wait is arranged each lock in the lock place chain table that discharges; As waiting for sign, and when there is not the lock type comflict in other locks on the same operating position of detected lock and other concurrent transactions, authorize other concurrent transactions with detected lock, wake other concurrent transactions up and continue to carry out, the lock type comprises shared lock and exclusive lock.
In an embodiment of the present invention, also provide a kind of concurrent control device, having comprised: judge module is used for judging according to the lock relation table whether the operating position for the treatment of of affairs has and the phase-locked lock that conflicts to be granted the relation that the lock relation table is used to preserve affairs and lock; Execution module is used for according to judged result the affairs granted lock, and carries out affairs; Release module is used for discharge the lock that affairs are held, and the lock that need not in the lock that will discharge to continue to wait for being authorized other concurrent transactions when affairs are carried out end.
Preferably, in above-mentioned concurrent control device, the lock relation table specifically comprises: transaction list is used to the affairs of preserving concurrent execution and not submitting to; The lock Hash table is used to follow the tracks of the lock of waiting in line; The chain table is used for association affairs and lock.
The foregoing description is because the relation that adopts the lock relation table to preserve its corresponding lock of affairs, so can lock the judgement that whether has conflict to pointing to the same difference of operating position for the treatment of, and carry out differentiated treatment according to judged result, in a single day rather than treat the concurrency control method that in correlation technique operative position is equipped with lock and just all lists the corresponding affairs of every other lock in waiting list, so it is lower to the concurrency of affairs control to have overcome the concurrency control method in the correlation technique, the problem that system performance is relatively poor, and then improved the concurrency of affairs controls, improved concurrent control effect.
Description of drawings
Accompanying drawing described herein is used to provide further understanding of the present invention, constitutes the application's a part, and illustrative examples of the present invention and explanation thereof are used to explain the present invention, do not constitute improper qualification of the present invention.In the accompanying drawings:
Fig. 1 shows the process flow diagram according to the concurrency control method of first embodiment of the invention;
Fig. 2 shows the synoptic diagram of the lock Hash table that concurrency control method adopts among Fig. 1;
Fig. 3 shows the process flow diagram according to the concurrency control method of second embodiment of the invention;
Fig. 4 shows the structural drawing according to the concurrent control device of third embodiment of the invention.
Embodiment
Below with reference to the accompanying drawings and in conjunction with the embodiments, describe the present invention in detail.
Fig. 1 shows the process flow diagram according to the concurrency control method of first embodiment of the invention, and this method may further comprise the steps:
Step S101 judges according to the lock relation table whether the operating position for the treatment of of affairs has and the phase-locked lock that conflicts to be granted, the relation that the lock relation table is used to preserve affairs and lock;
Step S102 to the affairs granted lock, and carries out affairs according to judged result;
Step S103 when affairs are carried out end, discharge the lock that affairs are held, and the lock that need not in the lock that will discharge to continue to wait for is authorized other concurrent transactions.
Present embodiment at first judges according to the lock relation table whether the operating position for the treatment of of affairs has and the phase-locked lock that conflicts to be granted, then according to judged result to the affairs granted lock, and execution affairs, at last when affairs are carried out end, discharge the lock that affairs are held, and the lock that need not in the lock that will discharge to continue to wait for is authorized other concurrent transactions, because the relation that has adopted the lock relation table to preserve its corresponding lock of affairs, so can lock the judgement that whether has conflict to pointing to the same difference of operating position for the treatment of, and carry out differentiated treatment according to judged result, in a single day rather than treat the concurrency control method that in correlation technique operative position is equipped with lock and just all lists the corresponding affairs of every other lock in waiting list, so it is lower to the concurrency of affairs control to have overcome the concurrency control method in the correlation technique, the problem that system performance is relatively poor, and then improved the concurrency of affairs controls, improved concurrent control effect.
Preferably, in above-mentioned concurrency control method, the lock relation table specifically comprises: transaction list is used to the affairs of preserving concurrent execution and not submitting to; The lock Hash table is used to follow the tracks of the lock of waiting in line; The chain table is used for association affairs and lock.
Lock relation table in the present embodiment specifically comprises transaction list, lock Hash table and chain table, the concurrency control method that is arranged so that present embodiment of above-mentioned table can effectively be managed affairs and lock, comprise index location, traversal search etc. apace, and then realized locking the judgement that whether has conflict to pointing to the same difference of operating position for the treatment of, for providing, above-mentioned concurrency control method provides powerful support for.
Transaction list is preserved the current affairs transaction information of other affairs of concurrent execution in the system when carrying out, the principle that is inserted into team's head according to the late comer is inserted, the pointer of node, the meter pointer of chain table etc. before and after transaction information specifically comprises in affairs ID, transaction types, the sensing transaction list.Affairs of each startup all can be inserted into these affairs in the transaction list, promptly the transaction information of these affairs can be saved in the transaction list.Comprise a thread structure information in the transaction structure, wherein comprised event object, when affairs because of waiting for the lock hanging time-out, carry out this event object of thread waits of affairs; When the affairs granted lock thereby when being waken up, the thread of granted lock is provided with this event object.
Fig. 2 shows the synoptic diagram of the lock Hash table that concurrency control method adopts among Fig. 1, as shown in Figure 2, each list item of lock Hash table is corresponding to the gauge outfit of a chain table, do like this, make that with the file space of writing down in the lock construction number and page number be that key calculates cryptographic hash, can navigate to corresponding chain table by corresponding lock Hash table list item.
The chain table is used for the affairs of association affairs tabulation record and locks the lock that writes down in the Hash table, as shown in Figure 2, each chain table comprises a plurality of lock constructions, each lock construction has write down information such as the file space number, page number, lock-bit figure, the shared bit of lock-bit figure (bit) number, lock type (shared lock, exclusive lock), lock sign (wait for, authorize), affiliated affairs of the data-base recording of the lock locking of waiting in line, and wherein the heap_no position of lock-bit figure is a sign for the treatment of the operating position record.Each affairs is corresponding to a chain table, lock of the every application of affairs, and all chain is gone in corresponding chain table, and this chain table is preserved the lock that these affairs are held, and every pair of record is operated, and just can lock accordingly and insert in the corresponding chain table of these affairs.A lock construction can be shared with other lock of the same type on one page, the lock that on other record, adds same type if desired, only need in the chain table, to search to have or not similar lock, if find then with the position, corresponding heap_no position of lock-bit figure, adopt single linked list promptly to solve hash collision like this, and saved memory headroom effectively.
Preferably, in above-mentioned concurrency control method, step S102 specifically comprises: if the operating position for the treatment of that thing 0 is engaged in does not have lock, to the affairs granted lock, and carry out affairs.
If the operating position for the treatment of of affairs does not have lock,, and carry out respective transaction in the present embodiment then to these affairs granted lock.Do like this, make data-base recording to be operated when not having other transaction operations, accept the operation of these affairs, under the prerequisite that guarantees concurrent control correctness, improved the concurrency of control.
Preferably, in above-mentioned concurrency control method, step S102 specifically comprises: if the operating position for the treatment of of affairs has lock, whether the existing lock of inspection exists with lock to be granted is conflicted; To the affairs granted lock, and carry out affairs according to check result.
In the present embodiment if affairs treat the existing lock of operating position, need continue then to check whether existing lock exists with lock to be granted conflicts, this conflict comprises: WR conflict, RW conflict and WW are outstanding, and then according to check result to the affairs granted lock, and execution affairs.Do like this, can and not exist two kinds of different situations of conflict to carry out differentiated treatment to the existence conflict, rather than after judgement obtains existing the lock, just every other affairs are hung up and waited for, improved the concurrency of control.
Preferably, in above-mentioned concurrency control method, to the affairs granted lock, and carry out affairs and specifically comprise according to check result: if not existing with lock to be granted, existing lock do not conflict, to the affairs granted lock, and the execution affairs.
Though the operating position for the treatment of of affairs has lock in the present embodiment, check result is not conflicted for existing lock does not exist with lock to be granted, at this moment, and still to the affairs granted lock, and the execution affairs.Present embodiment has been caught the execution opportunity of concurrent transaction under situation about being independent of each other, and makes the available resources maximization, and the concurrency control method of comparing in the correlation technique has improved the concurrency of control effectively.
Preferably, in above-mentioned concurrency control method,, and carry out affairs and specifically comprise the affairs granted lock according to check result:, transaction queue's wait is set, until regaining lock to be granted if existing lock conflicts with to be granted being latched in; Carry out affairs.
In the present embodiment if affairs treat the existing lock of operating position, and existing lock conflicts with to be granted being latched in, and these affairs then is set hangs up and insert waiting list and wait in line, until regaining lock to be granted, and the execution affairs.Do like this, make affairs to satisfy simultaneously and treat the existing lock of operating position and have lock just can hang up wait with to be granted being latched under the condition of conflicting, be that affairs only can be subjected to just waiting for when other concurrent transactions influence definite, under the prerequisite that guarantees concurrent control correctness, improved the concurrency of control.
Preferably, in above-mentioned concurrency control method, carry out affairs comprise following one of at least: increase that (insert is also referred to as insertion) operated, carried out deletion action, the operation of making amendment, carry out read operation.
Carrying out affairs in the present embodiment can be for increasing, deletes, revise, read, or its combination.The concurrency control method of present embodiment is not limited to a certain operation, but may extend to above-mentioned four kinds of basic operations, and perhaps range of application has been expanded in its combination.
Fig. 3 shows the process flow diagram according to the concurrency control method of second embodiment of the invention, is operating as the example explanation with insertion in the present embodiment, and this method may further comprise the steps:
Step S301, watcher thread receives SQL (Structured Query Language, Structured Query Language (SQL)) statement query requests, and distributes a worker thread to handle query requests;
Step S302, worker thread is carried out SQL query analysis and SQL query optimization, generates executive plan;
Step S303, worker thread adds the purpose exclusive lock to the latching operation table, shows that soon his-and-hers watches are carried out write operation;
Step S304, worker thread navigates to the record that article one satisfies X<=tuple from being inserted into data recording structure index entry tuple (tuple), navigates to the page or leaf that is inserted into record fast in order to index of reference;
Step S305 judges the Field Count of whether having built unique index and vernier coupling on the table more than or equal to the unique key Field Count, if less than, forward step S314 to;
Step S306 from being inserted into data recording structure index entry tuple (tuple), navigates to the record that article one satisfies X>=tuple, and X is an index record;
Step S307, whether if maximum transaction ID is more than or equal to minimum affairs ID in the current active affairs on the page, then checking has the implicit expression lock, if having, forward step S309 in the current record;
Step S308, this inserts operation and waits in line;
Step S309 obtains the gathering index record of current index record correspondence, if this record is just to insert, then has implicit expression to lock on this record, this implicit expression is locked be converted to explicit lock;
Step S310 judges whether X=tuple sets up, and X=tuple represents to exist the unique key conflict, and also the unique key constraint is violated in expression, if be false, forwards step S312 to;
Step S311, newspaper repeat key mistake forwards step S305 to;
Step S312, shared lock documentarily;
Step S313 is repositioned onto the record that article one satisfies X<=tuple, and X is an index record;
Step S314, next bar of checking current record writes down whether there is lock, be that key calculates cryptographic hash promptly with record file space, place number and page number, navigate to certain list item on the lock Hash table, traversal is the chain table of gauge outfit with this list item, checks among the lock-bit figure of each lock the whether set of heap_no position, if the heap_no position is not set among the lock-bit figure, promptly there is not lock on this record, forwards step S316 to;
Step S315 if the heap_no position is set among the lock-bit figure, represents that then upward there is lock in this record, continues to judge whether to exist lock conflict, if there is lock conflict, forwards step S308 to;
Step S316, application locks successfully, inserts data, has prevented this record of other transactions modify;
Step S317 has lock if insert on next bar record that writes down, and then inherits the lock on next bar record, simultaneously waiting status is changed to the state of authorizing;
Step S318, affairs carry out to finish, and promptly affairs are finished and are submitted to or affairs are finished rollback, discharge the lock of holding, scanning lock Hash table lock formation simultaneously, authorizing no longer needs the lock waited for.
Present embodiment is applied in the Database Systems, such as the Database Systems of IPTV electronic program list.Because the number of users that each electronic program system can hold is limited, therefore a cover IPTV system need dispose a lot of electronic program lists.A commercial data base is all moved on each electronic program list backstage in the correlation technique, cause cost higher, and present embodiment adopts above-mentioned concurrency control method near the commercial data base performance, reduced cost, satisfied the demand of IPTV system preferably, possess the standard database characteristic simultaneously, these characteristics comprise transactional integrity, transaction concurrency control, fault recovery etc.Present embodiment has been controlled the transaction concurrency execution effectively, has guaranteed system performance simultaneously to the full extent.
Preferably, in above-mentioned concurrency control method, affairs are carried out and finished to comprise: affairs are finished submission or affairs are finished rollback.
Affairs carry out to finish to comprise that affairs are finished submits to or affairs are finished rollback in the present embodiment, promptly when affairs are finished submission or affairs and finished rollback, discharge the lock that these affairs are held.Be released at once when lock is finished the locking task in the present embodiment, be convenient to other concurrent transactions and obtain corresponding lock, the chance to obtain to be performed helps to improve the concurrency of control.
Preferably, in above-mentioned concurrency control method, the lockset body that the release affairs are held comprises each lock in the lock place chain table that discharges, and it is deleted from this chain table, deletes from the lock Hash table of correspondence simultaneously.
Carry out end when affairs in the present embodiment, when promptly these affairs are finished submission or finished rollback, the lock that these affairs are held is deleted from the chain table of this affairs correspondence, also from the lock Hash table of correspondence, delete simultaneously.Present embodiment adopts will lock from corresponding chain table and lock Hash table deletes the release that realizes lock, operation is simple, and make and after locking the locking task of finishing certain affairs, be released at once, be convenient to other concurrent transactions and obtain corresponding lock, chance to obtain to be performed helps to improve the concurrency of control.
Preferably, in above-mentioned concurrency control method, authorize other concurrent transactions with the lock that need not in the lock that discharges to continue to wait for and specifically comprise:, detect whether the sign of wait is arranged each lock in the lock place chain table that discharges; As waiting for sign, and when there is not the lock type comflict in other locks on the same operating position of detected lock and other concurrent transactions, authorize other concurrent transactions with detected lock, wake other concurrent transactions up and continue to carry out, the lock type comprises shared lock and exclusive lock.
Present embodiment detects at first whether the sign of wait is arranged in the lock type that is released lock, if the sign of wait is arranged, show that then lock is in waiting status, be that key calculates cryptographic hash with the file space, record place of the lock of waiting status locking number and page number then, navigate to the gauge outfit of corresponding chain table on the lock Hash table, scanning lock place chained list, whether there is other lock to have the lock type comflict with it to each lock inspection in the chained list, if there is the lock type comflict, then detected lock need wait for that existing the lock of locking type comflict to be released with it just might obtain to authorize chance; If there is not the lock type comflict, then detected lock need not to wait for, authorizes other concurrent transactions with detected lock, the wait sign of this lock of resetting, be about to this lock and change the state of authorizing into, and wake other concurrent transactions continuation execution of detected lock correspondence up by waiting status.
Fig. 4 shows the structural drawing according to the concurrent control device of third embodiment of the invention, and this device comprises:
Judge module 10 is used for judging according to the lock relation table whether the operating position for the treatment of of affairs has and the phase-locked lock that conflicts to be granted the relation that the lock relation table is used to preserve affairs and lock;
Execution module 20 is used for according to judged result the affairs granted lock, and carries out affairs;
Release module 30 is used for discharge the lock that affairs are held, and the lock that need not in the lock that will discharge to continue to wait for being authorized other concurrent transactions when affairs are carried out end.
Present embodiment at first adopts judge module 10 to judge according to the lock relation table whether the operating position for the treatment of of affairs has and the phase-locked lock that conflicts to be granted, adopt then execution module 20 according to judged result to the affairs granted lock, and execution affairs, adopt release module 30 at last when affairs are carried out end, discharge the lock that affairs are held, and the lock that need not in the lock that will discharge to continue to wait for is authorized other concurrent transactions, because the relation that has adopted the lock relation table to preserve its corresponding lock of affairs, so can lock the judgement that whether has conflict to pointing to the same difference of operating position for the treatment of, and carry out differentiated treatment according to judged result, in a single day rather than treat the concurrency control method that in correlation technique operative position is equipped with lock and just all lists the corresponding affairs of every other lock in waiting list, so it is lower to the concurrency of affairs control to have overcome the concurrency control method in the correlation technique, the problem that system performance is relatively poor, and then improved the concurrency of affairs controls, improved concurrent control effect.
Preferably, in above-mentioned concurrent control device, the lock relation table specifically comprises: transaction list is used to the affairs of preserving concurrent execution and not submitting to; The lock Hash table is used to follow the tracks of the lock of waiting in line; The chain table is used for association affairs and lock.
Lock relation table in the present embodiment specifically comprises transaction list, lock Hash table and chain table, the concurrency control method that is arranged so that present embodiment of above-mentioned table can effectively be managed affairs and lock, comprise index location, traversal search etc. apace, and then realized locking the judgement that whether has conflict to pointing to the same difference of operating position for the treatment of, for providing, above-mentioned concurrency control method provides powerful support for.
Transaction list is preserved the current affairs transaction information of other affairs of concurrent execution in the system when carrying out, the principle that is inserted into team's head according to the late comer is inserted, the pointer of node, the meter pointer of chain table etc. before and after transaction information specifically comprises in affairs ID, transaction types, the sensing transaction list.Affairs of each startup all can be inserted into these affairs in the transaction list, promptly the transaction information of these affairs can be saved in the transaction list.Comprise a thread structure information in the transaction structure, wherein comprised event object, when affairs because of waiting for the lock hanging time-out, carry out this event object of thread waits of affairs; When the affairs granted lock thereby when being waken up, the thread of granted lock is provided with this event object.
As shown in Figure 2, each list item of lock Hash table is done like this corresponding to the gauge outfit of a chain table, makes that with the file space of writing down in the lock construction number and page number be that key calculates cryptographic hash, can navigate to corresponding chain table by corresponding lock Hash table list item.
The chain table is used for the affairs of association affairs tabulation record and locks the lock that writes down in the Hash table, as shown in Figure 2, each chain table comprises a plurality of lock constructions, each lock construction has write down information such as the file space number, page number, lock-bit figure, the shared bit of lock-bit figure (bit) number, lock type (shared lock, exclusive lock), lock sign (wait for, authorize), affiliated affairs of the data-base recording of the lock locking of waiting in line, and wherein the heap_no position of lock-bit figure is a sign for the treatment of the operating position record.Each affairs is corresponding to a chain table, lock of the every application of affairs, and all chain is gone in corresponding chain table, and this chain table is preserved the lock that these affairs are held, and every pair of record is operated, and just can lock accordingly and insert in the corresponding chain table of these affairs.A lock construction can be shared with other lock of the same type on one page, the lock that on other record, adds same type if desired, only need in the chain table, to search to have or not similar lock, if find then with the position, corresponding heap_no position of lock-bit figure, adopt single linked list promptly to solve hash collision like this, and saved memory headroom effectively.
As can be seen from the above description, the above embodiments of the present invention have improved the concurrency of affairs controls, have improved concurrent control effect.
Obviously, those skilled in the art should be understood that, above-mentioned each module of the present invention or each step can realize with the general calculation device, they can concentrate on the single calculation element, perhaps be distributed on the network that a plurality of calculation element forms, alternatively, they can be realized with the executable program code of calculation element, thereby, they can be stored in the memory storage and carry out by calculation element, perhaps they are made into each integrated circuit modules respectively, perhaps a plurality of modules in them or step are made into the single integrated circuit module and realize.Like this, the present invention is not restricted to any specific hardware and software combination.
The above is the preferred embodiments of the present invention only, is not limited to the present invention, and for a person skilled in the art, the present invention can have various changes and variation.Within the spirit and principles in the present invention all, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (11)

1. a concurrency control method is characterized in that, may further comprise the steps:
Judge according to the lock relation table whether the operating position for the treatment of of affairs has and the phase-locked lock that conflicts to be granted, and described lock relation table is used to preserve the relation of described affairs and lock;
To described affairs granted lock, and carry out described affairs according to judged result;
When described affairs are carried out end, discharge the lock that described affairs are held, and the lock that need not in the described lock that will discharge to continue to wait for is authorized other concurrent transactions.
2. concurrency control method according to claim 1 is characterized in that, described lock relation table specifically comprises:
Transaction list is used to the affairs of preserving concurrent execution and not submitting to;
The lock Hash table is used to follow the tracks of the lock of waiting in line;
The chain table is used for related described affairs and described lock.
3. concurrency control method according to claim 2 is characterized in that,, and carries out described affairs and specifically comprises described affairs granted lock according to judged result:
If the described operating position for the treatment of of described affairs does not have lock,, and carry out described affairs to described affairs granted lock.
4. concurrency control method according to claim 2 is characterized in that,, and carries out described affairs and specifically comprises described affairs granted lock according to judged result:
If the described existing lock of operating position for the treatment of of described affairs, whether the existing lock of inspection exists with described lock to be granted is conflicted;
To described affairs granted lock, and carry out described affairs according to check result.
5. concurrency control method according to claim 4 is characterized in that,, and carries out described affairs and specifically comprises described affairs granted lock according to check result:
If described existing lock does not exist with described lock to be granted and conflicts,, and carry out described affairs to described affairs granted lock.
6. concurrency control method according to claim 4 is characterized in that,, and carries out described affairs and specifically comprises described affairs granted lock according to check result:
If described existing lock conflicts with described to be granted being latched in, described transaction queue is set waits for, until regaining described lock to be granted;
Carry out described affairs.
7. according to claim 3,5 or 6 described concurrency control methods, it is characterized in that, carry out described affairs comprise following one of at least: increase operation, carry out deletion action, the operation of making amendment, carry out read operation.
8. concurrency control method according to claim 1 and 2 is characterized in that, described affairs are carried out and finished to comprise: described affairs are finished submission or described affairs are finished rollback.
9. concurrency control method according to claim 1 and 2 is characterized in that, authorizes other concurrent transactions with the lock that need not in the described lock that discharges to continue to wait for and specifically comprises:
To each lock in the described lock place chain table that discharges, detect whether the sign of wait is arranged;
As waiting for sign, and when there is not the lock type comflict in other locks on the detected described lock and the same operating position of described other concurrent transactions, authorize described other concurrent transactions with detected described lock, wake described other concurrent transactions up and continue to carry out, described lock type comprises shared lock and exclusive lock.
10. a concurrent control device is characterized in that, comprising:
Judge module is used for judging according to the lock relation table whether the operating position for the treatment of of affairs has and the phase-locked lock that conflicts to be granted, and described lock relation table is used to preserve the relation of described affairs and lock;
Execution module is used for according to judged result described affairs granted lock, and carries out described affairs;
Release module is used for discharge the lock that described affairs are held, and the lock that need not in the described lock that will discharge to continue to wait for being authorized other concurrent transactions when described affairs are carried out end.
11. concurrent control device according to claim 10 is characterized in that, described lock relation table specifically comprises:
Transaction list is used to the affairs of preserving concurrent execution and not submitting to;
The lock Hash table is used to follow the tracks of the lock of waiting in line;
The chain table is used for related described affairs and described lock.
CN2009101608047A 2009-07-23 2009-07-23 Concurrency control method and device Active CN101615203B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN2009101608047A CN101615203B (en) 2009-07-23 2009-07-23 Concurrency control method and device
PCT/CN2009/076082 WO2011009274A1 (en) 2009-07-23 2009-12-25 Method and apparatus of concurrency control

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2009101608047A CN101615203B (en) 2009-07-23 2009-07-23 Concurrency control method and device

Publications (2)

Publication Number Publication Date
CN101615203A true CN101615203A (en) 2009-12-30
CN101615203B CN101615203B (en) 2012-04-04

Family

ID=41494843

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2009101608047A Active CN101615203B (en) 2009-07-23 2009-07-23 Concurrency control method and device

Country Status (2)

Country Link
CN (1) CN101615203B (en)
WO (1) WO2011009274A1 (en)

Cited By (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102103642A (en) * 2011-03-25 2011-06-22 北京世纪互联工程技术服务有限公司 OLTP-based data deletion method, system and graphic database sever
CN103003815A (en) * 2010-06-23 2013-03-27 微软公司 Shared data collections
CN104252545A (en) * 2014-10-11 2014-12-31 南京国电南自美卓控制系统有限公司 Method for realizing object type attribute type lock of real-time memory database
CN104252386A (en) * 2013-06-26 2014-12-31 阿里巴巴集团控股有限公司 Data update locking method and equipment
CN104657237A (en) * 2015-03-12 2015-05-27 浪潮集团有限公司 Method for detecting disk array
CN104679881A (en) * 2015-03-13 2015-06-03 华为技术有限公司 Concurrency control method and concurrency control device
WO2016045605A3 (en) * 2014-09-26 2016-05-06 Huawei Technologies Co., Ltd. Concurrency control in shared storage architecture supporting on-page implicit locks
CN106156126A (en) * 2015-04-08 2016-11-23 阿里巴巴集团控股有限公司 Process the data collision detection method in data task and server
CN106250487A (en) * 2016-07-29 2016-12-21 杭州华三通信技术有限公司 A kind of database concurrency control method and device
CN106663062A (en) * 2014-04-30 2017-05-10 甲骨文国际公司 System and method for providing distributed transaction lock in transactional middleware machine environment
CN107016041A (en) * 2017-01-19 2017-08-04 阿里巴巴集团控股有限公司 A kind of method and device of control wall scroll data outbound
CN107291371A (en) * 2016-03-31 2017-10-24 华为技术有限公司 The implementation method and device of a kind of Read-Write Locks
CN109376165A (en) * 2018-11-14 2019-02-22 深圳市金证科技股份有限公司 The implementation method and device and computer readable storage medium of memory database lock
CN109388645A (en) * 2017-08-11 2019-02-26 腾讯科技(深圳)有限公司 Instruction executing method, instruction executing device and storage medium
CN109933606A (en) * 2019-03-19 2019-06-25 上海达梦数据库有限公司 A kind of database update method, apparatus, equipment and storage medium
CN110750356A (en) * 2019-09-09 2020-02-04 华南师范大学 Multi-core interaction method, system and storage medium suitable for nonvolatile memory
CN110909012A (en) * 2019-12-04 2020-03-24 上海达梦数据库有限公司 Method, device, equipment and storage medium for blocking database object
CN111198872A (en) * 2020-01-06 2020-05-26 中科驭数(北京)科技有限公司 Method and device for processing transactions by database
CN111858626A (en) * 2020-06-04 2020-10-30 武汉达梦数据库有限公司 Data synchronization method and device based on parallel execution
CN111984379A (en) * 2020-07-14 2020-11-24 上海金仕达软件科技有限公司 Read-write transaction control method, system, terminal device and storage medium
CN112199391A (en) * 2020-09-30 2021-01-08 深圳前海微众银行股份有限公司 Data locking detection method and device and computer readable storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100353325C (en) * 2004-08-23 2007-12-05 华为技术有限公司 Method for realing sharing internal stored data base and internal stored data base system
US7689561B2 (en) * 2005-12-07 2010-03-30 Sap Ag System and method for handling parallel updates of objects requiring time sensitive acknowledgement
CN1808389A (en) * 2006-02-20 2006-07-26 南京联创科技股份有限公司 Autonomous locking method based on shared memory for account background memory database
CN100568184C (en) * 2007-12-27 2009-12-09 电子科技大学 The locking method of data collision module in the collaborative editing

Cited By (34)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103003815A (en) * 2010-06-23 2013-03-27 微软公司 Shared data collections
CN103003815B (en) * 2010-06-23 2014-04-16 微软公司 Shared data collections
US9104715B2 (en) 2010-06-23 2015-08-11 Microsoft Technology Licensing, Llc Shared data collections
CN102103642B (en) * 2011-03-25 2016-08-03 北京世纪互联宽带数据中心有限公司 Data-erasure method based on OLTP, system and graphic data base server
CN102103642A (en) * 2011-03-25 2011-06-22 北京世纪互联工程技术服务有限公司 OLTP-based data deletion method, system and graphic database sever
CN104252386A (en) * 2013-06-26 2014-12-31 阿里巴巴集团控股有限公司 Data update locking method and equipment
CN104252386B (en) * 2013-06-26 2017-11-21 阿里巴巴集团控股有限公司 The locking method and equipment of data renewal
CN106663062B (en) * 2014-04-30 2019-08-16 甲骨文国际公司 The system and method for distributed transaction lock are provided in transactional middleware machine environment
CN106663062A (en) * 2014-04-30 2017-05-10 甲骨文国际公司 System and method for providing distributed transaction lock in transactional middleware machine environment
WO2016045605A3 (en) * 2014-09-26 2016-05-06 Huawei Technologies Co., Ltd. Concurrency control in shared storage architecture supporting on-page implicit locks
CN104252545B (en) * 2014-10-11 2017-05-31 南京国电南自维美德自动化有限公司 A kind of implementation method of the object type attributes type lock of real-time internal memory database
CN104252545A (en) * 2014-10-11 2014-12-31 南京国电南自美卓控制系统有限公司 Method for realizing object type attribute type lock of real-time memory database
CN104657237A (en) * 2015-03-12 2015-05-27 浪潮集团有限公司 Method for detecting disk array
CN104679881A (en) * 2015-03-13 2015-06-03 华为技术有限公司 Concurrency control method and concurrency control device
CN106156126A (en) * 2015-04-08 2016-11-23 阿里巴巴集团控股有限公司 Process the data collision detection method in data task and server
CN106156126B (en) * 2015-04-08 2019-10-11 阿里巴巴集团控股有限公司 Handle the data collision detection method and server in data task
CN107291371B (en) * 2016-03-31 2019-11-19 华为技术有限公司 A kind of implementation method and device of Read-Write Locks
CN107291371A (en) * 2016-03-31 2017-10-24 华为技术有限公司 The implementation method and device of a kind of Read-Write Locks
CN106250487A (en) * 2016-07-29 2016-12-21 杭州华三通信技术有限公司 A kind of database concurrency control method and device
CN107016041A (en) * 2017-01-19 2017-08-04 阿里巴巴集团控股有限公司 A kind of method and device of control wall scroll data outbound
CN109388645A (en) * 2017-08-11 2019-02-26 腾讯科技(深圳)有限公司 Instruction executing method, instruction executing device and storage medium
CN109388645B (en) * 2017-08-11 2023-02-24 腾讯科技(深圳)有限公司 Instruction execution method, instruction execution device, and storage medium
CN109376165A (en) * 2018-11-14 2019-02-22 深圳市金证科技股份有限公司 The implementation method and device and computer readable storage medium of memory database lock
CN109933606B (en) * 2019-03-19 2021-04-27 上海达梦数据库有限公司 Database modification method, device, equipment and storage medium
CN109933606A (en) * 2019-03-19 2019-06-25 上海达梦数据库有限公司 A kind of database update method, apparatus, equipment and storage medium
CN110750356A (en) * 2019-09-09 2020-02-04 华南师范大学 Multi-core interaction method, system and storage medium suitable for nonvolatile memory
CN110750356B (en) * 2019-09-09 2022-03-29 华南师范大学 Multi-core interaction method, system and storage medium suitable for nonvolatile memory
CN110909012A (en) * 2019-12-04 2020-03-24 上海达梦数据库有限公司 Method, device, equipment and storage medium for blocking database object
CN110909012B (en) * 2019-12-04 2020-09-04 上海达梦数据库有限公司 Method, device, equipment and storage medium for blocking database object
CN111198872A (en) * 2020-01-06 2020-05-26 中科驭数(北京)科技有限公司 Method and device for processing transactions by database
CN111858626A (en) * 2020-06-04 2020-10-30 武汉达梦数据库有限公司 Data synchronization method and device based on parallel execution
CN111984379A (en) * 2020-07-14 2020-11-24 上海金仕达软件科技有限公司 Read-write transaction control method, system, terminal device and storage medium
CN112199391A (en) * 2020-09-30 2021-01-08 深圳前海微众银行股份有限公司 Data locking detection method and device and computer readable storage medium
CN112199391B (en) * 2020-09-30 2024-02-23 深圳前海微众银行股份有限公司 Data locking detection method, equipment and computer readable storage medium

Also Published As

Publication number Publication date
CN101615203B (en) 2012-04-04
WO2011009274A1 (en) 2011-01-27

Similar Documents

Publication Publication Date Title
CN101615203B (en) Concurrency control method and device
US7243088B2 (en) Database management system with efficient version control
US5333316A (en) Locking and row by row modification of a database stored in a single master table and multiple virtual tables of a plurality of concurrent users
CN109923534B (en) Multi-version concurrency control for database records with uncommitted transactions
US5983225A (en) Parameterized lock management system and method for conditional conflict serializability of transactions
US5623659A (en) Parent/child subset locking scheme for versioned objects
CN101495976B (en) Direct-update software transactional memory
US4965719A (en) Method for lock management, page coherency, and asynchronous writing of changed pages to shared external store in a distributed computing system
US11580134B1 (en) Method and apparatus for resolving source database precommitted transactions that are replicated to a target database of a database replication system
US11386065B2 (en) Database concurrency control through hash-bucket latching
Wu et al. Transaction healing: Scaling optimistic concurrency control on multicores
Kawaguchi et al. Concurrency control theory for deferred materialized views
CA2375376A1 (en) Collision avoidance in bidirectional database replication
US20090319581A1 (en) Online Table Move
CN111459920B (en) Multi-version concurrency control method and system based on virtual global clock synchronization
Perrizo et al. Hydro: A heterogeneous distributed database system
CA2414980A1 (en) Deferred incremental integrity maintenance of base tables having contiguous data blocks
US7617212B2 (en) System and method for controlling access to a database
US8180745B2 (en) Persistent object references to parallel database containers
US7412465B2 (en) Method for append mode insertion of rows into tables in database management systems
US20090204967A1 (en) Reporting of information pertaining to queuing of requests
Lomet et al. Using the lock manager to choose timestamps
GB2356950A (en) System for improving concurrency through early release of unnecessary locks
Park et al. Priority-driven secure multiversion locking protocol for real-time secure database systems
CN117348977A (en) Method, device, equipment and medium for controlling transaction concurrency in database

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant