CN101615203B - Concurrency control method and device - Google Patents

Concurrency control method and device Download PDF

Info

Publication number
CN101615203B
CN101615203B CN2009101608047A CN200910160804A CN101615203B CN 101615203 B CN101615203 B CN 101615203B CN 2009101608047 A CN2009101608047 A CN 2009101608047A CN 200910160804 A CN200910160804 A CN 200910160804A CN 101615203 B CN101615203 B CN 101615203B
Authority
CN
China
Prior art keywords
lock
affairs
granted
control method
carry out
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.)
Active
Application number
CN2009101608047A
Other languages
Chinese (zh)
Other versions
CN101615203A (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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a concurrency control method, which comprises the following steps: judging whether a lock conflicting with the lock to be granted exists at the position to be operated of the transaction according to a lock relation table, wherein the lock relation table is used for storing the relation between the transaction and the lock; according to the judgment result, a lock is granted to the transaction, and the transaction is executed; when the execution of the transaction is finished, the locks held by the transaction are released, and locks which do not need to continuously wait in the released locks are granted to other concurrent transactions. The present invention also provides a concurrency control device, including: a judgment module; an execution module; and releasing the module. The invention overcomes the problems of lower concurrency of transaction control and poorer system performance of the concurrency control method in the related technology, thereby improving the concurrency of the transaction control and improving the concurrency 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 possibly there are 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.Possibly there are 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 through locking to operated data-base recording, and lets 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 get into waiting list; After being finished to lock release by last lock-based transaction execution; Other concurrent transactions just are able to database 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 get into waiting list; After being finished to lock release by last lock-based transaction execution; Other concurrent transactions just are able to database operated again, and cause the concurrency of affairs control lower, the problem that system performance is relatively poor.
In an embodiment of the present invention, a kind of concurrency control method is provided, has may further comprise the steps: whether the operating position of treating of judging affairs according to the lock relation table has and treats the afoul lock of granted lock, locks the relation that 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 of treating 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, the existing lock of inspection with treat whether granted lock exists and conflict; 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 based on check result: if existing lock with treat that granted lock does not exist and conflict, to the affairs granted lock, and the execution affairs.
Preferably, in above-mentioned concurrency control method, to the affairs granted lock, and carry out affairs and specifically comprise based on check result: if existing lock with treat that granted lock exists and conflict, transaction queue's wait is set, treat granted lock until regaining; 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 accomplished and are submitted to or affairs completion 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: each lock in the 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 same operating position of lock to be detected and other concurrent transactions; Authorize other concurrent transactions with lock to be detected, 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, a kind of concurrent control device is provided also, has comprised: judge module is used for judging that according to the lock relation table whether the operating position of treating of affairs has and treat the afoul lock of granted lock, locks the relation that 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 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 being authorized other concurrent transactions.
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 of treating; 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, and 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 accompanying drawing and combine embodiment, specify the present invention.
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 of treating of affairs has and treat the afoul lock of granted lock, locks the relation that 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 of treating of affairs has and treat the afoul lock of granted lock; Then according to judged result to the affairs granted lock, and carry out 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 authorizes other concurrent transactions, because the relation that has adopted the lock relation table to preserve its corresponding locks of affairs, so can lock the judgement that whether has conflict to pointing to the same difference of operating position of treating; 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, and 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 of treating, 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 can the transaction information of these affairs 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 be that key calculates cryptographic hash with the file space of writing down in the lock construction number with page number, can navigate to corresponding chain table through 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 of treating 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 insert in the corresponding chain table of these affairs locking accordingly.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, adopt single linked list promptly to solve hash collision like this, and saved memory headroom effectively with the corresponding heap_no bit of lock-bit figure.
Preferably, in above-mentioned concurrency control method, step S102 specifically comprises: if the operating position of treating that thing 0 is engaged in does not have lock, to the affairs granted lock, and carry out affairs.
If the operating position of treating 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 affairs treat the existing lock of operating position, the existing lock of inspection with treat whether granted lock exists and conflict; 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, then need continue to check existing lock and treat whether granted lock exists and conflict that 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 wait, improved the concurrency of control.
Preferably, in above-mentioned concurrency control method, to the affairs granted lock, and carry out affairs and specifically comprise based on check result: if existing lock with treat that granted lock does not exist and conflict, to the affairs granted lock, and the execution affairs.
Though in the present embodiment affairs treat the existing lock of operating position, check result for existing lock with treat that granted lock does not exist and conflict, at this moment, 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, to the affairs granted lock, and carry out affairs and specifically comprise based on check result: if existing lock with treat that granted lock exists and conflict, transaction queue's wait is set, treat granted lock until regaining; Carry out affairs.
In the present embodiment if affairs treat the existing lock of operating position, and existing lock with treat that granted lock exists and conflict, these affairs then are set hang up insertion waiting list and wait in line, treat granted lock until regaining, and the execution affairs.Do like this; Make affairs to satisfy simultaneously to treat existing lock of operating position and existing lock with treat condition that the granted lock existence conflicts under just can hang up wait; Be that affairs are only just waited for when other concurrent transactions influence definite can receiving; 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, 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 corresponding gathering index record of current index record, if this record is just to insert, the implicit expression lock is arranged on this record then, converts this implicit expression lock into explicit lock;
Step S310 judges whether X=tuple sets up, and X=tuple representes 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;
Whether step S314 exists lock on next bar record of inspection current record, is that key calculates cryptographic hash with file space, record place number with page number promptly; 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, then should upward there be lock in expression by record, continued to judge whether to exist lock conflict, if there is lock conflict, forwarded 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 are carried out and are finished, and promptly affairs are accomplished and are submitted to or affairs completion rollback, discharge the lock of holding, and the lock that no longer need wait for is authorized in the formation of scanning lock Hash table lock simultaneously.
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, has reduced cost, has 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 accomplished and are submitted to or affairs completion rollback.
Affairs execution end comprises that the affairs completion is submitted to or affairs are accomplished rollback in the present embodiment, promptly when affairs completion submission or affairs completion rollback, discharges the lock that these affairs are held.When lock is accomplished the locking task, be released at once 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, from the lock Hash table of correspondence, deletes simultaneously.
Carry out end when affairs in the present embodiment, when promptly these affairs are accomplished submission or accomplished rollback, the lock that these affairs are held is deleted from the corresponding chain table of these affairs, the while also deletes from the lock Hash table of correspondence.Present embodiment adopts will lock from corresponding chain table deletes the release that realizes lock with locking the Hash table; Operation is simple; And make and after lock is accomplished the locking task to certain affairs, be released at once; 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, authorize other concurrent transactions with the lock that need not in the lock that discharges to continue to wait for and specifically comprise: each lock in the 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 same operating position of lock to be detected and other concurrent transactions; Authorize other concurrent transactions with lock to be detected, 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; Showing that then lock is in waiting status, is that key calculates cryptographic hash with the file space, record place of the lock locking of waiting status number with page number then, navigates to the gauge outfit of corresponding chain table on the lock Hash table; Scanning lock place chained list; Whether have other lock to exist with it to each lock inspection in the chained list and lock type comflict, if there is the lock type comflict, lock then to be detected 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; Lock then to be detected need not to wait for, authorizes other concurrent transactions with lock to be detected, the wait sign of this lock of resetting; Be about to this lock and change the state of authorizing into, and wake other corresponding concurrent transactions of lock to be detected up and continue to carry out 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 that according to the lock relation table whether the operating position of treating of affairs has and treat the afoul lock of granted lock, locks the relation that 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 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 being authorized other concurrent transactions.
Present embodiment at first adopts judge module 10 to judge according to the lock relation table whether the operating position of treating of affairs has and treat the afoul lock of granted lock; Adopt then execution module 20 according to judged result to the affairs granted lock, and carry out 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 authorizes other concurrent transactions, because the relation that has adopted the lock relation table to preserve its corresponding locks of affairs, so can lock the judgement that whether has conflict to pointing to the same difference of operating position of treating; 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, and 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 of treating, 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 can the transaction information of these affairs 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 corresponding to the gauge outfit of a chain table like this, makes that be that key calculates cryptographic hash with the file space of writing down in the lock construction number with page number, can navigate to corresponding chain table through 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 of treating 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 insert in the corresponding chain table of these affairs locking accordingly.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, adopt single linked list promptly to solve hash collision like this, and saved memory headroom effectively with the corresponding heap_no bit of lock-bit figure.
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, it is apparent to those skilled in the art 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; Can they be stored in the memory storage and carry out, 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 by calculation element.Like this, the present invention is not restricted to any specific hardware and software combination.
The above is merely the preferred embodiments of the present invention, is not limited to the present invention, and for a person skilled in the art, the present invention can have various changes and variation.All within spirit of the present invention and principle, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (8)

1. a concurrency control method is characterized in that, may further comprise the steps:
Whether the operating position of treating of judging affairs based on the lock relation table has and treats the afoul lock of granted lock; Said lock relation table is used to preserve the relation of said affairs and lock; Said 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 said affairs and said lock;
To said affairs granted lock, and carry out said affairs according to judged result;
When said affairs are carried out end; Discharge the lock that said affairs are held; And the lock that need not in the said lock that will discharge to continue to wait for is authorized other concurrent transactions; Wherein, authorize other concurrent transactions with the lock that need not in the said lock that discharges to continue to wait for and specifically comprise: each lock in the said 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 said lock to be detected and the same operating position of said other concurrent transactions; Authorize said other concurrent transactions with said lock to be detected; Wake said other concurrent transactions up and continue to carry out, said lock type comprises shared lock and exclusive lock.
2. concurrency control method according to claim 1 is characterized in that,, and carries out said affairs and specifically comprises said affairs granted lock according to judged result:
If the said operating position of treating of said affairs does not have lock,, and carry out said affairs to said affairs granted lock.
3. concurrency control method according to claim 1 is characterized in that,, and carries out said affairs and specifically comprises said affairs granted lock according to judged result:
If said affairs said treated the existing lock of operating position, the existing lock of inspection is treated whether granted lock exists and is conflicted with said;
To said affairs granted lock, and carry out said affairs according to check result.
4. concurrency control method according to claim 3 is characterized in that,, and carries out said affairs and specifically comprises said affairs granted lock according to check result:
If said existing lock is treated that granted lock does not exist and is conflicted with said, to said affairs granted lock, and carries out said affairs.
5. concurrency control method according to claim 3 is characterized in that,, and carries out said affairs and specifically comprises said affairs granted lock according to check result:
If said existing lock treats that with said the granted lock existence conflicts, and is provided with said transaction queue and waits for, until regaining the said granted lock of treating;
Carry out said affairs.
6. according to claim 2,4 or 5 described concurrency control methods, it is characterized in that, carry out said affairs comprise following one of at least: increase operation, carry out deletion action, the operation of making amendment, carry out read operation.
7. concurrency control method according to claim 1 is characterized in that, said affairs are carried out and finished to comprise: said affairs are accomplished and are submitted to or said affairs completion rollback.
8. a concurrent control device is characterized in that, comprising:
Judge module; Be used for judging based on the lock relation table whether the operating position of treating of affairs has and treat the afoul lock of granted lock; Said lock relation table is used to preserve the relation of said affairs and lock, and said 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 said affairs and said lock;
Execution module is used for according to judged result said affairs granted lock, and carries out said affairs;
Release module is used for when said affairs are carried out end, discharge the lock that said affairs are held, and the lock that need not in the said lock that will discharge to continue to wait for being authorized other concurrent transactions;
Wherein, said release module is further used for each lock in the said lock place chain table that discharges is detected 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 said lock to be detected and the same operating position of said other concurrent transactions; Authorize said other concurrent transactions with said lock to be detected; Wake said other concurrent transactions up and continue to carry out, said lock type comprises shared lock and exclusive 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 CN101615203A (en) 2009-12-30
CN101615203B true 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)

