CN110502525A - A kind of optimistic concurrency control method of hybrid working load - Google Patents

A kind of optimistic concurrency control method of hybrid working load Download PDF

Info

Publication number
CN110502525A
CN110502525A CN201910757261.0A CN201910757261A CN110502525A CN 110502525 A CN110502525 A CN 110502525A CN 201910757261 A CN201910757261 A CN 201910757261A CN 110502525 A CN110502525 A CN 110502525A
Authority
CN
China
Prior art keywords
readset
affairs
predicate
verification method
verifying
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.)
Pending
Application number
CN201910757261.0A
Other languages
Chinese (zh)
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.)
East China Normal University
Original Assignee
East China Normal University
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 East China Normal University filed Critical East China Normal University
Priority to CN201910757261.0A priority Critical patent/CN110502525A/en
Publication of CN110502525A publication Critical patent/CN110502525A/en
Pending legal-status Critical Current

Links

Classifications

    • 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/2315Optimistic concurrency control
    • G06F16/2322Optimistic concurrency control using timestamps
    • 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/2315Optimistic concurrency control
    • G06F16/2329Optimistic concurrency control using versioning
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution

Landscapes

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

Abstract

The invention discloses the optimistic concurrency control methods under a kind of load of hybrid working, its main feature is that the method for closing verifying with the verifying integration of global write set using local readset, dynamically estimated according to workload and more different verification methods generate verifying cost, the verification method for selecting cost minimum and corresponding follow-up mechanism carry out hybrid working and load lower Optimistic Concurrency control, and specific execute includes: reading, verifying and the process that three phases are written.The advantages that present invention has the verifying of affairs at low cost compared with prior art, easy to operate, practical, reliable, is applicable to different types of workload, and systematic entirety can be good.

Description

