Hibernate 2nd Level query cache with Ignite

classic Classic list List threaded Threaded
5 messages Options
tatharoy tatharoy
Reply | Threaded
Open this post in threaded view
|

Hibernate 2nd Level query cache with Ignite

Hi,

 

I am trying to do a POC on hibernate 2nd level cache with Apache Ignite. With this configuration I was able to make it work

 

spring.jpa.properties.hibernate.cache.use_second_level_cache=true
spring.jpa.properties.hibernate.cache.use_query_cache=true
spring.jpa.properties.hibernate.generate_statistics=false
spring.jpa.properties.hibernate.cache.region.factory_class=org.apache.ignite.cache.hibernate.HibernateRegionFactory
spring.jpa.properties.org.apache.ignite.hibernate.default_access_type=READ_ONLY

 

 

<dependency>
     <
groupId>org.gridgain</groupId>
     <
artifactId>ignite-hibernate_5.3</artifactId>
     <
version>8.7.23</version>
     <
exclusions>
         <
exclusion>
             <
groupId>org.hibernate</groupId>
             <
artifactId>hibernate-core</artifactId>
         </
exclusion>
     </
exclusions>
</
dependency>
 
@Bean
@ConditionalOnMissingBean
public IgniteConfiguration igniteConfiguration(DiscoverySpi discoverySpi, CommunicationSpi communicationSpi) {
    IgniteConfiguration igniteConfiguration =
new IgniteConfiguration();
    igniteConfiguration.setClientMode(
clientMode);
    igniteConfiguration.setMetricsLogFrequency(
0);

    igniteConfiguration.setGridLogger(
new Slf4jLogger());

    igniteConfiguration.setDiscoverySpi(discoverySpi);
    igniteConfiguration.setCommunicationSpi(communicationSpi);
    igniteConfiguration.setFailureDetectionTimeout(
failureDetectionTimeout);

    CacheConfiguration<String, ?> cc =
new CacheConfiguration<>();
    cc.setName(“Entity1”);
    cc.setCacheMode(CacheMode.
REPLICATED);
 
    CacheConfiguration<String, ?> cc1 = new CacheConfiguration<>();
    cc1.setName(“
default-query-results-region”);
    cc1.setCacheMode(CacheMode.
REPLICATED);
 
    CacheConfiguration<String, ?> cc2 = new CacheConfiguration<>();
    cc2.setName(“
default-update-timestamps-region”);
    cc2.setCacheMode(CacheMode.
REPLICATED);

    igniteConfiguration.setCacheConfiguration(cc);



   
return igniteConfiguration;
}
 

 

 

I am testing this with external ignite node, but if the external ig node is restarted , I see the error when trying to access Entity1

 

"errorMessage": "class org.apache.ignite.internal.processors.cache.CacheStoppedException: Failed to perform cache operation (cache is stopped): Entity1; nested exception is java.lang.IllegalStateException: class org.apache.ignite.internal.processors.cache.CacheStoppedException: Failed to perform cache operation (cache is stopped): Entity1",

 

It looks like the issue is as reported here ,

 

https://stackoverflow.com/questions/46053089/ignite-cache-reconnection-issue-cache-is-stopped

https://issues.apache.org/jira/browse/IGNITE-5789

 

 

Are there any other way without restaring the client application we can make it work?

ezhuravlev ezhuravlev
Reply | Threaded
Open this post in threaded view
|

Re: Hibernate 2nd Level query cache with Ignite

Hi,

Can you please share full logs from client and server nodes?

Thanks,
Evgenii

ср, 26 авг. 2020 г. в 14:26, Tathagata Roy <[hidden email]>:

Hi,

 

I am trying to do a POC on hibernate 2nd level cache with Apache Ignite. With this configuration I was able to make it work

 

spring.jpa.properties.hibernate.cache.use_second_level_cache=true
spring.jpa.properties.hibernate.cache.use_query_cache=true
spring.jpa.properties.hibernate.generate_statistics=false
spring.jpa.properties.hibernate.cache.region.factory_class=org.apache.ignite.cache.hibernate.HibernateRegionFactory
spring.jpa.properties.org.apache.ignite.hibernate.default_access_type=READ_ONLY

 

 

<dependency>
     <
groupId>org.gridgain</groupId>
     <
artifactId>ignite-hibernate_5.3</artifactId>
     <
version>8.7.23</version>
     <
exclusions>
         <
exclusion>
             <
groupId>org.hibernate</groupId>
             <
artifactId>hibernate-core</artifactId>
         </
exclusion>
     </
exclusions>
</
dependency>
 
