2 sinat 21697575 sinat_21697575 于 2017.08.30 11:21 提问

mysql getHibernateTemplate().save 执行很慢 30C

处理描述
1.主处理
@Transactional(rollbackFor = Exception.class)
public String saveRecord(Record mRecord) {
try {
User user = userDao.load(mRecord.getUser().getId());
mRecord.setUser(user);
mRecord.setType(mRecord.getType());
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
mRecord.setAnswerDatetime(timestamp);
mRecord.setUpdateUserId(mRecord.getUser().getId());
mRecord.setUpdateDatetime(timestamp);
mRecord.setCreateUserId(mRecord.getUser().getId());
mRecord.setCreateDatetime(timestamp);
recordDao.save(mRecord);
return "SUCCESS";
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw e;
}
}
2.save处理
public ID save(T t) throws DataAccessException {
if (t != null) {
if (t instanceof UpdateInfo) {
Manageable userInfo = Authenticator.loadActiveUser().getUserInfo();
if (userInfo != null) {
UpdateInfo u = (UpdateInfo)t;
Timestamp systime = new Timestamp(System.currentTimeMillis());
u.setUpdateUserId(userInfo.getId());
u.setUpdateDatetime(systime);
if (u.getCreateDatetime() == null) {
u.setCreateUserId(userInfo.getId());
u.setCreateDatetime(systime);
}
} else {
UpdateInfo u = (UpdateInfo)t;
Timestamp systime = new Timestamp(System.currentTimeMillis());
u.setUpdateDatetime(systime);
}
}
return (ID)getHibernateTemplate().save(t);
}
return null;
}

问题点描述
return (ID)getHibernateTemplate().save(t);
这个处理花了十几分钟才结束。

log日志
1.接受到请求2017/08/30 09:02:23.763 INFO ControllerInterceptor creatRecord START 
2.数据库record的最终的更新时间是 2017/08/30 09:02:24
3.record表的id是从seq表中取得的
 Wed Aug 30 09:17:01 JST 2017
 Hibernate: select seq_value fromsequences where seq_key = 'record_id' for update
 Hibernate: update sequences set seq_value = ? where seq_value = ? and seq_key = 'record_id'
 Hibernate: insert into `records` (answer_datetime, answer_result, confirm_date, confirm_hour, confirm_minute, create_datetime, create_user_id, type, update_datetime, update_user_id, user_id, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

根据上述log推断return (ID)getHibernateTemplate().save(t);处理花了十几分钟。
补充:
个人开发环境,测试环境,staging环境都没有问题,只有在正式服务器上会有这个问题。
Csdn user default icon
上传中...
上传图片
插入图片