Hello Team,
I have a requirement to keep cache in ignite and that will update
frequently and selection also happens parallel, while i am executing
queries iam getting,
ava.sql.SQLException: Failed to update some keys because they had been
modified concurrently [keys=[ROWKEY [idHash=628930863, hash=1637498765,
rowkey=6, id=765436]]]
at
org.apache.ignite.internal.jdbc.thin.JdbcThinConnection.sendRequest(JdbcThinConnection.java:1009)
at
org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute0(JdbcThinStatement.java:234)
at
org.apache.ignite.internal.jdbc.thin.JdbcThinPreparedStatement.executeWithArguments(JdbcThinPreparedStatement.java:252)
at
org.apache.ignite.internal.jdbc.thin.JdbcThinPreparedStatement.executeUpdate(JdbcThinPreparedStatement.java:96)
at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:118)
at com.sun.proxy.$Proxy16.executeUpdate(Unknown Source)
Attached config file in attachment.
Thanks & Regards
Ajay Babu Maguluri.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- <context:component-scan base-package="com.sixdee.ignite"></context:component-scan>
<context:annotation-config />
<mvc:annotation-driven />
-->
<bean class="org.apache.ignite.configuration.IgniteConfiguration"
id="igniteConfiguration">
<property name="cacheKeyConfiguration">
<list>
<bean class="org.apache.ignite.cache.CacheKeyConfiguration">
<property name="typeName" value="ROWKEY" />
<property name="affinityKeyFieldName" value="rowkey" />
</bean>
</list>
</property>
<property name="clientMode" value="false" />
<property name="gridName" value="6d-ignite-grid"></property>
<property name="cacheConfiguration">
<list>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="persons"></property>
<!-- Set cache mode. -->
<property name="cacheMode" value="PARTITIONED" />
<!-- Set number of backups to 0 -->
<property name="backups" value="0" />
<property name="onheapCacheEnabled" value="false" />
<property name="statisticsEnabled" value="true" />
<property name="memoryPolicyName" value="Default_Region" />
<property name="copyOnRead" value="false" />
<property name="writeSynchronizationMode" value="FULL_SYNC" />
<property name="affinity">
<bean
class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
<property name="excludeNeighbors" value="true" />
<property name="partitions" value="10" />
<property name="affinityBackupFilter">
<bean
class="org.apache.ignite.cache.affinity.rendezvous.ClusterNodeAttributeAffinityBackupFilter">
<constructor-arg>
<array value-type="java.lang.String">
<value>AVAILABILITY_ZONE</value>
</array>
</constructor-arg>
</bean>
</property>
</bean>
</property>
<property name="queryEntities">
<list>
<bean class="org.apache.ignite.cache.QueryEntity">
<property name="keyType" value="ROWKEY"></property>
<property name="valueType" value="PERSONS"></property>
<property name="fields">
<map>
<entry key="rowkey" value="java.lang.Long"></entry>
<entry key="id" value="java.lang.Long"></entry>
<entry key="name" value="java.lang.String"></entry>
<entry key="birthday" value="java.lang.String"></entry>
<entry key="gender" value="java.lang.String"></entry>
<entry key="amount" value="java.lang.Long"></entry>
<entry key="salary" value="java.lang.Long"></entry>
<entry key="orgid" value="java.lang.String"></entry>
</map>
</property>
<property name="keyFields">
<set>
<value>rowkey</value>
<value>id</value>
</set>
</property>
</bean>
</list>
</property>
</bean>
</list>
</property>
<property name="includeEventTypes">
<list>
<!--Task execution events -->
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED" />
<!--Cache events -->
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED" />
</list>
</property>
<property name="peerClassLoadingEnabled" value="true"></property>
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean
class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
<property name="addresses">
<list>
<!-- In distributed environment, replace with actual host IP address. -->
<value>127.0.0.1:47500..47509</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
<property name="memoryConfiguration">
<bean class="org.apache.ignite.configuration.MemoryConfiguration">
<property name="defaultMemoryPolicyName" value="Default_Region" />
<property name="pageSize" value="4096" />
<property name="systemCacheInitialSize" value="#{40 * 1024 * 1024}" />
<property name="systemCacheMaxSize" value="#{40 * 1024 * 1024}" />
<property name="memoryPolicies">
<list>
<bean
class="org.apache.ignite.configuration.MemoryPolicyConfiguration">
<property name="name" value="Default_Region" />
<property name="initialSize" value="#{20 * 1024 * 1024}" />
<property name="maxSize" value="#{20 * 1024 * 1024}" />
<property name="pageEvictionMode" value="RANDOM_2_LRU" />
<property name="evictionThreshold" value="0.6" />
<property name="metricsEnabled" value="true" />
</bean>
</list>
</property>
</bean>
</property>
</bean>
<!--
<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:secret.properties" />
</bean>
<bean class="org.springframework.jdbc.datasource.DriverManagerDataSource"
id="dataSource">
<property name="driverClassName" value="${dsMySQL_DB.jdbc.driver}"></property>
<property name="url" value="${dsMySQL_DB.jdbc.url}"></property>
<property name="username" value="${dsMySQL_DB.jdbc.username}"></property>
<property name="password" value="${dsMySQL_DB.jdbc.password}"></property>
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/jndi"/>
</bean>
Spring Quartz
<bean name="refreshCache" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.sixdee.ignite.RefreshCache" />
<property name="jobDataAsMap">
<map>
<entry key="cacheName" value="persons" />
<entry key="query" value="select * from person" />
<entry key="igniteSpringBean" value-ref="igniteSpringBean" />
<entry key="dataSource" value-ref="dataSource" />
</map>
</property>
</bean>
Cron Trigger, run every 5 seconds
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="refreshCache" />
<property name="cronExpression" value="0/5 * * * * ?" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTrigger" />
</list>
</property>
<property name="quartzProperties">
<props>
<prop key="org.quartz.scheduler.skipUpdateCheck">true</prop>
</props>
</property>
</bean> -->
</beans>