@Bean
@ConditionalOnMissingBean
public IgniteConfiguration igniteConfiguration(DiscoverySpi discoverySpi, CommunicationSpi communicationSpi) {
    IgniteConfiguration igniteConfiguration =
new IgniteConfiguration();
    igniteConfiguration.setClientMode(
clientMode);
    igniteConfiguration.setMetricsLogFrequency(
0);

    igniteConfiguration.setGridLogger(
new Slf4jLogger());

    igniteConfiguration.setDiscoverySpi(discoverySpi);
    igniteConfiguration.setCommunicationSpi(communicationSpi);
    igniteConfiguration.setFailureDetectionTimeout(
failureDetectionTimeout);

    CacheConfiguration<String, ?> cc =
new CacheConfiguration<>();
    cc.setName(“Entity1”);
    cc.setCacheMode(CacheMode.
REPLICATED);
 
    CacheConfiguration<String, ?> cc1 = new CacheConfiguration<>();
    cc1.setName(“
default-query-results-region”);
    cc1.setCacheMode(CacheMode.
REPLICATED);
 
    CacheConfiguration<String, ?> cc2 = new CacheConfiguration<>();
    cc2.setName(“
default-update-timestamps-region”);
    cc2.setCacheMode(CacheMode.
REPLICATED);

    igniteConfiguration.setCacheConfiguration(cc);



   
return igniteConfiguration;
}
 

 

 

I am testing this with external ignite node, but if the external ig node is restarted , I see the error when trying to access Entity1

 

"errorMessage": "class org.apache.ignite.internal.processors.cache.CacheStoppedException: Failed to perform cache operation (cache is stopped): Entity1; nested exception is java.lang.IllegalStateException: class org.apache.ignite.internal.processors.cache.CacheStoppedException: Failed to perform cache operation (cache is stopped): Entity1",

 

It looks like the issue is as reported here ,

 

https://stackoverflow.com/questions/46053089/ignite-cache-reconnection-issue-cache-is-stopped

https://issues.apache.org/jira/browse/IGNITE-5789

 

 

Are there any other way without restaring the client application we can make it work?

tatharoy tatharoy
Reply | Threaded
Open this post in threaded view
|

RE: Hibernate 2nd Level query cache with Ignite

Thanks for responding @Evgenii

 

Attaching the logs for both. There is no signification info in the ignite server. In application logs all logs after line 6629 is when application was able to reconnect with server after the server restart

 

From: Evgenii Zhuravlev <[hidden email]>
Sent: Wednesday, August 26, 2020 4:58 PM
To: user <[hidden email]>
Subject: Re: Hibernate 2nd Level query cache with Ignite

 

Hi,

 

Can you please share full logs from client and server nodes?

 

Thanks,

Evgenii

 

ср, 26 авг. 2020 г. в 14:26, Tathagata Roy <[hidden email]>:

Hi,

 

I am trying to do a POC on hibernate 2nd level cache with Apache Ignite. With this configuration I was able to make it work

 

spring.jpa.properties.hibernate.cache.use_second_level_cache=true
spring.jpa.properties.hibernate.cache.use_query_cache=true
spring.jpa.properties.hibernate.generate_statistics=false
spring.jpa.properties.hibernate.cache.region.factory_class=org.apache.ignite.cache.hibernate.HibernateRegionFactory
spring.jpa.properties.org.apache.ignite.hibernate.default_access_type=READ_ONLY

 

 

<dependency>
     <
groupId>org.gridgain</groupId>
     <
artifactId>ignite-hibernate_5.3</artifactId>
     <
version>8.7.23</version>
     <
exclusions>
         <
exclusion>
             <
groupId>org.hibernate</groupId>
             <
artifactId>hibernate-core</artifactId>
         </
exclusion>
     </
exclusions>
</
dependency>
 
@Bean
@ConditionalOnMissingBean
public IgniteConfiguration igniteConfiguration(DiscoverySpi discoverySpi, CommunicationSpi communicationSpi) {
    IgniteConfiguration igniteConfiguration =
new IgniteConfiguration();
    igniteConfiguration.setClientMode(
clientMode);
    igniteConfiguration.setMetricsLogFrequency(
0);

    igniteConfiguration.setGridLogger(
new Slf4jLogger());

    igniteConfiguration.setDiscoverySpi(discoverySpi);
    igniteConfiguration.setCommunicationSpi(communicationSpi);
    igniteConfiguration.setFailureDetectionTimeout(
failureDetectionTimeout);

    CacheConfiguration<String, ?> cc =
new CacheConfiguration<>();
    cc.setName(“Entity1”);
    cc.setCacheMode(CacheMode.
REPLICATED);
 
    CacheConfiguration<String, ?> cc1 = new CacheConfiguration<>();
    cc1.setName(“
default-query-results-region”);
    cc1.setCacheMode(CacheMode.
REPLICATED);
 
    CacheConfiguration<String, ?> cc2 = new CacheConfiguration<>();
    cc2.setName(“
default-update-timestamps-region”);
    cc2.setCacheMode(CacheMode.
REPLICATED);

    igniteConfiguration.setCacheConfiguration(cc);



   
return igniteConfiguration;
}
 

 

 

