Commit 645920e8 authored by Julien Muchembled's avatar Julien Muchembled

storage: move the commit at tpc_vote from the backends to the unique caller

parent eaa07e25
...@@ -396,13 +396,18 @@ class DatabaseManager(object): ...@@ -396,13 +396,18 @@ class DatabaseManager(object):
@abstract @abstract
def storeTransaction(self, tid, object_list, transaction, temporary = True): def storeTransaction(self, tid, object_list, transaction, temporary = True):
"""Store a transaction temporarily, if temporary is true. Note """Write transaction metadata
that this transaction is not finished yet. The list of objects
contains tuples, each of which consists of an object ID, The list of objects contains tuples, each of which consists of
a data_id and object serial. an object ID, a data_id and object serial.
The transaction is either None or a tuple of the list of OIDs, The transaction is either None or a tuple of the list of OIDs,
user information, a description, extension information and transaction user information, a description, extension information and transaction
pack state (True for packed).""" pack state (True for packed).
If 'temporary', the transaction is stored into ttrans/tobj tables,
(instead of trans/obj). The caller is in charge of committing, which
is always the case at tpc_vote.
"""
@abstract @abstract
def _pruneData(self, data_id_list): def _pruneData(self, data_id_list):
......
...@@ -465,8 +465,6 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -465,8 +465,6 @@ class MySQLDatabaseManager(DatabaseManager):
q("REPLACE INTO %s VALUES (%s,%s,%s,'%s','%s','%s','%s',%s)" % ( q("REPLACE INTO %s VALUES (%s,%s,%s,'%s','%s','%s','%s',%s)" % (
trans_table, partition, 'NULL' if temporary else tid, packed, trans_table, partition, 'NULL' if temporary else tid, packed,
e(''.join(oid_list)), e(user), e(desc), e(ext), u64(ttid))) e(''.join(oid_list)), e(user), e(desc), e(ext), u64(ttid)))
if temporary:
self.commit()
_structLL = struct.Struct(">LL") _structLL = struct.Struct(">LL")
_unpackLL = _structLL.unpack _unpackLL = _structLL.unpack
......
...@@ -376,8 +376,6 @@ class SQLiteDatabaseManager(DatabaseManager): ...@@ -376,8 +376,6 @@ class SQLiteDatabaseManager(DatabaseManager):
(partition, None if temporary else tid, (partition, None if temporary else tid,
packed, buffer(''.join(oid_list)), packed, buffer(''.join(oid_list)),
buffer(user), buffer(desc), buffer(ext), u64(ttid))) buffer(user), buffer(desc), buffer(ext), u64(ttid)))
if temporary:
self.commit()
def _pruneData(self, data_id_list): def _pruneData(self, data_id_list):
data_id_list = set(data_id_list).difference(self._uncommitted_data) data_id_list = set(data_id_list).difference(self._uncommitted_data)
......
...@@ -174,7 +174,9 @@ class TransactionManager(object): ...@@ -174,7 +174,9 @@ class TransactionManager(object):
txn_info = oid_list, user, desc, ext, False, ttid txn_info = oid_list, user, desc, ext, False, ttid
transaction.has_trans = True transaction.has_trans = True
# store metadata to temporary table # store metadata to temporary table
self._app.dm.storeTransaction(ttid, object_list, txn_info) dm = self._app.dm
dm.storeTransaction(ttid, object_list, txn_info)
dm.commit()
def lock(self, ttid, tid): def lock(self, ttid, tid):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment