Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExecutorEngine里的executor未按照预期以阻塞方式返回所有result #64

Closed
koaal opened this issue May 6, 2016 · 1 comment

Comments

@koaal
Copy link

koaal commented May 6, 2016

应用场景:表名table1,分库未分表
测试用例:select min(id) from table1
错误信息:NPE

错误分析:
debug发现getResult做merge时子线程异步返回的resultset为null。

代码:com.dangdang.ddframe.rdb.sharding.executor.ExecutorEngine.getFutureResults用guava的Futures.get()阻塞式返回异步执行查询的resultset,怀疑该方法未像javadoc所声明的为阻塞方式。

修改该方法为显式阻塞,问题得到修复:
private List getFutureResults(final Set<ListenableFuture> futures) {
List result = new ArrayList(futures.size());
try {
for (ListenableFuture future : futures) {
result.add(future.get());
}
} catch (final InterruptedException | ExecutionException ex) {
throw new ShardingJdbcException(ex);
}
return result;
}

@koaal
Copy link
Author

koaal commented May 6, 2016

是我测试代码的问题,Futures.get()确实为阻塞,不存在上述问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants