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
Carlos Ramos Carreño
neoppod
Commits
ee6e413e
Commit
ee6e413e
authored
Feb 07, 2024
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
master: prevent importing transaction with invalid TID
Else it leads to DB corruption and a crash of the master.
parent
9f5e14f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
neo/master/transactions.py
neo/master/transactions.py
+4
-1
neo/tests/threaded/test.py
neo/tests/threaded/test.py
+17
-0
No files found.
neo/master/transactions.py
View file @
ee6e413e
...
...
@@ -282,11 +282,14 @@ class TransactionManager(EventQueue):
if
tid
is
None
:
# No TID requested, generate a temporary one
tid
=
self
.
_nextTID
()
elif
tid
<=
self
.
_last_tid
:
raise
ProtocolError
(
"new TID must be greater than the last committed one"
)
else
:
# Use of specific TID requested, queue it immediately and update
# last TID.
self
.
_queue
.
append
(
tid
)
self
.
setLastTID
(
tid
)
self
.
_last_tid
=
tid
txn
=
self
.
_ttid_dict
[
tid
]
=
Transaction
(
node
,
storage_readiness
,
tid
)
logging
.
debug
(
'Begin %s'
,
txn
)
return
tid
...
...
neo/tests/threaded/test.py
View file @
ee6e413e
...
...
@@ -2864,6 +2864,23 @@ class Test(NEOThreadedTest):
self
.
assertRaises
(
RuntimeError
,
cluster
.
neoctl
.
setClusterState
,
ClusterStates
.
STARTING_BACKUP
)
@
with_cluster
()
def
testTpcBeginWithInvalidTID
(
self
,
cluster
):
storage
=
cluster
.
getZODBStorage
()
txn
=
transaction
.
Transaction
()
storage
.
tpc_begin
(
txn
)
storage
.
store
(
ZERO_OID
,
None
,
'foo'
,
''
,
txn
)
storage
.
tpc_vote
(
txn
)
tid
=
storage
.
tpc_finish
(
txn
)
self
.
assertRaises
(
NEOStorageError
,
storage
.
tpc_begin
,
transaction
.
Transaction
(),
tid
)
new_tid
=
add64
(
tid
,
1
)
txn
=
transaction
.
Transaction
()
storage
.
tpc_begin
(
txn
,
new_tid
)
storage
.
store
(
ZERO_OID
,
tid
,
'bar'
,
''
,
txn
)
storage
.
tpc_vote
(
txn
)
self
.
assertEqual
(
add64
(
tid
,
1
),
storage
.
tpc_finish
(
txn
))
if
__name__
==
"__main__"
:
unittest
.
main
()
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