Method and apparatus providing optimistic locking of shared computer resources
First Claim
1. A method of updating a resource object using optimistic locks, the method comprising the computer-implemented steps of:
- receiving from a client process a request to update a particular resource object;
sending to a lock manager process a request for a first lock for access to the particular resource object, the request including data indicating an optimistic lock type;
receiving the first lock for access to the particular resource object, the first lock including data indicating the resource object, the optimistic lock type and a first value for a version number related to a number of changes to the resource object since the lock manager generated a lock data structure corresponding to the resource object; and
updating the resource object by sending to a lock manager process a request for a second lock for access to the particular resource object, the request including data indicating the resource object identification and an exclusive lock type;
receiving the second lock for access to the particular resource object, the second lock including data indicating the resource object identification, the exclusive lock type and a second value for the version number;
determining whether the second value for the version number substantially equals the first value for the version number; and
if the second value substantially equals the first value, then committing an updated resource object to the resource, and replacing the second value for the version number in the second lock with a third value for the version number, the third value computed by adding the second value and a predetermined version change value.
1 Assignment
0 Petitions
Accused Products
Abstract
Techniques for concurrent access to a resource object, such as a database, include generating a lock data structure for a particular resource object. The lock data structure includes data values for a resource object identification, a lock type, and a version number. The version number is related to a number of changes to the resource object since the lock data structure was generated. A request is received from a requesting process. The request is for a requested lock type for access to the particular resource object. It is determined whether to grant the request based on the requested lock type and the lock type in the lock data structure. By carrying a lock version number in a lock data structure managed by a lock manager, improved optimistic locking is provided in a database. In particular, the approach enables introduction of optimistic locking to a legacy database without requiring burdensome changes to a database table schema.
-
Citations
28 Claims
-
1. A method of updating a resource object using optimistic locks, the method comprising the computer-implemented steps of:
-
receiving from a client process a request to update a particular resource object;
sending to a lock manager process a request for a first lock for access to the particular resource object, the request including data indicating an optimistic lock type;
receiving the first lock for access to the particular resource object, the first lock including data indicating the resource object, the optimistic lock type and a first value for a version number related to a number of changes to the resource object since the lock manager generated a lock data structure corresponding to the resource object; and
updating the resource object by sending to a lock manager process a request for a second lock for access to the particular resource object, the request including data indicating the resource object identification and an exclusive lock type;
receiving the second lock for access to the particular resource object, the second lock including data indicating the resource object identification, the exclusive lock type and a second value for the version number;
determining whether the second value for the version number substantially equals the first value for the version number; and
if the second value substantially equals the first value, then committing an updated resource object to the resource, and replacing the second value for the version number in the second lock with a third value for the version number, the third value computed by adding the second value and a predetermined version change value. - View Dependent Claims (2, 3, 4, 5, 6, 7)
-
-
8. A computer-readable medium carrying one or more sequences of instructions for updating a resource object, which instructions, when executed by one or more processors, cause the one or more processors to carry out the steps of:
-
receiving from a client process a request to update a particular resource object;
sending to a lock manager process a request for a first lock for access to the particular resource object, the request including data indicating an optimistic lock type;
receiving the first lock for access to the particular resource object, the first lock including data indicating the resource object, the optimistic lock type and a first value for a version number related to a number of changes to the resource object since the lock manager generated a lock data structure corresponding to the resource object; and
updating the resource object by sending to a lock manager process a request for a second lock for access to the particular resource object, the request including data indicating the resource object identification and an exclusive lock type;
receiving the second lock for access to the particular resource object, the second lock including data indicating the resource object identification, the exclusive lock type and a second value for the version number;
determining whether the second value for the version number substantially equals the first value for the version number, and if the second value substantially equals the first value, then committing an updated resource object to the resource, and replacing the second value for the version number in the second lock with a third value for the version number, the third value computed by adding the second value and a predetermined version change value. - View Dependent Claims (9, 10, 11, 12, 13, 14)
-
-
15. An apparatus for updating a resource object, comprising:
-
a processor;
one or more stored sequences of instructions which, when executed by the processor, cause the processor to carry out the steps of;
receiving from a client process a request to update a particular resource object;
sending to a lock manager process a request for a first lock for access to the particular resource object, the request including data indicating an optimistic lock type, receiving the first lock for access to the particular resource object, the first lock including data indicating the resource object, the optimistic lock type and a first value for a version number related to a number of changes to the resource object since the lock manager generated a lock data structure corresponding to the resource object; and
updating the resource object by sending to a lock manager process a request for a second lock for access to the particular resource object, the request including data indicating the resource object identification and an exclusive lock type;
receiving the second lock for access to the particular resource object, the second lock including data indicating the resource object identification, the exclusive lock type and a second value for the version number, determining whether the second value for the version number substantially equals the first value for the version number, and if the second value substantially equals the first value, then committing an updated resource object to the resource, and replacing the second value for the version number in the second lock with a third value for the version number, the third value computed by adding the second value and a predetermined version change value. - View Dependent Claims (16, 17, 18, 19, 20, 21)
-
-
22. An apparatus for updating a resource object, comprising:
-
a means for receiving from a client process a request to update a particular resource object;
a means for sending to a lock manager process a request for a first lock for access to the particular resource object, the request including data indicating an optimistic lock type;
a means for receiving the first lock for access to the particular resource object, the first lock including data indicating the resource object, the optimistic lock type and a first value for a version number related to a number of changes to the resource object since the lock manager generated a lock data structure corresponding to the resource object; and
a means for updating the resource object, including a means for sending to a lock manager process a request for a second lock for access to the particular resource object, the request including data indicating the resource object identification and an exclusive lock type;
a means for receiving the second lock for access to the particular resource object, the second lock including data indicating the resource object identification, the exclusive lock type and a second value for the version number;
a means for determining whether the second value for the version number substantially equals the first value for the version number;
a means for committing an updated resource object to the resource if the second value substantially equals the first value; and
a means for replacing the second value for the version number in the second lock with a third value for the version number if the second value substantially equals the first value, the third value computed by adding the second value and a predetermined version change value. - View Dependent Claims (23, 24, 25, 26, 27, 28)
-
Specification