I am testing this with external ignite node, but if the external ig node is restarted , I see the error when trying to access Entity1

 

"errorMessage": "class org.apache.ignite.internal.processors.cache.CacheStoppedException: Failed to perform cache operation (cache is stopped): Entity1; nested exception is java.lang.IllegalStateException: class org.apache.ignite.internal.processors.cache.CacheStoppedException: Failed to perform cache operation (cache is stopped): Entity1",

 

It looks like the issue is as reported here ,

 

https://stackoverflow.com/questions/46053089/ignite-cache-reconnection-issue-cache-is-stopped

https://issues.apache.org/jira/browse/IGNITE-5789

 

 

Are there any other way without restaring the client application we can make it work?


ApplicationLogs.log (1M) Download Attachment
IgniteServerLogs.log (24K) Download Attachment
tatharoy tatharoy
Reply | Threaded
Open this post in threaded view
|

RE: Hibernate 2nd Level query cache with Ignite

In reply to this post by ezhuravlev

If it helps here is my dependency tree

 

 

 

From: Tathagata Roy
Sent: Thursday, August 27, 2020 8:35 AM
To: user <[hidden email]>
Subject: RE: Hibernate 2nd Level query cache with Ignite

 

Thanks for responding @Evgenii

 

Attaching the logs for both. There is no signification info in the ignite server. In application logs all logs after line 6629 is when application was able to reconnect with server after the server restart

 

From: Evgenii Zhuravlev <[hidden email]>
Sent: Wednesday, August 26, 2020 4:58 PM
To: user <[hidden email]>
Subject: Re: Hibernate 2nd Level query cache with Ignite

 

Hi,

 

Can you please share full logs from client and server nodes?

 

Thanks,

Evgenii

 

ср, 26 авг. 2020 г. в 14:26, Tathagata Roy <[hidden email]>:

Hi,

 

I am trying to do a POC on hibernate 2nd level cache with Apache Ignite. With this configuration I was able to make it work

 

spring.jpa.properties.hibernate.cache.use_second_level_cache=true
spring.jpa.properties.hibernate.cache.use_query_cache=true
spring.jpa.properties.hibernate.generate_statistics=false
spring.jpa.properties.hibernate.cache.region.factory_class=org.apache.ignite.cache.hibernate.HibernateRegionFactory
spring.jpa.properties.org.apache.ignite.hibernate.default_access_type=READ_ONLY

 

 

<dependency>
     <
groupId>org.gridgain</groupId>
     <
artifactId>ignite-hibernate_5.3</artifactId>
     <
version>8.7.23</version>
     <
exclusions>
         <
exclusion>
             <
groupId>org.hibernate</groupId>
             <
artifactId>hibernate-core</artifactId>
         </
exclusion>
     </
exclusions>
</
dependency>
 
@Bean
@ConditionalOnMissingBean
public IgniteConfiguration igniteConfiguration(DiscoverySpi discoverySpi, CommunicationSpi communicationSpi) {
    IgniteConfiguration igniteConfiguration =
new IgniteConfiguration();
    igniteConfiguration.setClientMode(
clientMode);
    igniteConfiguration.setMetricsLogFrequency(
0);

    igniteConfiguration.setGridLogger(
new Slf4jLogger());

    igniteConfiguration.setDiscoverySpi(discoverySpi);
    igniteConfiguration.setCommunicationSpi(communicationSpi);
    igniteConfiguration.setFailureDetectionTimeout(
failureDetectionTimeout);

    CacheConfiguration<String, ?> cc =
new CacheConfiguration<>();
    cc.setName(“Entity1”);
    cc.setCacheMode(CacheMode.
REPLICATED);
 
    CacheConfiguration<String, ?> cc1 = new CacheConfiguration<>();
    cc1.setName(“
default-query-results-region”);
    cc1.setCacheMode(CacheMode.
REPLICATED);
 
    CacheConfiguration<String, ?> cc2 = new CacheConfiguration<>();
    cc2.setName(“
default-update-timestamps-region”);
    cc2.setCacheMode(CacheMode.
REPLICATED);

    igniteConfiguration.setCacheConfiguration(cc);



   
return igniteConfiguration;
}
 

 

 

I am testing this with external ignite node, but if the external ig node is restarted , I see the error when trying to access Entity1

 

"errorMessage": "class org.apache.ignite.internal.processors.cache.CacheStoppedException: Failed to perform cache operation (cache is stopped): Entity1; nested exception is java.lang.IllegalStateException: class org.apache.ignite.internal.processors.cache.CacheStoppedException: Failed to perform cache operation (cache is stopped): Entity1",

 

It looks like the issue is as reported here ,

 