A kind of optimistic concurrency control method of hybrid working load
Technical field
The present invention relates to the transaction concurrency control technology fields of memory database, especially a kind of to be loaded based on hybrid working Optimistic concurrency control method.
Background technique
Optimistic Concurrency controls (Optimistic Concurrency Control, abbreviation OCC) agreement for affairs Entire execute is divided into three continuous stages: reading stage, Qualify Phase and write phase.One affairs is in Qualify Phase to it The data of reading and the data of write-in are verified to check whether own destroys the serializability scheduling of affairs.From verifying From the perspective of record type, the authentication mechanism of Optimistic Concurrency control can be divided into two classes: local readset closes verifying (Local Readset Validation, abbreviation LRV) and the verifying of global write set (Global Writeset Validation, referred to as GWV).Closed in verification method in local readset, affairs closed using local readset record the data of oneself all reading and its Corresponding version.In Qualify Phase, the affairs need to check its local readset close in all records, it is concurrent to search other Whether affairs have modified the data of its reading in its reading stage.It is not needed using the affairs of global write set verification method Retain in the context of oneself and read record, but saves the predicate in all SQL query statements about WHERE clause.Work as thing Business is when entering Qualify Phase, which checks that whether these predicates met other concurrent transactions writes set, thus judgement oneself The serialization whether oneself destroys affairs executes, and the affairs of all submissions will all be stored in the recently submitted list of the overall situation In.But the authentication mechanism of these Optimistic Concurrencies control can not all be suitable for different types of workload.It is obvious that local The size that the readset of performance and affairs that readset closes verification method closes is closely related.For example, executing a scanning on a large scale When inquiry, affairs need to save a large amount of scanning record in the conjunction of its readset.Since the affairs need to read again in Qualify Phase A large amount of data are taken, verifying cost will obviously increase.It is different from local readset conjunction verification method, global write set authentication The cost of method depends greatly on the feature of real-time working load, with the increasing of concurrent transaction amount and the tuple amount of modification Add, the expense for verifying predicate will obviously increase.
Although Optimistic Concurrency Control Protocol can use the characteristic of present age computer multicore and big memory, to possess more preferable Scalability, but when in workload include frequent read/write conflict when, which has higher transaction rollback rate, this will The overall performance of influence system.Work on hand about hybrid concurrency control mainly concentrates how to combine Optimistic Concurrency control and compassion It sees two-phase lock (Two-Phase Locking, abbreviation 2PL).In order to which using the advantage of two-phase lock, they are in concurrent affairs Between find the hot spot data for causing conflict, and in these hot spot datas of transactions access using the method for similar two-phase lock. But they have ignored the influence that cost is verified in Optimistic Concurrency Control Protocol.
The verifying cost of the Optimistic Concurrency control of the prior art is big, which can not be suitable for different types of work Load, the overall performance of system are poor.
Summary of the invention
The purpose of the present invention is the Optimistic Concurrencies in view of the deficiencies of the prior art and under a kind of hybrid working load of design Control method, the method that verifying with the verifying integration of global write set are closed using local readset, according in Optimistic Concurrency Control Protocol Reading, verifying and write-in three phases load lower Optimistic Concurrency control to describe hybrid working, according to each reading in affairs The feature of extract operation and the running work load characteristic of the affairs determine corresponding proof scheme, to reduce affairs The advantages of verifying cost, having and be suitable for different types of workload, improve systematic entirety energy.
The object of the present invention is achieved like this: the optimistic concurrency control method under a kind of load of hybrid working, feature The method that verifying with the verifying integration of global write set are closed using local readset, dynamically estimated according to workload and ratio less With the verifying cost that verification method generates, the minimum verification method of cost and corresponding follow-up mechanism is selected to carry out hybrid working negative Lower Optimistic Concurrency control is carried, specifically executing process includes following three stages:
(1), the stage is read
A step: tuple is obtained from data set according to the predicate of query statement.
B step: R, P are usedno_readsetAnd PreadsetThe verification method of follow-up mechanism carries out costing analysis, in the R mechanism The search condition of inquiry operation, for each tuple of the queried access, obtains the tuple in the primary key column of tables of data Pointer tuple, and generation one reading version<tuple, tuple.ts>, the readset for being then added to affairs oneself closes In ReadSet;Use symbol S1Come indicate the inquiry operation be stored in readset close ReadSet in number of tuples, use cr1Expression is tested Card method LRV1 maintenance and the cost for checking a versions of data, if follow-up mechanism R provides service to read inquiry q, For the inquiry operation, verifying cost estimation required for verification method LRV1 is Clrv1(q)=S1·cr1
The Pno_readsetAffairs are oneself one predicate set PredicateSet of maintenance in mechanism, read behaviour when executing When making, affairs can be the query generation predicate and put it into the predicate set PredicateSet of oneself;Use S2And cr2 To respectively indicate follow-up mechanism PreadsetThe number of tuples and verification method LRV2 that need to store check the cost of a tuple, when making With follow-up mechanism PreadsetWhen carrying out record queries operation q and detect the inquiry using verification method LRV2, generation is verified Valence is estimated as Clrv2(q)=S2·cr2
The Pno_readsetMechanism can detect rushing between an affairs and its concurrent transaction using verification method GWV It is prominent.
The PreadsetAffairs need to safeguard a PredicateSet for oneself in mechanism, when executing read operation, Affairs not only need to generate predicate for query statement itself, it is also necessary to close ReadSet using a readset to store the member of access Group, the predicate of the query statement and its readset of return are closed ReadSet and are added to predicate set together by it In PredicateSet;The follow-up mechanism PreadsetAn affairs and its concurrent transaction can be detected using verification method GWV Between conflict, for each inquiry operation in affairs, the cost of verification method GWV is related with two aspects: concurrent transaction Quantity and each concurrent transaction write the mean size of set WriteSet, indicated respectively with N and W, if cpIt indicates to check one A predicate whether there is the cost of intersection with a record in set WriteSets is write, the verification method GWV's of inquiry operation q Cost estimation is Cgwv(q)=NWcp
Step c: the selection estimation the smallest verification method of cost, thus using corresponding follow-up mechanism, for inquiry operation Q, if the cost C of verification method LRV1lrv1(q) minimum, transacter will select R follow-up mechanism for the inquiry operation; If verifying cost Clrv2(q) minimum, then select PreadsetFollow-up mechanism;Otherwise, P is selectedno_readsetFollow-up mechanism.
Step d: the relevant tracking information of affairs start recording;
(2), Qualify Phase
A step: affairs needs lock to each record write in set WriteSet.
B step: all after writing lock when getting, affairs will obtain next index from global transaction list gList Point NextIndex, and the pointer of oneself context is placed at the point, the NextIndex value that each affairs is obtained is made It is stabbed for the submission time of affairs, i.e. serialization point of the affairs in all affairs.
Step c: MOCC (Mixed workloads using OCC, the Optimistic Concurrency control under hybrid working load) makes All inquiries of follow-up mechanism R are used with the verifying of LRV1 verification method, the LRV1 is verified as R follow-up mechanism and uses a kind of local Readset closes verification method to verify the readset of affairs and close ReadSet, and affairs are by the tuple of read access and its colophon to certainly Oneself readset closes in ReadSet, and when verifying ReadSet, whether affairs check the version of each tuple in ReadSet by other Concurrent transaction modification, if the newest timestamp in tuple is not equal to the timestamp copied when access tuples or tuple is another One affairs locking, then return the result ABORT.
Step d: carry out verifying the predicate set PredicateSet of the affairs as follows.
d1: if affairs have successfully passed the verifying that readset closes ReadSet, will verify the predicate set of the affairs PredicateSet, MOCC will first check for the tracking type of predicate p.
d2If: p.type=Pno_readset, the predicate will be verified using verification method GWV, use verification method When GWV verifies predicate, affairs T detects the range [sIndex, eIndex] on global transaction list gList, and in this range All concurrent transactions for finding affairs T, for each concurrent transaction in gList, affairs T check oneself predicate whether with this The each element intersection of concurrent transaction write in set WriteSet, if intersection, returns to ABORT.
d3If: the tracking type of the predicate is Preadset(p.type=Preadset), compare cost Clrv2(p) and Cgwv (p) size, if Clrv2(p) smaller, verification method LRV2 is selected, verification method GWV, the LRV2 is otherwise selected to need again Predicate is executed to obtain the newest readset of query statement and close ReadSet, then new readset is closed in ReadSet and predicate and is stored Old readset close ReadSet (p.set) and be compared, if phase in of different sizes or the two set of the two set It is different with the element on position, then return to ABORT.
Step e: if affairs have successfully passed all verifyings, which will return the result SUCCESS.
(3), write phase
Updating affairs in the database is oneself each record write in set WriteSet, while more new data and being released Corresponding lock is put, for each record in WriteSet, affairs can hold always the lock in corresponding data items until the record Data and timestamp field be updated, its state is set COMMITTED by last affairs.
The advantages that present invention has the verifying of affairs at low cost compared with prior art, easy to operate, practical, reliable, can Suitable for different types of workload, systematic entirety can be good.
Detailed description of the invention
Fig. 1 is global transaction list gList;
Fig. 2 is that the WHERE clause of query statement is changed into predicate example;
Fig. 3 is the MOCC example of follow-up mechanism R;
Fig. 4 is follow-up mechanism Pno_readsetMOCC example.
Fig. 5 is follow-up mechanism PreadsetMOCC example;
Fig. 6 is the execution schematic diagram of verification method;
Fig. 7 is the execution schematic diagram of transaction validation.
Specific embodiment
The verifying cost that the present invention dynamically estimates according to workload and more different verification methods generate, then selects The minimum verification method of cost follow-up mechanism corresponding with its, to reduce verifying cost of the affairs under hybrid working load simultaneously The overall performance of raising system describes the lower optimism of hybrid working load according to the three phases in Optimistic Concurrency Control Protocol simultaneously The specific execution process of control is sent out, i.e. reading stage, Qualify Phase and write phase, respectively includes following steps:
(1), the stage is read
A step: tuple is obtained from data set according to the predicate of query statement.
B step: costing analysis is carried out to the verification method of different follow-up mechanisms
The difference is R mechanism, P with follow-up mechanismno_readsetMechanism and PreadsetMechanism, specific verification method into Row costing analysis is as follows:
(1) for R mechanism: such case shows the search condition of the inquiry operation in the primary key column of tables of data;For Each tuple of the queried access obtains the pointer tuple of the tuple, and generates a reading version < tuple, Tuple.ts >, the readset for being then added to affairs oneself closes in ReadSet;The inquiry operation is indicated using symbol S1 Be stored in readset and close number of tuples in ReadSet, with cr1 indicate verification method LRV1 maintenance and check versions of data at This, therefore, if follow-up mechanism R provides service to read inquiry q, for the inquiry operation, verification method LRV1 institute The verifying cost estimation needed is Clrv1(q)=S1·cr1
(2) for Pno_readsetMechanism (the not predicate of ReadSet): in the mechanism, affairs are oneself maintenance one Predicate set PredicateSet, when executing read operation, affairs can be the query generation predicate and put it into oneself In predicate set PredicateSet;Use S2And cr2To respectively indicate follow-up mechanism PreadsetIt the number of tuples that needs to store and tests Card method LRV2 checks the cost of a tuple, as use follow-up mechanism PreadsetCarry out record queries operation q and utilizes authentication Method LRV2 is come when detecting the inquiry, verifying cost estimation is Clrv2(q)=S2·cr2
(3) for PreadsetMechanism (predicate with ReadSet): with follow-up mechanism Pno_readsetEqually, affairs needs are Oneself one PredicateSet of maintenance, when executing read operation, affairs not only need to generate predicate for query statement itself, It also needs to close ReadSet using a readset to store the tuple of access.It is by the predicate of the query statement and its reading of return Set ReadSet is added to together in predicate set PredicateSet;Follow-up mechanism PreadsetAnd Pno_readsetIt can benefit Conflicting between an affairs and its concurrent transaction is detected with verification method GWV.For each inquiry operation in affairs, test The cost of card method GWV and two aspects in relation to: the quantity of concurrent transaction and each concurrent transaction write the flat of set WriteSet Equal size is indicated with N and W respectively.If cpIt indicates to check a predicate and writes whether a record in set WriteSets is deposited In the cost of intersection, therefore, the cost estimation of the verification method GWV of inquiry operation q is Cgwv(q)=NWcp
Step c: suitable verification method and follow-up mechanism are selected
The selection estimation the smallest verification method of cost, thus using corresponding follow-up mechanism, for inquiry operation q, if The cost C of verification method LRV1lrv1(q) minimum, transacter will select R follow-up mechanism for the inquiry operation;If tested Demonstrate,prove cost Clrv2(q) minimum, then select PreadsetFollow-up mechanism;Otherwise, P is selectedno_readsetFollow-up mechanism.
Step d: the relevant tracking information of affairs start recording.
(2), Qualify Phase
A step: affairs needs lock to each record write in set WriteSet.
B step: affairs obtain submission time stamp
All after writing lock when getting, affairs will obtain next index point from global transaction list gList NextIndex, and the pointer of oneself context is placed at the point.The value for the NextIndex that each affairs is got is It is unique, and the value has monotonic increase, so using the value to stab as the submission time of affairs, that is, the affairs Serialization point in all affairs.
Step c: MOCC uses one using all inquiry follow-up mechanism R of follow-up mechanism R using the verifying of LRV1 verification method The local readset of kind closes verification method to verify the readset of affairs and close ReadSet, and this method is marked as LRV1, and affairs will read visit The tuple and its colophon asked are into the readset conjunction ReadSet of oneself.When verifying ReadSet, affairs are checked in ReadSet Whether the version of each tuple is modified by other concurrent transactions, if the newest timestamp in tuple is copied when being not equal to access tuples The timestamp or tuple of shellfish are locked by another affairs, then return the result ABORT.
Step d: the predicate set PredicateSet of the affairs is verified
If affairs have successfully passed the verifying that readset closes ReadSet, the predicate set of the affairs will be verified PredicateSet;MOCC will first check for the tracking type of predicate p.
If p.type=Pno_readset, the predicate will be verified using verification method GWV, use verification method GWV When verifying predicate, affairs T detects the range [sIndex, eIndex] on global transaction list gList, can look in this range To all concurrent transactions of affairs T.For each concurrent transaction in gList, affairs T check oneself predicate whether with this simultaneously The each element intersection of hair affairs write in set WriteSet.If intersection, returns to ABORT.
If the tracking type of the predicate is Preadset(p.type=Preadset), compare cost Clrv2(p) and Cgwv(p) Size, if Clrv2(p) smaller, verification method LRV2 is selected, verification method GWV is otherwise selected.Different from LRV1, LRV2 needs Predicate is re-executed to obtain the newest readset of query statement and close ReadSet, then closes new readset in ReadSet and predicate The old readset of storage closes ReadSet (p.set) and is compared, if of different sizes or the two set of the two set Element in middle same position is different, then returns to ABORT.
Step e: if affairs have successfully passed all verifyings, which will return the result SUCCESS.
(3), write phase
Affairs need each record write in set WriteSet for oneself to update its data in the database and release Corresponding lock is put, for each record in WriteSet, affairs can hold always the lock in corresponding data items until the record Data and timestamp field be updated, its state is set COMMITTED by last affairs.
Below by way of the specific example of several different follow-up mechanisms and verification method, the present invention is made further detailed It describes in detail bright.
Embodiment 1
Refering to attached drawing 1, global transaction list gList that transacter needs is stored just in Qualify Phase Or completed affairs, global transaction list gList be to be realized by annular array that a fixed size is N, each Affairs all use atomic instructions FAA (fetch-and-add) to obtain the NextIndex on gList, which can be used as affairs Submission time stab (commit timestamp).When executing reading inquiry operation, if the type of follow-up mechanism is PreadsetOr Pno_readsetAnd the predicate set PredicateSet of affairs at this time is sky, then the affairs need to obtain global transaction Submission index point CommittedIndex in list gList, and (sts) is stabbed as at the beginning of oneself.MOCC is Each affairs safeguard one and write set WriteSet to save the more new data that affairs are not submitted, when affairs enter Qualify Phase When, the pointer comprising its transaction context for writing set WriteSet is added in global transaction list gList.
Refering to attached drawing 2, affairs determine to use follow-up mechanism Pno_readsetSELECT statement is tracked, WHERE in sentence Clause includes two simple conjunctions, so adding two predicates in the predicate set PredicateSet of affairs.It is tracking Mechanism Pno_readsetAnd PreadsetIn, for each affairs, the predicate of both types can be stored in the same predicate collection It closes in PredicateSet.A predicate in the set is considered as the conjunction expression of sentential function, wherein each function describes The range of condition of a column in inquiry.Member in predicate set PredicateSet is configured to triple < type, COLs, set >, wherein type indicates the follow-up mechanism type of the predicate, and COLs scope condition columns and set are that this is looked into The readset of inquiry closes ReadSet.If the follow-up mechanism of predicate p is Pno_readset(i.e. p.type=Pno_readset), then the predicate ReadSet is empty (i.e. p.set=null).Each member column use<col, start, end in COLs>indicate to order It inscribes function " start≤col≤end ", wherein col is the number of target column.
Refering to attached drawing 3, affairs TxFollow-up mechanism R is assigned, therefore, in affairs TxExecute read inquiry when, need by < E, 1>and<F, 1>be added in the readset conjunction ReadSet of oneself;As affairs TxWhen into Qualify Phase, it will call the side LRV1 Method detects transactional conflict, it needs to re-read tuple E and F, and finds that the ts in E is modified by other affairs, this shows Affairs Tx clashes (i.e. affairs T with other affairs4), therefore, affairs Tx should be aborted and rollback.
Refering to attached drawing 4, affairs TyFollow-up mechanism P is assignedno_readset, therefore, affairs TyBy the predicate of query statement < Pno_readset, { id, A, C }, null > be recorded in its privately owned predicate set PredicateSet, into after Qualify Phase, thing Be engaged in TyThe verification method GWV that will be used, it is searched complete using time started stamp (sts=4) and submission time stamp (cts=5) Recently submitted concurrent transaction (i.e. affairs T in office transaction list gList4), then, affairs TyCheck affairs T4Write set WriteSet has found by T4The tuple C of modification is in the range [A, C] of its predicate, and therefore, transacter should also stop And rollback affairs Ty
Refering to attached drawing 5, MOCC can also be by follow-up mechanism PreadsetDistribute to affairs Ty, the type and set of member in predicate With T in attached drawing 4yPredicate in member it is different.After entering Qualify Phase, affairs TyIt can be from LRV2 method and GWV method A kind of verification method is selected to detect and conflict with other concurrent transactions.
In the example child of above-mentioned 3~Fig. 5 of attached drawing, useTo indicate transaction write set in global transaction list gList A record<A, c, o in WriteSet, n>.There are two user's column id and name in table t, and wherein id is primary key column.In table t In, it can be seen that there are six the tuples with continuous major key, and the default initial values of field name and ts are respectively o and 0, need to infuse Meaning, the field ts for con current control is sightless to database user.In this example, affairs Tx, TyAnd T4It is simultaneously Affairs are sent out, wherein affairs T4It is initially completed, which is omitted the write operation of these affairs, clearly to show MOCC The working method of (Mixed workloads using OCC, the Optimistic Concurrency control under hybrid working load).
Refering to attached drawing 6, in read phase, verifying costing analysis is carried out first, if an inquiry operation uses tracing machine R processed verifies cost C then needing to verify using verification method LRV1 required for verification method LRV1lrv1(q)=S1· cr1, as use follow-up mechanism PreadsetWhen carrying out record queries operation q and detect the inquiry using verification method LRV2, Verify cost Clrv2(q)=S2·cr2, follow-up mechanism PreadsetAnd Pno_readsetVerification method GWV be may be by detect one Conflicting between a affairs and its concurrent transaction, the cost C of the verification method GWV of inquiry operation qgwv(q)=NWcp;So Compare the size of three kinds of verifying costs of estimation, the selection verifying the smallest follow-up mechanism of cost afterwards.Own when affairs have executed it Read-write operation after, it will enter Qualify Phase, in Qualify Phase, affairs it needs to be determined that its serialization point and checking that it is The no concurrent transaction generation with before serialization point conflicts.
Refering to attached drawing 7, (the 3rd row and the firstly, affairs need to lock to each record write in set WriteSet 4 rows), in order to avoid deadlock, will successively be locked according to the sequence of its tuple major key to these records.All lock is write when getting Later, affairs will obtain next index point NextIndex from global transaction list gList, and by the pointer of oneself context It is placed at the point.It should be noted that the value for the NextIndex that each affairs is got is unique, and the value With monotonic increase.Therefore, we use the value to stab as the submission time of affairs, that is, the affairs are in all affairs Serialization point.
Next, MOCC (Mixed workloads using OCC, the Optimistic Concurrency control under hybrid working load) will Verifying use follow-up mechanism R all inquiries, affairs t all R inquiry all using the same readset close ReadSet come record with Track information, and follow-up mechanism R uses verification method LRV1.Therefore, MOCC verifies the conjunction of affairs readset using LRV1 method Each of ReadSet element (the 7th -9 row).If verification method LRV1 return result be ABORT, affairs by oneself State be set as ABORT and return.If affairs have successfully passed the verifying that readset closes ReadSet, the affairs will be verified Predicate set PredicateSet, an affairs are to record follow-up mechanism using the same predicate set PredicateSet PreadsetAnd Pno_readsetReading inquiry tracking information.Therefore, for each predicate in predicate set PredicateSet P, MOCC will first check for the tracking type of predicate p.If p.type=Pno_readset, will be tested using verification method GWV Demonstrate,prove the predicate (the 11st -14 row).Specifically, GWV verification method is needed using parameter p, t.sts and (t.cts-1) Lai Shixian, Wherein [t.sts, t.cts-1] indicates the index range of concurrent transaction of the affairs in global transaction list gList.If letter Number GWV verification method returns to ABORT, then affairs set ABORT for the state of oneself and return.If the tracking class of the predicate Type is Preadset(p.type=Preadset), one will be selected from verification method LRV2 and GWV to verify the predicate, in order to drop Low verifying cost needs to compare both methods and selects the verifying lower method of cost.If affairs are smoothly through verifying Stage, then it will enter write phase, at this stage, affairs need for oneself each record write in set WriteSet more Its new data in the database simultaneously discharge corresponding lock.It should be noted that for each record in WriteSet, affairs Lock in corresponding data items can be held always until the data and timestamp field of the record have been updated, finally, affairs by its State is set as COMMITTED.
The statement of the above operating process is only a best possible example in present invention specific implementation, realization of the invention Deployment is not limited to above-mentioned form of presentation, is not intended to limit the invention patent, those skilled in the art can weigh Benefit makes a variety of changes or modifies in the range of requiring, this is not affected the essence of the present invention, all for the equivalent reality of the present invention It applies, is intended to be limited solely by within the scope of the claims of the invention patent.

