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
674d6973
Commit
674d6973
authored
Apr 16, 2025
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 事件修改逻辑添加死锁重试
parent
90f35b99
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletion
+18
-1
EventDataServiceImpl.java
...va/net/wanji/datacenter/service/EventDataServiceImpl.java
+18
-1
No files found.
wj-datacenter-service/src/main/java/net/wanji/datacenter/service/EventDataServiceImpl.java
View file @
674d6973
...
@@ -12,6 +12,7 @@ import net.wanji.datacenter.kafka.KafkaProducerServiceHandler;
...
@@ -12,6 +12,7 @@ import net.wanji.datacenter.kafka.KafkaProducerServiceHandler;
import
net.wanji.datacenter.mapper.EventInfoMapper
;
import
net.wanji.datacenter.mapper.EventInfoMapper
;
import
net.wanji.datacenter.pojo.dto.EventDataDTO
;
import
net.wanji.datacenter.pojo.dto.EventDataDTO
;
import
net.wanji.datacenter.pojo.po.EventInfoPO
;
import
net.wanji.datacenter.pojo.po.EventInfoPO
;
import
org.apache.ignite.transactions.TransactionRollbackException
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.NotNull
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -54,7 +55,23 @@ public class EventDataServiceImpl implements EventDataService {
...
@@ -54,7 +55,23 @@ public class EventDataServiceImpl implements EventDataService {
eventInfoPO4DB
.
setOptStatus
(
1
);
eventInfoPO4DB
.
setOptStatus
(
1
);
}
}
setGreenId
(
crossIdGreenIdMap
,
eventInfoPO4DB
,
eventInfoPO4DB
.
getCrossId
());
setGreenId
(
crossIdGreenIdMap
,
eventInfoPO4DB
,
eventInfoPO4DB
.
getCrossId
());
int
retryCount
=
0
;
while
(
retryCount
<
3
)
{
try
{
eventInfoMapper
.
updateOne
(
eventInfoPO4DB
);
eventInfoMapper
.
updateOne
(
eventInfoPO4DB
);
return
;
}
catch
(
TransactionRollbackException
e
)
{
retryCount
++;
log
.
warn
(
"检测到死锁,进行第 {} 次重试"
,
retryCount
);
try
{
// 等待一会,避免立刻冲突
Thread
.
sleep
(
100
);
}
catch
(
InterruptedException
ignored
)
{
log
.
warn
(
"检测到死锁, Thread.sleep 100ms,异常:{}"
,
ignored
);
}
}
}
}
else
{
}
else
{
EventInfoPO
eventInfoPO
=
getEventInfoPO
(
eventDataDTO
);
EventInfoPO
eventInfoPO
=
getEventInfoPO
(
eventDataDTO
);
eventInfoMapper
.
insertOne
(
eventInfoPO
);
eventInfoMapper
.
insertOne
(
eventInfoPO
);
...
...
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