我试图做一些简单的基准测试(使用JMH)的点燃缓存,并启用了写。写通是很好的,但是写出来的错误是正确的.
我得到了CacheWriterException,连接池正在超时。数据源是由Spring配置的默认hikari datasource (通过写入可以正确地工作)。

Ignite缓存配置
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);存储和实体配置
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
public void saveToCacheWriteAhead(Customer customer) {
waCache.put(customer.getId(), customer);
}知道是什么导致了这个错误吗?
发布于 2020-09-10 05:23:34
“连接不可用”可能意味着连接池已满。如果提前写入,则在每个写入线程中打开一个连接。因此,连接的最大数量至少应该是写入线程的数目。
https://stackoverflow.com/questions/63806968
复制相似问题