Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wj-datacenter-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jinan
wj-datacenter-platform
Commits
d34dcb95
Commit
d34dcb95
authored
Feb 24, 2025
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 添加死锁重试机制
parent
37936b9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
DataProcessServiceImpl.java
...wanji/datacenter/service/impl/DataProcessServiceImpl.java
+19
-2
No files found.
wj-datacenter-service/src/main/java/net/wanji/datacenter/service/impl/DataProcessServiceImpl.java
View file @
d34dcb95
package
net
.
wanji
.
datacenter
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.common.utils.tool.BeanListUtils
;
import
net.wanji.databus.dao.mapper.*
;
...
...
@@ -14,6 +15,7 @@ import net.wanji.datacenter.pojo.dto.CrossPeriodLaneDTO;
import
net.wanji.datacenter.pojo.dto.CrossPeriodTurnDTO
;
import
net.wanji.datacenter.pojo.po.EventInfoPO
;
import
net.wanji.datacenter.service.DataProcessService
;
import
org.apache.ignite.transactions.TransactionRollbackException
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -154,16 +156,31 @@ public class DataProcessServiceImpl implements DataProcessService {
}
}
p
rivate
void
insertTrafficIndexForEventInfo
(
List
<
CrossDataRealtimePO
>
eventList
)
{
p
ublic
void
insertTrafficIndexForEventInfo
(
List
<
CrossDataRealtimePO
>
eventList
)
{
if
(!
CollectionUtils
.
isEmpty
(
eventList
))
{
for
(
CrossDataRealtimePO
crossDataRealtimePO
:
eventList
)
{
try
{
int
retryCount
=
0
;
String
crossId
=
crossDataRealtimePO
.
getCrossId
();
EventInfoPO
eventInfoPO
=
eventInfoMapper
.
selectLastEventInfo
(
crossId
);
if
(
Objects
.
nonNull
(
eventInfoPO
))
{
Double
trafficIndex
=
crossDataRealtimePO
.
getTrafficIndex
();
eventInfoPO
.
setTrafficIndex
(
trafficIndex
);
eventInfoMapper
.
updateOne
(
eventInfoPO
);
while
(
retryCount
<=
3
)
{
try
{
eventInfoMapper
.
updateOne
(
eventInfoPO
);
return
;
}
catch
(
TransactionRollbackException
e
)
{
retryCount
++;
log
.
warn
(
"检测到死锁,进行第 {} 次重试"
,
retryCount
);
try
{
// 等待一会,避免立刻冲突
Thread
.
sleep
(
100
);
}
catch
(
InterruptedException
ignored
)
{
log
.
warn
(
"检测到死锁, Thread.sleep 100ms,异常:{}"
,
ignored
);
}
}
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"路口周期数据插入时间交通指数失败:{}"
,
e
);
...
...
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