Conference PaperPDF Available

Implementing Optimistic Concurrency Control for Persistence Middleware Using Row Version Verification

Authors:

Abstract and Figures

Modern web-based applications are often built as multi-tier architecture using persistence middleware. Middleware technology providers recommend the use of Optimistic Concurrency Control (OCC) mechanism to avoid the risk of blocked resources. However, most vendors of relational database management systems implement only locking schemes for concurrency control. As consequence a kind of OCC has to be implemented at client or middleware side. A simple Row Version Verification (RVV) mechanism has been proposed to implement an OCC at client side. The implementation of RVV depends on the underlying database management system and the specifics of the middleware. For performance reasons the middleware uses buffers (cache) of its own to avoid network traffic and possible disk I/O. This caching however complicates the use of RVV because the data in the middleware cache may be stale (outdated). We investigate various data access technologies, including the new Java Persistence API (JPA) and Microsoft's LINQ technologies for their ability to use the RVV programming discipline. The use of persistence middleware that tries to relieve the programmer from the low level transaction programming turns out to even complicate the situation in some cases. Programmed examples show how to use SQL data access patterns to solve the problem.
Content may be subject to copyright.
Implementing Optimistic Concurrency Control for Persistence Middleware using
Row Version Verification
Martti Laiho
Dpt. of Business Information Technology
Haaga-Helia University of Applied Sciences
FI-00520 Helsinki, Finland
Email: martti.laiho@haaga-helia.fi
Fritz Laux
Fakult¨
at Informatik
Reutlingen University
D-72762 Reutlingen, Germany
Email: fritz.laux@reutlingen-university.de
Abstract—Modern web-based applications are often built as
multi-tier architecture using persistence middleware. Middle-
ware technology providers recommend the use of Optimistic
Concurrency Control (OCC) mechanism to avoid the risk
of blocked resources. However, most vendors of relational
database management systems implement only locking schemes
for concurrency control. As consequence a kind of OCC has
to be implemented at client or middleware side.
A simple Row Version Verification (RVV) mechanism has
been proposed to implement an OCC at client side. For
performance reasons the middleware uses buffers (cache) of
its own to avoid network traffic and possible disk I/O. This
caching however complicates the use of RVV because the
data in the middleware cache may be stale (outdated). We
investigate various data access technologies, including the new
Java Persistence API (JPA) and Microsoft’s LINQ technologies
for their ability to use the RVV programming discipline.
The use of persistence middleware that tries to relieve the
programmer from the low level transaction programming turns
out to even complicate the situation in some cases. Programmed
examples show how to use SQL data access patterns to solve
the problem.
Keywords-persistence middleware; caching; data access pat-
tern; row version verification.
I. INTRODUCTION
With the advent of multi-tier web applications or more
precisely with decentralized and loosely coupled transac-
tional systems OCC has gained new attention. Providers
of enterprise architecture frameworks (like Java Enterprise
Edition (JEE)) and persistence middleware (like object re-
lational mappers) propose to use optimistic concurrency
control to avoid the risk of blocked resources and orphan
locks. Developers face now the situation that they have to
implement a kind of optimistic concurrency control over
the existing concurrency control provided by the DBMS.
In order to help application developers we propose to use
RVV. Lets explain the mechanism shortly: RVV depends on
a technical row version column. Its value is incremented
whenever any data in the row is changed. By checking the
row version, it can be found out if any concurrent transaction
has modified the data meanwhile. If this happened, the
validation fails and the transaction has to abort. If the row
version is still the same, then the transaction may write the
new data. If the row version is cached by the middleware
this could lead to stale data. Therefore, it is necessary to
circumvent the middleware cache for the row version in
order to apply RVV.
Another motivation to use RVV results from the practice
that web applications usually split a user transaction into
several SQL transactions. In this case the database concur-
rency mechanism cannot ensure transactional properties for
the user transaction, but RVV helps to avoid at least the
lost update problem. Consider a typical concurrency scenario
with two users that try to book the same flight online. First,
a list of fights is displayed (step 2, in Figure 1), second, a
certain flight is chosen (step 4), and third, the flight is booked
(step 6). When the second user selects the same flight and
reads the available seats before the first user has updated
the number, a lost update will be produced. This could be
avoided by re-reading the seats in step 6 and compare it with
step 4 before storing the new number.
We consider the RVV discipline as a critical reliability
criterion in web based transactional application develop-
ment. The proper way for applications to meet the RVV
discipline is to strictly follow the SQL data access patterns
presented in Laux and Laiho [2]. This patterns essentially
ensure that the row version is checked before overwriting a
data value. The patterns describe how to deal with different
concurrency schemes of the underlying DBMS and how to
exploit triggers to support RVV from the database side.
In the present paper these data access patterns are applied
to a generic use case and code samples show implementa-
tions for various technologies.
A. Structure of the Paper
After this Introduction, Section II starts with the presen-
tation of a typical use case including SQL statements for
its setup on a relational database. Each of the following
Sections, III (JDBC, .NET), IV (Hibernate, JPA), and V
(MS LINQ) present implementations of RVV using the data
access patterns of [2]. Section VI concludes the paper with
a comparison between these technologies.
2010 Second International Conference on Advances in Databases, Knowledge, and Data Applications
978-0-7695-3981-2/10 $26.00 © 2010 IEEE
DOI 10.1109/DBKDA.2010.25
45
B. Related Work
Optimistic concurrency control (OCC) mechanisms have
been studied already 30 years ago ([3][4][5][6]), but hardly
any commercial DBMS has implemented algorithms of this
type (see Bernstein and Newcomer [7] or Gray and Reuter
[8]) except for MVCC.
In case of MVCC the middleware has to make sure,
that caching is not invalidating the multi-versioning system.
This problem is discussed by Seifert and Scholl [9] who
counteract with a hybrid of invalidation and propagation
message. In Web applications the risk of not properly
terminated transactions is extremely high (users simply click
away). In such cases snapshot data or locks in the case of
a locking protocol are held until (hopefully) some timeout
elapses. This can severely degrade performance.
In order to avoid the above problems the application has to
implement an OCC on top of the database’s locking mech-
anism. Nock ([10], pages 395-404) describes an ”optimistic
lock” pattern based on version information. He points out
that this access pattern does not use locking (despite of its
misleading name) and therefore avoids orphan locks. His
pattern does not address caching.
Adya et al [11] recommend to use the system clock as
blocking-free protocol for global serialization in distributed
database systems. However this approach has to fail if the
resolution is not fine enough to produce unique timestamps
as we proofed for Oracle in [1].
During decades of development in relational database
technologies the programming paradigms in data access
technologies have constantly changed. The two mainstream
schools in object oriented programming today are the Java
camp [12] and the camp of Microsoft’s .NET framework
[13], both providing call-level APIs and Object-Relational
Mappings (ORM) of their own for object persistence. The
problems of using RVV with the older version of Enterprise
Java Beans 2.0 are discussed in [15].
We follow in this paper the object persistence abstrac-
tions of Hoffer, Prescott, and Topi ([14], Chapter 16) and
implement the access patterns at application or middleware
layer. At SQL level we apply patterns B and C from [2] to
different technologies. Pattern B uses a conditional UPDATE
.. WHERE oldRV =RV statement to verify that the old
row version oldRV is still the same as the actual one (RV).
Pattern C consists of a SELECT RV .. statement to re-
read the actual row version, then a programmed validation
(if oldRV =RV then ..) follows, and if the validation was
successful, the UPDATE takes place. The code samples in
the present paper use SQL Server 2008 as DBMS for our
basic use case, since SQL Server provides some interesting
tuning possibilities and can be used by all technologies we
want to present. Examples using DB2 and Oracle can be
found in our full RVV paper [1].
II. A BA SI C USE CA SE SAMPLE
Figure 1 presents a typical user transaction in 6 steps
(phases) containing three SQL transactions like the flight
booking mentioned before plus an optional compensation
step. The ideal isolation levels listed for each SQL trans-
action depends on the concurrency control provided by
the DBMS. The default concurrency control mechanism on
SQL Server is locking (LSCC), but it can alternatively be
configured to use ”snapshot” isolation (MVCC).
For the SQL Server implementation of our use case the
following Transact-SQL commands will be needed:
CREATE TABLE rvv.VersionTest(
id INT NOT NULL PRIMARY KEY (id),
s VARCHAR(20), -- a sample data column
rv ROWVERSION -- incr by SQLServer at row-update
) ;
GO
CREATE VIEW rvv.RvTestList (id,s)) -- for phase 2
AS SELECT id,s FROM rvv.VersionTest ;
GO
CREATE VIEW rvv.RvTest (id,s,rv) --for phases 4 and 6
AS SELECT id,s,CAST(rv AS BIGINT) AS rv
FROM rvv.VersionTest WITH (UPDLOCK) ;
GO
INSERT INTO rvv.RvTest (id,s) VALUES (1,’some text’);
INSERT INTO rvv.RvTest (id,s) VALUES (2,’some text’);
For technical details of the above script the reader is
referred to the SQL Server online documentation [16].
III. BASELINE RVV IMPLEMENTATIONS USING
CAL L-LE VE L API
The first open database call-level interface and de facto
standard for accessing almost any DBMS is the ODBC
API specification which has strongly influenced the data
access technologies since 1992. The current specification
is almost the same as the SQL/CLI standard of ISO SQL.
Many class libraries have been implemented as wrappers
of ODBC and many data access tools can be configured
to access databases using ODBC. Based very much on the
same ideas Sun has introduced the JDBC interface for Java
applications accessing databases. This has become industry
standard in the Java world. Using the previously defined
SQL views for accessing table VersionTest and applying the
RVV discipline, the following sample Java code for Phase 6
(the update phase) of Figure 1 reveals the necessary technical
details:
// *** Phase 6 - UPDATE (Transaction) ***
con.setAutoCommit(false);
// Pattern B update - no need to set isolation level
string sqlCommand = "UPDATE rvv.RvTest " +
"SETs=?"+
"WHERE id = ? AND rv = ? ";
46
Figure 1. Transactions and isolation levels of the sample use case
pstmt = con.prepareStatement(sqlCommand);
pstmt.setString(1, newS);
pstmt.setLong(2, id);
pstmt.setLong(3, oldRv);
int updated = pstmt.executeUpdate();
if (updated != 1) {
throw new Exception("Conflicting row version in the
database! " );
}
pstmt.close();
// Update succeeded -> The application needs to know
the new value of RV
sqlCommand = "SELECT rv FROM rvv.RvTest WHERE id =
?";
pstmt = con.prepareStatement(sqlCommand);
pstmt.setLong(1, id);
ResultSet rs = pstmt.executeQuery();
newRv = rs.getLong(1);
rs.close();
pstmt.close();
con.commit();
In the above, as in all following examples, it is assumed
that the version attribute rv will be maintained by the
database itself, e.g., by a row level trigger. If the database
has no such capability every application itself has to take
care of incrementing the version on every update. If legacy
applications do not follow this convention, they are subject
to lost update.
Every 4-5 years Microsoft has introduced a new data
access technology after ODBC, and in the beginning of
this millennium ADO.NET built on various data providers.
Without going into details of this rich technology we just
show below the phase 6 from our baseline implementation of
RVV using C# language and the native .NET Data Provider
(SqlClient) [17] to access SQL Server 2008:
// Phase 6 - update transaction
txn = cn.BeginTransaction();
cmd.Transaction = txn;
// Pattern B update including reread of rv using
OUTPUT clause of T-SQL:
cmd.CommandText = "UPDATE rvv.RvTest " +
"SET s = @s OUTPUT INSERTED.rv " +
"WHERE id = @id AND rv = @oldRv ";
cmd.Parameters.Clear();
cmd.Parameters.Add("@s", SqlDbType.Char, 20).Value =
newS;
cmd.Parameters.Add("@id", SqlDbType.Int, 5).Value =
id;
cmd.Parameters.Add("@oldRv", SqlDbType.BigInt,
12).Value = oldRv;
long newRv = 0L;
try {newRv = (long) cmd.ExecuteScalar();
txn.Commit();
}
catch (Exception e) {
throw new Exception("Conflicting row version in
database "+ e.Message);
}
47
Figure 2. Hibernate architecture
All the latest versions of the mainstream DBMS systems
can act as servers of Web Services providing light and direct
call-level API to DBMS services. One RVV example of
.NET using Web Services by Soap 1.2 envelopes is given in
[1]. While it will be interesting to study the Web Services
of DB2 and Oracle, the news of the future version of SQL
Server tell that the native XML Web Services of SQL Server
will be replaced by Windows Communication Foundation
(WCF) [18].
IV. RVV IMPLEMENTATIONS USING ORM MIDDLEWARE
Data access patterns solving the impedance mismatch be-
tween relational databases and object-oriented programming
are called Object-Relational Mappers (ORM) [10]. One
widely known ORM technology is the Container Managed
Persistence (CMP) pattern of the Java Persistence API (JPA)
as part of the Java Enterprise Beans 3.0 (EJB3). The JPA
specification assumes the use of ”optimistic locking” [19].
The JPA raised the market for sophisticated persistence
managers providing object-relational mappings, such as
TopLink [20] and Hibernate [21]. Figure 2 shows our
interpretation of the alternatives of the current Hibernate
framework which implements the JPA but also allows full
control over Hibernate’s Core down to JDBC code level,
which we actually need for our RVV implementation when
using Hibernate.
In terms of RVV we are mainly interested in the object
persistence services of ORM frameworks. As an example
of these services Figure 3 presents methods of JPA for
managing persistence of an entity object.
Object properties can be changed only for loaded objects.
This means that only Pattern C (re-SELECT..UPDATE) up-
dates are possible in ORM frameworks. The caching service
of ORM middleware improves performance by buffering
objects, but RVV requires the current row version from the
database and therefore needs to bypass the cache. ORM
frameworks provide automatic ”optimistic locking” services
based on timestamp or version column, but according to the
Figure 3. JPA persistence management
JPA specification these are maintained by the ORM middle-
ware itself (persistence provider) at client-side, so any other
software can bypass the version maintenance. Therefore, the
only generally reliable version control mechanism is the
server-side stamping.
The following Java code sample from our RVV Paper [1]
shows how to avoid stale data from Hibernate’s cache. To
set the isolation level via JDBC we first need to switch to
Hibernate’s core level. Then, the object is reloaded and the
actual newRv is read. The used Pattern C requires repeatable
read or stronger isolation level to ensure that the row version
will not change during validation and execution of the
update. If the validation succeeds the object is updated:
// Phase 6 - "model"
em.clear(); //1) clear EntityManager’s cache for RVV
try {
Session session = (Session)em.getDelegate();
// JPA => Hibernate Core
Connection conn = session.connection(); // =>
JDBC
Transaction tx6 = session.beginTransaction();
conn.setTransactionIsolation(
conn.TRANSACTION_SERIALIZABLE); // Pattern C
RvvEntity re2 = em.find(RvvEntity.class, id);
// reload the object
Long newRv = (Long)re2.getRv(); // read current
row version
if (oldRv.equals(newRv)) {// verifying the
version
re2.setS(s); // update of properties
em.persist(re2); // Pattern C RVV update
tx6.commit();
}else
throw new Exception("StaleObjectState:
oldRv=" + oldRv + " newRv=" + newRv);
}
catch (Exception ex) {
System.out.println("P 6, catched exception: " +
ex);
}
V. RVV IMPLEMENTATION USING LINQ T O SQL
Microsoft’s answer to the ORM frameworks is Language
Integrated Query (LINQ) for the .NET Framework 3.5. The
class libraries of LINQ can be integrated as part of any .NET
language providing developer ”IntelliSense” support during
48
coding time and error checking already at compile-time [22].
So called ”standard query operators” of LINQ can be applied
to different mappings using LINQ providers, such as LINQ
to XML, LINQ to Datasets, LINQ to Objects, and LINQ to
SQL. In the following C# code sample of our use case Phase
6 the object myRow was loaded from the database in Phase
4 and string newS contains a new value entered in Phase
5, and dc is the DataContext object which holds the open
connection to the database. The shaded part of the code is
just a programmed break allowing concurrent processing for
concurrency tests:
// Phase 6
TransactionOptions txOpt = new TransactionOptions();
txOpt.IsolationLevel =
System.Transactions.IsolationLevel.RepeatableRead;
using (TransactionScope txs = new TransactionScope
(TransactionScopeOption.Required, txOpt)) {
try {myRow.S = newS;
// To allow time for concurrent update tests ...
Console.Write("Press ENTER to continue ..");
Console.ReadLine();
dc.SubmitChanges(ConflictMode.FailOnFirstConflict );
txs.Complete();
}
catch (ChangeConflictException e) {
Console.WriteLine("ChangeConflictException: " +
e.Message);
}
catch (Exception e) {
Console.WriteLine("SubmitChanges error: " +
e.Message + ", Source: " + e.Source +
", InnerException: " + e.InnerException);
}
}
At run-time the data access statements of LINQ to SQL are
translated into native SQL which can be traced. The follow-
ing sample test run trace proves that row version verification
is automatic based on Pattern B (Conditional UPDATE) and
LINQ automatically tries to refresh the updated row version
content:
Press ENTER to continue ..
Before pressing the ENTER key the contents of column S in row 1 is updated
in a concurrent Transact-SQL session.
UPDATE [rvv].[RvTestU]
SET [S] = @p3
WHERE ([ID] = @p0) AND ([S] = @p1) AND ([RV] = @p2)
SELECT [t1].[RV]
FROM [rvv].[RvTestU] AS [t1]
WHERE ((@@ROWCOUNT) > 0) AND ([t1].[ID] = @p4)
-- @p0: Input Int (Size = 0; Prec = 0; Scale = 0) [1]
-- @p1: Input NVarChar (Size = 9; Prec = 0; Scale =
0) [TestValue]
-- @p2: Input BigInt (Size = 0; Prec = 0; Scale = 0)
[32001]
-- @p3: Input NVarChar (Size = 7; Prec = 0; Scale =
0) [testing]
-- @p4: Input Int (Size = 0; Prec = 0; Scale = 0) [1]
-- Context: SqlProvider(Sql2005) Model:
AttributedMetaModel Build: 3.5.21022.8
ChangeConflictException: Row not found or changed.
The code shows the use of TransactionScope, the new
transaction programming paradigm of .NET Framework
which does not depend on LINQ. Setting Isolation level
is actually not necessary for the transaction since it uses
Pattern B (Conditional UPDATE), but we want to show that
it can be set programmatically. The test also shows that no
stale data was used in spite of LINQ caching.
VI. CONCLUSION
Table I presents a comparison of the Call-level APIs
and ORM Frameworks with RVV practice in mind. Ma-
jor findings are the differences when applying the access
patterns of [2] for different middleware technologies with
regard to isolation levels, transaction control, caching, and
performance overhead. While we are writing this paper
LINQ to SQL is still at beta phase and currently it turned
out slow in our tests. However, we are impressed about
the built-in ”optimistic concurrency control” as Microsoft
calls it. Microsoft has the advantage of experiences from
the competing technologies. Attributes of LINQ are more
orthogonal than the numerous JPA annotations and its object
caching did not produce side-effects in concurrency control
making LINQ easier to use and manage. It also utilizes
server-side version stamping. With the advanced features
of the framework - as it proves to do things right - this
is a most promising software development extension in the
.NET Framework. The native DBMS for LINQ is currently
SQL Server, but since IBM and Oracle have already shipped
its own ADO.NET data providers, their support for this
technology can be expected.
As an advantage of ORM Frameworks Hoffer et al [14]
lists ”Developers do not need detailed understanding of the
DBMS or the database schema”. We don’t share this view.
Even if we use these higher abstraction frameworks we
need to verify that we understand the low level data access
operations so that our applications are transaction safe. For
example it was necessary to circumvent middleware caches
where possible or when using disconnected data sets we
had to explicitly reread the row version from the database
in repeatable read isolation (access Pattern C). The version
stamping of the ”optimistic locking” should not be handled
at client or middleware side, but on server side to avoid
ignorant applications.
Some comparisons in Table I are still speculative instead
of hard facts. In this respect Table I can be considered as
suggestions for further studies.
REFERENCES
[1] M. Laiho and F. Laux; On Row Version Verifying (RVV)
Data Access Discipline for avoiding Lost Updates, URL:
http://www.DBTechNet.org/papers/RVV Paper 20090605.pdf
(2009, Nov.)
49
Table I
COMPARISON OF CLI APIS AND ORM FRAMEWORKS
CLI APIs ORM Frameworks
Java
Hibernate
ODBC Web Service JDO
JDBC APIs TopLink .NET
ADO.NET JPA LINQ
Access Pattern A yes yes no no
Access Pattern B yes yes no yes
Access Pattern C yes yes yes no
DBMS http: low
Performance overhead low appl.serv: high high high (beta)
OOP Programming labor-intensive yes yes
Persistence SQL SQL middleware service middleware service
Use of native SQL detailed detailed limited limited
– isolation full control full control default full control
– local transaction full control full control TM 1) full control
– global transaction (ADO.NET) difficult TM 1) implicit 2)
2nd level caching yes
Optimistic Locking RVV RVV configurable built-in
Version stamping (default) client-side server-side
1) using Transaction Manager (TM), 2) using TransactionScope
[2] F. Laux and M. Laiho; SQL Access Patterns for Optimistic
Concurrency Control, The First International Conferences
on Pervasive Patterns and Applications (PATTERNS 2009),
November 15-20, 2009 - Athens/Glyfada, Greece
[3] H. T. Kung and J. T. Robinson; On Optimistic Methods
for Concurrency Control, In ACM Transactions on Database
Systems (TODS) 6(2), 1981, pp. 213-226
[4] D. Z. Badal; Correctness of Concurrency Control and Im-
plications in Distributed Databases. In Proc. COMPSAC79,
Chicago, 1979
[5] G. Schlageter; Optimistic Methods for Concurrency Control
in Distributed Database Systems. In Proceedings of the 7th
VLDB, Cannes, 1981, pp.125-130
[6] R. Unland, U. Pr¨
adel, and G. Schlageter; Ideas on Optimistic
Concurrency Control I: On the Integration of Timestamps into
Optimistic Concurrency Control Methods and A New Solution
for the Starvation Problem in Optimistic Concurrency Con-
trol. In: Informatik Fachbericht; FernUniversit¨
at Hagen, Nr.
26. 1982
[7] Ph. Bernstein and E. Newcomer; Principles of Transaction
Processing, Morgan Kaufmann, 1997
[8] J. Gray and A. Reuter; Transaction Processing: Concepts and
Techniques, Morgan Kaufmann, 1993
[9] A. Seifert and M. H. Scholl; A Multi-version Cache Re-
placement and Prefetching Policy for Hybrid Data Delivery
Environments, Proceedings of the 28th VLDB Conference,
Hong Kong, China, 2002
[10] C. Nock; Data Access Patterns, Addison-Wesley, 2004
[11] A. Adya, R. Gruber, B. Liskov, and U. Maheshwari; Efficient
Optimistic Concurrency Control Using Loosely Synchronized
Clocks, ACM SIGMOD Record, Volume 24 , Issue 2 (May
1995), pp 23 - 34, ISSN: 0163-5808
[12] E. Jendrock, J. Ball, D. Carson, I. Evans, S. Fordin,
and K. Haase; The Java EE 5 Tutorial, URL: http://
java.sun.com/javaee/5/docs/tutorial/doc/sjsaseej2eet.html
(2008, Oct.)
[13] N.N.; .NET Framework 3.5, msdn .NET Framework
Developer Center, URL: http://msdn.microsoft.com/ en-
us/library/w0x726c2.aspx (2009. Nov.)
[14] J. A. Hoffer, M. B. Prescott, and H. Topi; Modern Database
Management, 9th ed., Pearson Prentice-Hall, 2009
[15] M. Laiho and F. Laux; Data Access using RVV Discipline
and Persistence Middleware, eRA-3, 2008, Aegina/Greece
[16] N.N.; SQL Server Books Online, msdn SQL Server Devel-
oper Center, URL: http://msdn. microsoft.com/en-gb/library/
ms130214.aspx (2009, Nov.)
[17] N.N.; SQL Server and ADO.NET, msdn Visual Stu-
dio Developer Center, URL: http://msdn.microsoft.com/en-
us/library/kb9s9ks0.aspx (2009, Oct.)
[18] N.N.; Native XML Web Services: Deprecated in SQL
Server 2008, msdn SQL Server Developer Center, URL:
http://msdn.microsoft.com/en-us/library/cc280436.aspx
(2009, Nov.)
[19] L. DeMichiel and M. Keith; JSR 220: Enterprise
JavaBeansTM, Version 3.0, Java Persistence API , Final
Release, 8 May 2006, URL: http://jcp.org/aboutJava/
communityprocess/final/jsr220/ (2009, Nov.)
[20] Oracle; TopLink Developers Guide 10g (10.1.3.1.0), B28218-
01, September 2006
[21] C. Bauer and G. King; Java Persistence with Hibernate,
Manning, 2007
[22] S. Klein; Professional LINQ, Wiley Publishing, 2008
50
... HTTP offers ETags [17] in response to allow caching of results, and ETags can be used for validating a step in a transaction. ETags are very similar to the RVV concept [27] or Multi-Version Concurrency Control (MVCC), successfully used in PostgreSQL [28], SQL server [29], Oracle etc. to provide optimistic execution. In fact the ETag can coincide with the RVV validator for requests that return only one row of a base table. ...
... The RVV protocol is a type of version control mechanism, which can be used for a form of optimistic concurrency control, alongside or in preference to other versioning measures such as MVCC. The model implementations of RVV in the Laiho/Laux paper [27] envisage a sequence generator to ensure uniqueness of RVV values, so that new values of this sequence are added as a special row-version column in base tables on each INSERT or UPDATE. Some Database Management Systems (DBMSs) include row versioning mechanisms that can be used for this. ...
... If the RVV model of Laiho/Laux [27] is extended in this way it can be used to validate the results of join queries, or more complex selections where a row in the selection embeds values from rows of other tables. ...
Preprint
Full-text available
Data Integration of heterogeneous data sources relies either on periodically transferring large amounts of data to a physical Data Warehouse or retrieving data from the sources on request only. The latter results in the creation of what is referred to as a virtual Data Warehouse, which is preferable when the use of the latest data is paramount. However, the downside is that it adds network traffic and suffers from performance degradation when the amount of data is high. In this paper, we propose the use of a readCheck validator to ensure the timeliness of the queried data and reduced data traffic. It is further shown that the readCheck allows transactions to update data in the data sources obeying full Atomicity, Consistency, Isolation, and Durability (ACID) properties.
... HTTP offers ETags [17] in response to allow caching of results, and ETags can be used for validating a step in a transaction. ETags are very similar to the RVV concept [27] or Multi-Version Concurrency Control (MVCC), successfully used in PostgreSQL [28], SQL server [29], Oracle etc. to provide optimistic execution. In fact the ETag can coincide with the RVV validator for requests that return only one row of a base table. ...
... The RVV protocol is a type of version control mechanism, which can be used for a form of optimistic concurrency control, alongside or in preference to other versioning measures such as MVCC. The model implementations of RVV in the Laiho/Laux paper [27] envisage a sequence generator to ensure uniqueness of RVV values, so that new values of this sequence are added as a special row-version column in base tables on each INSERT or UPDATE. Some Database Management Systems (DBMSs) include row versioning mechanisms that can be used for this. ...
... If the RVV model of Laiho/Laux [27] is extended in this way it can be used to validate the results of join queries, or more complex selections where a row in the selection embeds values from rows of other tables. ...
Conference Paper
Full-text available
Data Integration of heterogeneous data sources relies either on periodically transferring large amounts of data to a physical Data Warehouse or retrieving data from the sources on request only. The latter results in the creation of what is referred to as a virtual Data Warehouse, which is preferable when the use of the latest data is paramount. However, the downside is that it adds network traffic and suffers from performance degradation when the amount of data is high. In this paper, we propose the use of a readCheck validator to ensure the timeliness of the queried data and reduced data traffic. It is further shown that the readCheck allows transactions to update data in the data sources obeying full Atomicity, Consistency, Isolation, and Durability (ACID) properties.
... In this paper we look at the application development from the Online Transaction Processing (OLTP) point of view, and especially on the modern mainstream commercial DBMS used by industry , namely DB2, Oracle, and SQL Server, with ISO SQL standard as the common denominator. The ideas described here are extensions of the work first presented in [1]. A cornerstone of data management is the proper transaction processing, and a generally accepted requirement for reliable flat SQL transactions is the ACID transaction model defined by Haerder and Reuter [2]. ...
... Developers face now the situation that they have to implement a kind of optimistic concurrency control over the existing concurrency control provided by the DBMS. But shifting the burden to the middleware or application is a tricky task [1]. First, there is a need to distinguish between business/user transaction and SQL transaction. ...
Article
Full-text available
Modern web-based applications are often built as multi-tier architecture using persistence middleware. Middle- ware technology providers recommend the use of Optimistic Concurrency Control (OCC) mechanism to avoid the risk of blocked resources. However, most vendors of relational database management systems implement only locking schemes for concurrency control. As a consequence a kind of OCC has to be implemented at client or middleware side. The aim of this paper is to recommend Row Version Verification (RVV) as a mean to realize an OCC at the middleware level. To help the developers with the implementation of RVV we propose to use SQL access patterns. For performance reasons the middleware uses buffers (cache) of its own to avoid network traffic and to reduce disk I/O. This caching, however, complicates the use of RVV because the data in the middleware cache may be stale (outdated). We investigate various data access technologies, including the Java Persistence API and Microsoft's LINQ technologies in combination with commercial database systems for their ability to use the RVV programming discipline. The use of persistence middleware that tries to relieve the programmer from the low level transaction programming turns out to even complicate the situation in some cases. The contribution of this paper are patterns and guidelines for an implementation of OCC at the middleware layer using RVV. Our approach prevents from inconsistencies, reduces locking to a minimum, considers a couple of mainstream tech- nologies, and copes with the effects of concurrency protocols, data access technologies, and caching mechanisms.
... commutative semantics). Laiho and Laux [10] also developed a method of using row-versioning to ensure correct non-blocking operation of distributed applications. Both these approaches require changes to the application protocols, but they can be used with existing commercial DBMS products. ...
Preprint
Full-text available
At DBKDA 2019, we demonstrated that StrongDBMS with simple but rigorous optimistic algorithms, provides better performance in situations of high concurrency than major commercial database management systems (DBMS). The demonstration was convincing but the reasons for its success were not fully analysed. There is a brief account of the results below. In this short contribution, we wish to discuss the reasons for the results. The analysis leads to a strong criticism of all DBMS algorithms based on locking, and based on these results, it is not fanciful to suggest that it is time to re-engineer existing DBMS.
... commutative semantics). Laiho and Laux [10] also developed a method of using row-versioning to ensure correct non-blocking operation of distributed applications. Both these approaches require changes to the application protocols, but they can be used with existing commercial DBMS products. ...
Conference Paper
Full-text available
At DBKDA 2019, we demonstrated that StrongDBMS with simple but rigorous optimistic algorithms, provides better performance in situations of high concurrency than major commercial database management systems (DBMS). The demonstration was convincing but the reasons for its success were not fully analysed. There is a brief account of the results below. In this short contribution, we wish to discuss the reasons for the results. The analysis leads to a strong criticism of all DBMS algorithms based on locking, and based on these results, it is not fanciful to suggest that it is time to re-engineer existing DBMS.
... The PyrrhoDB [19] is the only database we are aware of that implements OCC as CC mechanism . Laiho and Laux [20] thoroughly analysed Row Version Verification (RVV) as an implementation of OCC within a disconnected architecture and their work provides, beside a detailed discussion, patterns to implement RVV for a couple of common databases and data access technologies at the MW layer. Fekete et al. [21] also pointed out that an integration of underlying short transactions and complex transactions is important, and mechanisms to ensure consistency without the need to lock data are required. ...
Conference Paper
Full-text available
This work presents a disconnected transaction model able to cope with the increased complexity of long-living, hierarchically structured, and disconnected transactions. We combine an Open and Closed Nested Transaction Model with Optimistic Concurrency Control and interrelate flat transactions with the aforementioned complex nature. Despite temporary inconsistencies during a transaction's execution our model ensures consistency.
Article
Recently, mobile computing has changed the way that spatial data and GIS are processed. Unlike wired and stand-alone GIS, now the trend has been switched from offline to real-time data processing using location aware services, such as GPS technology. The increased usage of location aware services in multiuser real-time environment has made transaction management incredibly significant. If the simultaneous query operations on the same data item are not handled intelligently then this results in data inconsistency issue. Concurrency control protocol is one of the primary aspects that helps in overcoming this issue a in multiuser environment. To the best of our knowledge, the impact of technological advancements on concurrency control has not been thoroughly studied in the literature. In this article, we explored the literature on concurrency control algorithms in depth with respect to real-time applications and the applications with moving objects. We defined a taxonomy of concurrency control solutions and assessed the maturity of these solutions in the light of characteristics of real-time and mobile environment. We compared the most recent developments made in the literature and presented meaningful insights. Challenges are also identified and discussed, which can assist in doing research in this domain in future.
Article
Full-text available
Transaction processing is of growing importance for mobile and web applications. Booking tickets, flight reservation, e-Banking, e-Payment, and booking holiday arrangements are just a few examples. Due to temporarily disconnected situations the synchronisation and consistent transaction processing are key issues. To avoid difficulties with blocked transactions or communication loss several authors and technology providers have recommended to use Optimistic Concurrency Control (OCC) to solve the problem. However most vendors of Relational Database Management Systems (DBMS) implemented only locking schemes for concurrency control which prohibit the immediate use of OCC.We propose Row Version Verifying (RVV) discipline to avoid lost updates and achieve a kind of OCC for those DBMS not providing an adequate non-blocking concurrency control. Moreover, the different mechanisms are categorized as access pattern in order to provide programmers with a general guideline for SQL databases. The proposed SQL access patterns are relevant for all transactional applications with unreliable communication and low conflicting situations.We demonstrate the proposed solution using mainstream database systems like Oracle, DB2, and SQLServer.
Article
From the Publisher:25 proven patterns for improving data access and application performance Efficient, high-quality data access code is crucial to the performance and usability of virtually any enterprise application--and there's no better way to improve an existing system than to optimize its data access code. Regardless of database engine, platform, language, orapplication, developers repeatedly encounter the same relational database access challenges. In Data Access Patterns, Clifton Nock identifies 25 proven solutions, presenting each one in the form of a clear, easy-to-use pattern. These patterns solve an exceptionally wide range of problems including creating efficient database-independent applications, hiding obscure database semantics from users, speeding database resource initialization, simplifying development and maintenance, improving support for concurrency and transactions, and eliminating data access bottlenecks. Every pattern is illustrated with fully commented Java/JDBC code examples, as well as UML diagrams representing interfaces, classes, and relationships. The patterns are organized into five categories: Decoupling Patterns: Build cleaner, more reliable systems by decoupling data access code from other application logic Resource Patterns: Manage relational database resources more efficiently Input/Output Patterns: Simplify I/O operations by translating consistently between "physical" relational data and domain object representations of that data Cache Patterns: Use caching strategically, to optimize the tradeoffs between data access optimization and cache overhead Concurrency Patterns: Implement concurrencyand transactions more effectively and reliably Data Access Patterns demystifies techniques that have traditionally been used only in the most robust data access solutions--making those techniques practical for every software developer, architect, and designer.
Conference Paper
This paper introduces MICP, a novel multi- version integrated cache replacement and prefetching algorithm designed for efficient cache and transaction management in hybrid data delivery networks. MICP takes into account the dynamically and sporadically changing cost/benefit ratios of cached and/or disseminated object versions by making cache replacement and prefetching decisions sensitive to the objects' access probabilities, their position in the broadcast cycle, and their update frequency. Additionally, to eliminate the issue of a newly created or outdated, but re-cacheable, object version replacing a version that may not be re- acquired from the server, MICP logically divides the client cache into two variable-sized partitions, namely the REC and the NON-REC partitions for maintaining re-cacheable and non- re-cacheable object versions, respectively. Besides judiciously selecting replacement victims, MICP selectively prefetches popular object versions from the broadcast channel in order to further improve transaction response time. A simulation study compares MICP with one offline and two online cache replacement and prefetching algorithms. Performance results for the workloads and system settings considered demonstrate that MICP improves transaction throughput rates by about 18.9% compared to the best performing online algorithm and it performs
Conference Paper
Recently, methods for concurrency control have been proposed which were called "optimistic". These methods do not consider access conflicts when they occur; instead, a transaction always proceeds, and at its end a check is performed whether a conflict has happened. If so, the transaction is backed up. This basic approach is investigated in two directions: First, a method is developed which frees read transactions from any consideration of concurrency control; all responsibility for correct synchronization is assigned to the update transactions. This method, has the great advantage that, in case of conflicts between read transactions and update transactions, no backup is performed. Then, the application of optimistic solutions in distributed database systems is discussed, a solution is presented.
Article
Most current approaches to concurrency control in database systems rely on locking of data objects as a control mechanism. In this paper, two families of non-locking concurrency controls are presented. The methods used are "optimistic" in the sense that they rely mainly on transaction backup as a control mechanism, "hoping" that conflicts between transactions will not occur. Applications where these methods should be more efficient than locking are discussed.
Article
This paper describes an efficient optimistic concurrency control scheme for use in distributed database systems in which objects are cached and manipulated at client machines while persistent storage and transactional support are provided by servers. The scheme provides both serializability and external consistency for committed transactions; it uses loosely synchronized clocks to achieve global serialization. It stores only a single version of each object, and avoids maintaining any concurrency control information on a perobject basis; instead, it tracks recent invalidations on a per-client basis, an approach that has low in-memory space overhead and no per-object disk overhead. In addition to its low space overheads, the scheme also performs well. The paper presents a simulation study that compares the scheme to adaptive callback locking, the best concurrency control scheme for client-server object-oriented database systems studied to date. The study shows that our scheme outperforms...