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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
745ee2b2
Commit
745ee2b2
authored
Jun 21, 2018
by
Julien Muchembled
2
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):
...
@@ -828,7 +828,7 @@ class DatabaseManager(object):
"""
"""
@
abstract
@
abstract
def
unlockTransaction
(
self
,
tid
,
ttid
):
def
unlockTransaction
(
self
,
tid
,
ttid
,
trans
,
obj
):
"""Finalize a transaction by moving data to a finished area."""
"""Finalize a transaction by moving data to a finished area."""
@
abstract
@
abstract
...
...
neo/storage/database/mysqldb.py
View file @
745ee2b2
...
@@ -705,18 +705,21 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -705,18 +705,21 @@ class MySQLDatabaseManager(DatabaseManager):
%
(
u64
(
tid
),
u64
(
ttid
)))
%
(
u64
(
tid
),
u64
(
ttid
)))
self
.
commit
()
self
.
commit
()
def
unlockTransaction
(
self
,
tid
,
ttid
):
def
unlockTransaction
(
self
,
tid
,
ttid
,
trans
,
obj
):
q
=
self
.
query
q
=
self
.
query
u64
=
util
.
u64
u64
=
util
.
u64
tid
=
u64
(
tid
)
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
)
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"
data_id_list
=
[
x
for
x
,
in
q
(
"SELECT data_id%s AND data_id IS NOT NULL"
%
sql
)]
%
sql
)]
q
(
"INSERT INTO obj SELECT `partition`, oid, %d, data_id, value_tid %s"
q
(
"INSERT INTO obj SELECT `partition`, oid, %d, data_id, value_tid %s"
%
(
tid
,
sql
))
%
(
tid
,
sql
))
q
(
"DELETE"
+
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
)
self
.
releaseData
(
data_id_list
)
def
abortTransaction
(
self
,
ttid
):
def
abortTransaction
(
self
,
ttid
):
...
...
neo/storage/database/sqlite.py
View file @
745ee2b2
...
@@ -470,10 +470,15 @@ class SQLiteDatabaseManager(DatabaseManager):
...
@@ -470,10 +470,15 @@ class SQLiteDatabaseManager(DatabaseManager):
(
u64
(
tid
),
u64
(
ttid
)))
(
u64
(
tid
),
u64
(
ttid
)))
self
.
commit
()
self
.
commit
()
def
unlockTransaction
(
self
,
tid
,
ttid
):
def
unlockTransaction
(
self
,
tid
,
ttid
,
trans
,
obj
):
q
=
self
.
query
q
=
self
.
query
u64
=
util
.
u64
u64
=
util
.
u64
tid
=
u64
(
tid
)
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
)
ttid
=
u64
(
ttid
)
sql
=
" FROM tobj WHERE tid=?"
sql
=
" FROM tobj WHERE tid=?"
data_id_list
=
[
x
for
x
,
in
q
(
"SELECT data_id%s AND data_id IS NOT NULL"
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):
...
@@ -481,8 +486,6 @@ class SQLiteDatabaseManager(DatabaseManager):
q
(
"INSERT INTO obj SELECT partition, oid, ?, data_id, value_tid"
+
sql
,
q
(
"INSERT INTO obj SELECT partition, oid, ?, data_id, value_tid"
+
sql
,
(
tid
,
ttid
))
(
tid
,
ttid
))
q
(
"DELETE"
+
sql
,
(
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
)
self
.
releaseData
(
data_id_list
)
def
abortTransaction
(
self
,
ttid
):
def
abortTransaction
(
self
,
ttid
):
...
...
neo/storage/handlers/initialization.py
View file @
745ee2b2
...
@@ -77,7 +77,7 @@ class InitializationHandler(BaseMasterHandler):
...
@@ -77,7 +77,7 @@ class InitializationHandler(BaseMasterHandler):
def
validateTransaction
(
self
,
conn
,
ttid
,
tid
):
def
validateTransaction
(
self
,
conn
,
ttid
,
tid
):
dm
=
self
.
app
.
dm
dm
=
self
.
app
.
dm
dm
.
lockTransaction
(
tid
,
ttid
)
dm
.
lockTransaction
(
tid
,
ttid
)
dm
.
unlockTransaction
(
tid
,
ttid
)
dm
.
unlockTransaction
(
tid
,
ttid
,
True
,
True
)
dm
.
commit
()
dm
.
commit
()
def
startOperation
(
self
,
conn
,
backup
):
def
startOperation
(
self
,
conn
,
backup
):
...
...
neo/storage/transactions.py
View file @
745ee2b2
...
@@ -314,12 +314,15 @@ class TransactionManager(EventQueue):
...
@@ -314,12 +314,15 @@ class TransactionManager(EventQueue):
Unlock transaction
Unlock transaction
"""
"""
try
:
try
:
t
id
=
self
.
_transaction_dict
[
ttid
].
tid
t
ransaction
=
self
.
_transaction_dict
[
ttid
]
except
KeyError
:
except
KeyError
:
raise
ProtocolError
(
"unknown ttid %s"
%
dump
(
ttid
))
raise
ProtocolError
(
"unknown ttid %s"
%
dump
(
ttid
))
tid
=
transaction
.
tid
logging
.
debug
(
'Unlock TXN %s (ttid=%s)'
,
dump
(
tid
),
dump
(
ttid
))
logging
.
debug
(
'Unlock TXN %s (ttid=%s)'
,
dump
(
tid
),
dump
(
ttid
))
dm
=
self
.
_app
.
dm
dm
=
self
.
_app
.
dm
dm
.
unlockTransaction
(
tid
,
ttid
)
dm
.
unlockTransaction
(
tid
,
ttid
,
transaction
.
voted
==
2
,
Vincent Pelletier
@vpelletier
·
Jun 28, 2018
Owner
A symbolic pseudo-constant instead of a literal would be nicer.
A symbolic pseudo-constant instead of a literal would be nicer.
Julien Muchembled
@jm
·
Jul 13, 2018
Owner
if only it was free
if only it was free
Please
register
or
sign in
to reply
transaction
.
store_dict
)
self
.
_app
.
em
.
setTimeout
(
time
()
+
1
,
dm
.
deferCommit
())
self
.
_app
.
em
.
setTimeout
(
time
()
+
1
,
dm
.
deferCommit
())
self
.
abort
(
ttid
,
even_if_locked
=
True
)
self
.
abort
(
ttid
,
even_if_locked
=
True
)
...
...
neo/tests/storage/testStorageDBTests.py
View file @
745ee2b2
...
@@ -89,7 +89,7 @@ class StorageDBTests(NeoUnitTestBase):
...
@@ -89,7 +89,7 @@ class StorageDBTests(NeoUnitTestBase):
self
.
db
.
lockTransaction
(
tid
,
ttid
)
self
.
db
.
lockTransaction
(
tid
,
ttid
)
yield
yield
if
commit
:
if
commit
:
self
.
db
.
unlockTransaction
(
tid
,
ttid
)
self
.
db
.
unlockTransaction
(
tid
,
ttid
,
True
,
objs
)
self
.
db
.
commit
()
self
.
db
.
commit
()
elif
commit
is
not
None
:
elif
commit
is
not
None
:
self
.
db
.
abortTransaction
(
ttid
)
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