Families Citing this family (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
CN104252386B (en) * 2013-06-26 2017-11-21 阿里巴巴集团控股有限公司 The locking method and equipment of data renewal
KR102206577B1 (en) * 2014-04-30 2021-01-25 오라클 인터내셔날 코포레이션 System and method for providing distributed transaction lock in transactional middleware machine environment
US20160092488A1 (en) * 2014-09-26 2016-03-31 Futurewei Technologies, Inc. Concurrency control in a 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
CN104657237A (en) * 2015-03-12 2015-05-27 浪潮集团有限公司 Method for detecting disk array
CN104679881B (en) * 2015-03-13 2019-03-08 华为技术有限公司 A kind of concurrency control method and device
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
CN106250487B (en) * 2016-07-29 2020-07-03 新华三技术有限公司 Database concurrency control method and device
CN107016041B (en) * 2017-01-19 2020-05-05 阿里巴巴集团控股有限公司 Method and device for controlling single data to be exported
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
CN110750356B (en) * 2019-09-09 2022-03-29 华南师范大学 Multi-core interaction method, system and storage medium suitable for nonvolatile memory
CN110909012B (en) * 2019-12-04 2020-09-04 上海达梦数据库有限公司 Method, device, equipment and storage medium for blocking database object
CN111198872B (en) * 2020-01-06 2021-06-11 中科驭数(北京)科技有限公司 Method and device for processing transactions by database
CN111858626B (en) * 2020-06-04 2024-06-21 武汉达梦数据库股份有限公司 Parallel execution-based data synchronization method and device
CN111984379B (en) * 2020-07-14 2023-04-07 上海金仕达软件科技股份有限公司 Read-write transaction control method, system, terminal device and storage medium
CN112199391B (en) * 2020-09-30 2024-02-23 深圳前海微众银行股份有限公司 Data locking detection method, equipment 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

Also Published As

Publication number Publication date
CN101615203A (en) 2009-12-30
WO2011009274A1 (en) 2011-01-27

Similar Documents

Publication Publication Date Title
CN101615203B (en) Concurrency control method and device
CA2537411C (en) A database management system with efficient version control
US11580134B1 (en) Method and apparatus for resolving source database precommitted transactions that are replicated to a target database of a database replication system
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
CN101495976B (en) Direct-update software transactional memory
US5983225A (en) Parameterized lock management system and method for conditional conflict serializability of transactions
US7233947B2 (en) Timestamping in databases
CN111433764A (en) High-throughput distributed transaction management of global consistency sliced O L TP system and implementation method thereof
Wu et al. Transaction healing: Scaling optimistic concurrency control on multicores
CN106354732B (en) A kind of off-line data version conflict solution for supporting concurrently to cooperate with
CN101714167B (en) Method and device for accessing monofile database
CN101788922A (en) Method and device for realizing transaction storage system based on auxiliary thread
CN101556597B (en) Self-adaptive optimistic concurrency control method
Chen et al. Plor: General transactions with predictable, low tail latency
Perrizo et al. Hydro: A heterogeneous distributed database system
US7617212B2 (en) System and method for controlling access to a database
Ammann et al. A two snapshot algorithm for concurrency control in multi-level secure databases
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
US20240184766A1 (en) Method and apparatus for fine-grained hierarchical locking in a multi-master database system
CN117348977A (en) Method, device, equipment and medium for controlling transaction concurrency in database
Park et al. Priority-driven secure multiversion locking protocol for real-time secure database systems
He Supporting Low-Latency Transactions in Shared-Memory Deterministic Databases
Kuo et al. Conservative and optimistic protocols

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