Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
745ee2b2
Commit
745ee2b2
authored
Jun 21, 2018
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: skip useless work when unlocking transactions
parent
67df59ad
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
11 deletions
+20
-11
neo/storage/database/manager.py
neo/storage/database/manager.py
+1
-1
neo/storage/database/mysqldb.py
neo/storage/database/mysqldb.py
+6
-3
neo/storage/database/sqlite.py
neo/storage/database/sqlite.py
+6
-3
neo/storage/handlers/initialization.py
neo/storage/handlers/initialization.py
+1
-1
neo/storage/transactions.py
neo/storage/transactions.py
+5
-2
neo/tests/storage/testStorageDBTests.py
neo/tests/storage/testStorageDBTests.py
+1
-1
No files found.
neo/storage/database/manager.py
View file @
745ee2b2
...
...
@@ -828,7 +828,7 @@ class DatabaseManager(object):
"""
@
abstract
def
unlockTransaction
(
self
,
tid
,
ttid
):
def
unlockTransaction
(
self
,
tid
,
ttid
,
trans
,
obj
):
"""Finalize a transaction by moving data to a finished area."""
@
abstract
...
...
neo/storage/database/mysqldb.py
View file @
745ee2b2
...
...
@@ -705,18 +705,21 @@ class MySQLDatabaseManager(DatabaseManager):
%
(
u64
(
tid
),
u64
(
ttid
)))
self
.
commit
()
def
unlockTransaction
(
self
,
tid
,
ttid
):
def
unlockTransaction
(
self
,
tid
,
ttid
,
trans
,
obj
):
q
=
self
.
query
u64
=
util
.
u64
tid
=
u64
(
tid
)
if
trans
:
q
(
"INSERT INTO trans SELECT * FROM ttrans WHERE tid=%d"
%
tid
)
q
(
"DELETE FROM ttrans WHERE tid=%d"
%
tid
)
if
not
obj
:
return
sql
=
" FROM tobj WHERE tid=%d"
%
u64
(
ttid
)
data_id_list
=
[
x
for
x
,
in
q
(
"SELECT data_id%s AND data_id IS NOT NULL"
%
sql
)]
q
(
"INSERT INTO obj SELECT `partition`, oid, %d, data_id, value_tid %s"
%
(
tid
,
sql
))
q
(
"DELETE"
+
sql
)
q
(
"INSERT INTO trans SELECT * FROM ttrans WHERE tid=%d"
%
tid
)
q
(
"DELETE FROM ttrans WHERE tid=%d"
%
tid
)
self
.
releaseData
(
data_id_list
)
def
abortTransaction
(
self
,
ttid
):
...
...
neo/storage/database/sqlite.py
View file @
745ee2b2
...
...
@@ -470,10 +470,15 @@ class SQLiteDatabaseManager(DatabaseManager):
(
u64
(
tid
),
u64
(
ttid
)))
self
.
commit
()
def
unlockTransaction
(
self
,
tid
,
ttid
):
def
unlockTransaction
(
self
,
tid
,
ttid
,
trans
,
obj
):
q
=
self
.
query
u64
=
util
.
u64
tid
=
u64
(
tid
)
if
trans
:
q
(
"INSERT INTO trans SELECT * FROM ttrans WHERE tid=?"
,
(
tid
,))
q
(
"DELETE FROM ttrans WHERE tid=?"
,
(
tid
,))
if
not
obj
:
return
ttid
=
u64
(
ttid
)
sql
=
" FROM tobj WHERE tid=?"
data_id_list
=
[
x
for
x
,
in
q
(
"SELECT data_id%s AND data_id IS NOT NULL"
...
...
@@ -481,8 +486,6 @@ class SQLiteDatabaseManager(DatabaseManager):
q
(
"INSERT INTO obj SELECT partition, oid, ?, data_id, value_tid"
+
sql
,
(
tid
,
ttid
))
q
(
"DELETE"
+
sql
,
(
ttid
,))
q
(
"INSERT INTO trans SELECT * FROM ttrans WHERE tid=?"
,
(
tid
,))
q
(
"DELETE FROM ttrans WHERE tid=?"
,
(
tid
,))
self
.
releaseData
(
data_id_list
)
def
abortTransaction
(
self
,
ttid
):
...
...
neo/storage/handlers/initialization.py
View file @
745ee2b2
...
...
@@ -77,7 +77,7 @@ class InitializationHandler(BaseMasterHandler):
def
validateTransaction
(
self
,
conn
,
ttid
,
tid
):
dm
=
self
.
app
.
dm
dm
.
lockTransaction
(
tid
,
ttid
)
dm
.
unlockTransaction
(
tid
,
ttid
)
dm
.
unlockTransaction
(
tid
,
ttid
,
True
,
True
)
dm
.
commit
()
def
startOperation
(
self
,
conn
,
backup
):
...
...
neo/storage/transactions.py
View file @
745ee2b2
...
...
@@ -314,12 +314,15 @@ class TransactionManager(EventQueue):
Unlock transaction
"""
try
:
t
id
=
self
.
_transaction_dict
[
ttid
].
tid
t
ransaction
=
self
.
_transaction_dict
[
ttid
]
except
KeyError
:
raise
ProtocolError
(
"unknown ttid %s"
%
dump
(
ttid
))
tid
=
transaction
.
tid
logging
.
debug
(
'Unlock TXN %s (ttid=%s)'
,
dump
(
tid
),
dump
(
ttid
))
dm
=
self
.
_app
.
dm
dm
.
unlockTransaction
(
tid
,
ttid
)
dm
.
unlockTransaction
(
tid
,
ttid
,
transaction
.
voted
==
2
,
transaction
.
store_dict
)
self
.
_app
.
em
.
setTimeout
(
time
()
+
1
,
dm
.
deferCommit
())
self
.
abort
(
ttid
,
even_if_locked
=
True
)
...
...
neo/tests/storage/testStorageDBTests.py
View file @
745ee2b2
...
...
@@ -89,7 +89,7 @@ class StorageDBTests(NeoUnitTestBase):
self
.
db
.
lockTransaction
(
tid
,
ttid
)
yield
if
commit
:
self
.
db
.
unlockTransaction
(
tid
,
ttid
)
self
.
db
.
unlockTransaction
(
tid
,
ttid
,
True
,
objs
)
self
.
db
.
commit
()
elif
commit
is
not
None
:
self
.
db
.
abortTransaction
(
ttid
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment