Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
W
website
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
84
Issues
84
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Video AG Infrastruktur
website
Commits
68509e96
Commit
68509e96
authored
Jan 15, 2018
by
Andreas Valder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed db wraper to always retry transactions for mysql
parent
eda64713
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
db.py
db.py
+9
-1
jobs.py
jobs.py
+2
-2
No files found.
db.py
View file @
68509e96
...
...
@@ -67,7 +67,15 @@ elif config['DB_ENGINE'] == 'mysql':
else
:
db
=
mysql
.
connector
.
connect
(
user
=
config
[
'MYSQL_USER'
],
password
=
config
[
'MYSQL_PASSWD'
],
unix_socket
=
config
.
get
(
'MYSQL_UNIX'
,
None
))
cur
=
db
.
cursor
()
cur
.
execute
(
operation
)
tries
=
0
while
(
tries
<
10
):
try
:
cur
.
execute
(
operation
)
except
mysql
.
connector
.
errors
.
InternalError
as
e
:
if
e
.
msg
==
'Deadlock found when trying to get lock; try restarting transaction'
:
tries
+=
1
else
:
raise
rows
=
[]
try
:
rows
=
cur
.
fetchall
()
...
...
jobs.py
View file @
68509e96
...
...
@@ -155,10 +155,10 @@ def jobs_schedule(hostname):
return
'no jobs'
,
503
modify
(
'UPDATE jobs SET state="scheduled", worker = ?, time_scheduled = ? WHERE id = ?'
,
hostname
,
datetime
.
now
(),
job
[
'id'
])
query
(
"COMMIT"
)
except
OperationalError
:
except
:
tries
+=
1
job
=
None
sleep
(
random
.
rand
inti
(
0
,
50
))
sleep
(
random
.
rand
om
(
))
if
tries
>
10
:
return
'no jobs'
,
503
...
...
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