https://stackoverflow.com/questions/46053089/ignite-cache-reconnection-issue-cache-is-stopped

https://issues.apache.org/jira/browse/IGNITE-5789

 

 

Are there any other way without restaring the client application we can make it work?


dependencyTree.txt (17K) Download Attachment
ezhuravlev ezhuravlev
Reply | Threaded
Open this post in threaded view
|

Re: Hibernate 2nd Level query cache with Ignite

Hi,

In the ticket you've shared before, the reproducer has a cache object creation after the reconnect. This should be done in this case too. The thing is that the client reconnects to the absolutely different cluster, as it was in memory and it was fully stopped. To avoid this situation you can start more than one server node. At the same time, I think that on the ignite - hibernate integration side, we should add handling of the reconnect for this scenario.
All cache proxy objects should be recreated after reconnect.


Best Regards,
Evgenii


чт, 27 авг. 2020 г. в 08:48, Tathagata Roy <[hidden email]>:

If it helps here is my dependency tree

 

 

 

From: Tathagata Roy
Sent: Thursday, August 27, 2020 8:35 AM
To: user <[hidden email]>
Subject: RE: Hibernate 2nd Level query cache with Ignite

 

Thanks for responding @Evgenii

 

Attaching the logs for both. There is no signification info in the ignite server. In application logs all logs after line 6629 is when application was able to reconnect with server after the server restart

 

From: Evgenii Zhuravlev <[hidden email]>
Sent: Wednesday, August 26, 2020 4:58 PM
To: user <[hidden email]>
Subject: Re: Hibernate 2nd Level query cache with Ignite

 

Hi,

 

Can you please share full logs from client and server nodes?

 

Thanks,

Evgenii

 

ср, 26 авг. 2020 г. в 14:26, Tathagata Roy <[hidden email]>:

Hi,

 

I am trying to do a POC on hibernate 2nd level cache with Apache Ignite. With this configuration I was able to make it work

 

spring.jpa.properties.hibernate.cache.use_second_level_cache=true
spring.jpa.properties.hibernate.cache.use_query_cache=true
spring.jpa.properties.hibernate.generate_statistics=false
spring.jpa.properties.hibernate.cache.region.factory_class=org.apache.ignite.cache.hibernate.HibernateRegionFactory
spring.jpa.properties.org.apache.ignite.hibernate.default_access_type=READ_ONLY

 

 

<dependency>
     <
groupId>org.gridgain</groupId>
     <
artifactId>ignite-hibernate_5.3</artifactId>
     <
version>8.7.23</version>
     <
exclusions>
         <
exclusion>
             <
groupId>org.hibernate</groupId>
             <
artifactId>hibernate-core</artifactId>
         </
exclusion>
     </
exclusions>
</
dependency>
 
@Bean
@ConditionalOnMissingBean
public IgniteConfiguration igniteConfiguration(DiscoverySpi discoverySpi, CommunicationSpi communicationSpi) {
    IgniteConfiguration igniteConfiguration =
new IgniteConfiguration();
    igniteConfiguration.setClientMode(
clientMode);
    igniteConfiguration.setMetricsLogFrequency(
0);

    igniteConfiguration.setGridLogger(
new Slf4jLogger());

    igniteConfiguration.setDiscoverySpi(discoverySpi);
    igniteConfiguration.setCommunicationSpi(communicationSpi);
    igniteConfiguration.setFailureDetectionTimeout(
failureDetectionTimeout);

    CacheConfiguration<String, ?> cc =
new CacheConfiguration<>();
    cc.setName(“Entity1”);
    cc.setCacheMode(CacheMode.
REPLICATED);
 
    CacheConfiguration<String, ?> cc1 = new CacheConfiguration<>();
    cc1.setName(“
default-query-results-region”);
    cc1.setCacheMode(CacheMode.
REPLICATED);
 
    CacheConfiguration<String, ?> cc2 = new CacheConfiguration<>();
    cc2.setName(“
default-update-timestamps-region”);
    cc2.setCacheMode(CacheMode.
REPLICATED);

    igniteConfiguration.setCacheConfiguration(cc);



   
return igniteConfiguration;
}
 

 

 

I am testing this with external ignite node, but if the external ig node is restarted , I see the error when trying to access Entity1

 

"errorMessage": "class org.apache.ignite.internal.processors.cache.CacheStoppedException: Failed to perform cache operation (cache is stopped): Entity1; nested exception is java.lang.IllegalStateException: class org.apache.ignite.internal.processors.cache.CacheStoppedException: Failed to perform cache operation (cache is stopped): Entity1",

 

It looks like the issue is as reported here ,

 

https://stackoverflow.com/questions/46053089/ignite-cache-reconnection-issue-cache-is-stopped

https://issues.apache.org/jira/browse/IGNITE-5789

 

 

Are there any other way without restaring the client application we can make it work?