首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >预写缓存导致CacheWriterException

预写缓存导致CacheWriterException
EN

Stack Overflow用户
提问于 2020-09-09 07:46:05
回答 1查看 85关注 0票数 0

我试图做一些简单的基准测试(使用JMH)的点燃缓存,并启用了写。写通是很好的,但是写出来的错误是正确的.

我得到了CacheWriterException,连接池正在超时。数据源是由Spring配置的默认hikari datasource (通过写入可以正确地工作)。

Ignite缓存配置

代码语言:javascript
复制
 CacheConfiguration<Long, Customer> customerWriteAheadCacheCfg = new CacheConfiguration<(CacheName.WRITE_AHEAD.getCacheName());
 customerWriteAheadCacheCfg.setIndexedTypes(Long.class, Customer.class);
 customerWriteAheadCacheCfg.setWriteThrough(true);
 customerWriteAheadCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
 customerWriteAheadCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
 customerWriteAheadCacheCfg.setWriteBehindEnabled(true);
 customerWriteAheadCacheCfg.setWriteBehindBatchSize(50);

存储和实体配置

代码语言:javascript
复制
CacheJdbcPojoStoreFactory<Long, Customer> customerPojoFactory1 = new CacheJdbcPojoStoreFactory<>();
customerPojoFactory1.setDataSourceBean("dataSource");
customerPojoFactory1.setDialect(new BasicJdbcDialect());
JdbcType customerPojoType1 = new JdbcType();
customerPojoType1.setCacheName(CacheName.WRITE_AHEAD.getCacheName());
customerPojoType1.setKeyType(Long.class);
customerPojoType1.setValueType(Customer.class);
customerPojoType1.setDatabaseTable("customer");
customerPojoType1.setKeyFields(new JdbcTypeField(Types.INTEGER, "id", Long.class, "id"));
customerPojoType1.setValueFields(
           new JdbcTypeField(Types.VARCHAR, "name", String.class, "name"),
           new JdbcTypeField(Types.VARCHAR, "type", String.class, "type")
);
customerPojoFactory1.setTypes(customerPojoType1);

对于基准测试,我只是在缓存中使用put

代码语言:javascript
复制
public void saveToCacheWriteAhead(Customer customer) {
    waCache.put(customer.getId(), customer);
}

知道是什么导致了这个错误吗?

EN

回答 1

Stack Overflow用户

发布于 2020-09-10 05:23:34

“连接不可用”可能意味着连接池已满。如果提前写入,则在每个写入线程中打开一个连接。因此,连接的最大数量至少应该是写入线程的数目。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63806968

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档