Skip to content

Commit

Permalink
[Bugfix] 修复mysql死锁报错 (didi#728)
Browse files Browse the repository at this point in the history
  • Loading branch information
RenChauncy committed Nov 22, 2022
1 parent b5e5ab1 commit abf488e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ public void batchReplace(Long clusterPhyId, List<HealthCheckResult> healthCheckR
Map<String, HealthCheckResult> presentHealthPoMap = healthCheckResults.stream().collect(Collectors.toMap(o -> o.getClusterPhyId() + o.getDimension() + o.getConfigName() + o.getResName(), Function.identity()));
List<HealthCheckResultPO> dbHealthsPoList = getHealthsFromDB(healthCheckResults);
for (HealthCheckResultPO healthCheckResultPO : dbHealthsPoList) {
HealthCheckResult toUpdate = presentHealthPoMap.remove(healthCheckResultPO.getClusterPhyId() + healthCheckResultPO.getDimension() + healthCheckResultPO.getConfigName() + healthCheckResultPO.getResName());
healthCheckResultDAO.updateByKey(this.convert2HealthCheckPo(toUpdate));
String key = healthCheckResultPO.getClusterPhyId() + healthCheckResultPO.getDimension() + healthCheckResultPO.getConfigName() + healthCheckResultPO.getResName();
if (presentHealthPoMap.containsKey(key)){
presentHealthPoMap.remove(key);
healthCheckResultDAO.updateById(healthCheckResultPO);
}
}
for (HealthCheckResult healthCheckResult : presentHealthPoMap.values()) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ public interface HealthCheckResultDAO extends BaseMapper<HealthCheckResultPO> {

int batchReplace(List<HealthCheckResultPO> healthCheckResultPos);

void updateByKey(HealthCheckResultPO healthCheckResultPO);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,5 @@
dimension = dimension, config_name = config_name, cluster_phy_id = cluster_phy_id,
res_name = res_name, passed = passed
</insert>
<update id="updateByKey" parameterType="com.xiaojukeji.know.streaming.km.common.bean.po.health.HealthCheckResultPO">
UPDATE ks_km_health_check_result SET passed = #{passed}
WHERE cluster_phy_id = #{clusterPhyId} AND dimension = #{dimension}
and config_name = #{configName} AND res_name = #{resName}
</update>

</mapper>

0 comments on commit abf488e

Please sign in to comment.