Skip to content

Commit

Permalink
变更线程池时引入了一个bug:
Browse files Browse the repository at this point in the history
1:Netty5的EventLoop.submit()提交的任务是无法被interupted的。
2:jdk的SessionStatManager的重发任务不能被interrupted,因为BDB任务被
中断后会使BDB的Environment损坏。
  • Loading branch information
Lihuanghe committed Oct 13, 2015
1 parent 0c68145 commit 126f18a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.zx.sms</groupId>
<artifactId>cmpp-core</artifactId>
<version>1.21</version>
<version>1.22</version>
<packaging>jar</packaging>
<name>cmpp-core</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ private void scheduleRetryMsg(final ChannelHandlerContext ctx, final Message mes
*TODO bugfix:
*不知道什么原因,会导致 下面的future任务没有cancel掉。
*这里增加一个引用,当会试任务超过次数限制后,cancel掉自己。
*些任务不能被中断interupted.如果storeMap.remove()被中断会破坏BDB的内部状态,使用BDB无法继续工作
**/
final AtomicReference<Future> ref = new AtomicReference<Future>();

Expand All @@ -244,7 +245,7 @@ public void run() {
//会有future泄漏的情况发生,这里cancel掉自己,来规避泄漏
Future future = ref.get();
if(future!=null)
future.cancel(true);
future.cancel(false);

cancelRetry(message, ctx.channel());

Expand All @@ -267,6 +268,7 @@ public void run() {
ctx.writeAndFlush(message, ctx.newPromise());
}
} catch (Throwable e) {
logger.error("retry Send Msg Error: {}", message);
logger.error("retry send Msg Error.", e);
}
}
Expand All @@ -278,7 +280,7 @@ public void run() {

// 这里增加一次判断,是否已收到resp消息,已到resp后,msgRetryMap里的entry会被 remove掉。
if (msgRetryMap.get(seq) == null) {
future.cancel(true);
future.cancel(false);
}

} else if (entry == null) {
Expand All @@ -292,7 +294,7 @@ private Entry cancelRetry(Message msg, Channel channel) {
Entry entry = msgRetryMap.remove(msg.getHeader().getSequenceId());

if (entry != null && entry.future != null) {
entry.future.cancel(true);
entry.future.cancel(false);
}
if (windows != null) {
// 如果等窗口的队列里有任务,先发送等待的消息
Expand Down

0 comments on commit 126f18a

Please sign in to comment.