Claims (1)

1. the optimistic concurrency control method under a kind of hybrid working load, it is characterised in that local readset is used to close verifying and the overall situation Write set verifying integration method, dynamically estimate according to workload and more different verification methods generation verifying cost, The verification method for selecting cost minimum and corresponding follow-up mechanism carry out hybrid working and load lower Optimistic Concurrency control, specifically hold Row process includes following three stages:
(1), the stage is read
A step: tuple is obtained from data set according to the predicate of query statement;
B step: R, P are usedno_readsetAnd PreadsetThe verification method of follow-up mechanism carries out costing analysis, inquires in the R mechanism The search condition of operation, for each tuple of the queried access, obtains the pointer of the tuple in the primary key column of tables of data Tuple, and generation one reading version<tuple, tuple.ts>, the readset for being then added to affairs oneself closes In ReadSet;Use symbol S1Come indicate the inquiry operation be stored in readset close ReadSet in number of tuples, use cr1Expression is tested Card method LRV1 maintenance and the cost for checking a versions of data, if follow-up mechanism R provides service to read inquiry q, For the inquiry operation, verifying cost estimation required for verification method LRV1 is Clrv1(q)=S1·cr1
The Pno_readsetAffairs are oneself one predicate set PredicateSet of maintenance in mechanism, when executing read operation, Affairs can be the query generation predicate and put it into the predicate set PredicateSet of oneself;Use S2And cr2To distinguish Indicate follow-up mechanism PreadsetThe number of tuples and verification method LRV2 for needing to store check the cost of a tuple, track when using Mechanism PreadsetWhen carrying out record queries operation q and detect the inquiry using verification method LRV2, cost estimation is verified For Clrv2(q)=S2·cr2;The Pno_readsetMechanism can detect an affairs and its concurrent transaction using verification method GWV Between conflict;
The PreadsetAffairs need to safeguard a PredicateSet for oneself in mechanism, and when executing read operation, affairs are not It only needs to generate predicate for query statement itself, it is also necessary to close ReadSet using a readset to store the tuple of access, it will The predicate of the query statement and its readset of return close ReadSet and are added in predicate set PredicateSet together;Institute State follow-up mechanism PreadsetConflicting between an affairs and its concurrent transaction can be detected using verification method GWV, for thing Each inquiry operation in business, the cost of verification method GWV and two aspects are in relation to the quantity and each concurrent thing of concurrent transaction The mean size of set WriteSet is write in business, is indicated respectively with N and W, if cpIt indicates to check a predicate and writes set A record whether there is the cost of intersection in WriteSets, and the cost estimation of the verification method GWV of inquiry operation q is Cgwv (q)=NWcp
Step c: the selection estimation the smallest verification method of cost, thus using corresponding follow-up mechanism, for inquiry operation q, such as The cost C of fruit verification method LRV1lrv1(q) minimum, transacter will select R follow-up mechanism for the inquiry operation;If Verify cost Clrv2(q) minimum, then select PreadsetFollow-up mechanism;Otherwise, P is selectedno_readsetFollow-up mechanism;
Step d: the relevant tracking information of affairs start recording;
(2), Qualify Phase
A step: affairs needs lock to each record write in set WriteSet;
B step: all after writing lock when getting, affairs will obtain next index point from global transaction list gList NextIndex, and the pointer of oneself context is placed at the point, the NextIndex value that each affairs is obtained as The submission time of affairs stabs, i.e. serialization point of the affairs in all affairs;
Step c: MOCC uses all inquiries of follow-up mechanism R using the verifying of LRV1 verification method, and the LRV1 is verified as R tracking Mechanism using a kind of local readset closes verification method to verify the readset of affairs and close ReadSet, and affairs are by the tuple of read access And its colophon, into the readset conjunction ReadSet of oneself, when verifying ReadSet, affairs check each tuple in ReadSet Version whether modified by other concurrent transactions, if time for copying when the newest timestamp in tuple is not equal to access tuples Stamp or tuple are locked by another affairs, then return the result ABORT;
Step d: carry out verifying the predicate set PredicateSet of the affairs as follows:
d1: if affairs have successfully passed the verifying that readset closes ReadSet, will verify the predicate set of the affairs PredicateSet, MOCC will first check for the tracking type of predicate p;
d2If: p.type=Pno_readset, the predicate will be verified using verification method GWV, be tested using verification method GWV When demonstrate,proving predicate, affairs T detects the range [sIndex, eIndex] on global transaction list gList, and finds thing in this range Be engaged in T all concurrent transactions, for each concurrent transaction in gList, affairs T check oneself predicate whether with the concurrent thing The each element intersection of business write in set WriteSet, if intersection, returns to ABORT;
d3If: the tracking type of the predicate is Preadset(p.type=Preadset), compare cost Clrv2(p) and Cgwv(p) big It is small, if Clrv2(p) smaller, verification method LRV2 is selected, otherwise selects verification method GWV, the LRV2 that need to re-execute meaning Word closes ReadSet to obtain the newest readset of query statement, then will store in new readset conjunction ReadSet and predicate old Readset closes ReadSet (p.set) and is compared, if same position in of different sizes or the two set of the two set On element it is different, then return to ABORT;
Step e: if affairs have successfully passed all verifyings, which will return the result SUCCESS;(3), write phase
Updating affairs in the database is oneself each record write in set WriteSet, while more new data and discharging phase The lock answered, for each record in WriteSet, affairs can hold always the lock in corresponding data items until the number of the record It has been updated according to timestamp field, its state is set COMMITTED by last affairs.
CN201910757261.0A 2019-08-16 2019-08-16 A kind of optimistic concurrency control method of hybrid working load Pending CN110502525A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910757261.0A CN110502525A (en) 2019-08-16 2019-08-16 A kind of optimistic concurrency control method of hybrid working load

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910757261.0A CN110502525A (en) 2019-08-16 2019-08-16 A kind of optimistic concurrency control method of hybrid working load

Publications (1)

Publication Number Publication Date
CN110502525A true CN110502525A (en) 2019-11-26

Family

ID=68588202

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910757261.0A Pending CN110502525A (en) 2019-08-16 2019-08-16 A kind of optimistic concurrency control method of hybrid working load

Country Status (1)

Country Link
CN (1) CN110502525A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111459920A (en) * 2020-05-15 2020-07-28 北京谷数科技股份有限公司 Multi-version concurrency control method and system based on virtual global clock synchronization
CN111797107A (en) * 2020-07-08 2020-10-20 贵州易鲸捷信息技术有限公司 Database transaction concurrency control method for mixing optimistic lock and pessimistic lock
CN112632105A (en) * 2020-01-17 2021-04-09 华东师范大学 System and method for verifying correctness of large-scale transaction load generation and database isolation level
CN114217978A (en) * 2022-02-21 2022-03-22 在线途游(北京)科技有限公司 Database transaction processing method, system, computing device and computer readable storage medium based on optimistic lock

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101556597A (en) * 2009-03-06 2009-10-14 南京航空航天大学 Self-adaptive optimistic concurrency control method
CN105955801A (en) * 2015-12-21 2016-09-21 上海交通大学 RDMA and HTM based distributed optimistic concurrency control method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101556597A (en) * 2009-03-06 2009-10-14 南京航空航天大学 Self-adaptive optimistic concurrency control method
CN105955801A (en) * 2015-12-21 2016-09-21 上海交通大学 RDMA and HTM based distributed optimistic concurrency control method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
郭进伟等: "Adaptive Optimistic Concurrency Control for Heterogeneous Workloads", 《百度学术》 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112632105A (en) * 2020-01-17 2021-04-09 华东师范大学 System and method for verifying correctness of large-scale transaction load generation and database isolation level
CN111459920A (en) * 2020-05-15 2020-07-28 北京谷数科技股份有限公司 Multi-version concurrency control method and system based on virtual global clock synchronization
CN111459920B (en) * 2020-05-15 2021-01-15 北京谷数科技股份有限公司 Multi-version concurrency control method and system based on virtual global clock synchronization
CN111797107A (en) * 2020-07-08 2020-10-20 贵州易鲸捷信息技术有限公司 Database transaction concurrency control method for mixing optimistic lock and pessimistic lock
CN111797107B (en) * 2020-07-08 2024-02-09 贵州易鲸捷信息技术有限公司 Database transaction concurrency control method for hybrid optimistic lock and pessimistic lock
CN114217978A (en) * 2022-02-21 2022-03-22 在线途游(北京)科技有限公司 Database transaction processing method, system, computing device and computer readable storage medium based on optimistic lock

Similar Documents

Publication Publication Date Title
CN110502525A (en) A kind of optimistic concurrency control method of hybrid working load
EP2191372B1 (en) Parallel nested transactions in transactional memory
US9547685B2 (en) Halloween protection in a multi-version database system
US7962456B2 (en) Parallel nested transactions in transactional memory
US8271464B2 (en) Parallel nested transactions in transactional memory
EP0457473B1 (en) Method for accessing shared data
US20140379658A1 (en) Constraint-based consistency with snapshot isolation
Lomet et al. Using the lock manager to choose timestamps
Davidson Replicated data and partition failures
Kanungo et al. Issues with concurrency control techniques
Ragunathan et al. Speculation-based protocols for improving the performance of read-only transactions
Ragunathan et al. Improving the performance of Read-only Transactions through Speculation
Boukerche et al. T3C: a temporally correct concurrency control algorithm for distributed databases
Graefe Revisiting optimistic and pessimistic concurrency control
Hatia Leveraging formal specification to implement a database backend
Sadoghi et al. Multi-Version Concurrency Revisited
Li Model checking transaction properties for concurrent real-time transactions in UPPAAL
CN114610626A (en) Relational database-oriented transaction isolation automatic testing method and device
Graefe The End of Optimistic Concurrency Control: Why good locking will always win
Cai et al. Concurrency Control and Recovery in OLTP Systems: High Scalability and Availability
Bessani Scaling In-Memory databases on multicores
Özsu et al. Introduction to Transaction Management
Elmagarmid et al. A hierarchical approach to concurrency control for multidatabases
Skarra et al. Semantic Synchronization in a Persistent Object System Library
Madden 6.893 Database Systems, Fall 2004

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20191126

WD01 Invention patent application deemed withdrawn after publication