0

I have some problem configuring jdbc-store for infinispan. I have defined a local cache with this configurations:

<cache-container name="MyCacheContainer">
    <local-cache name="MyCache">
        <expiration max-idle="60000" interval="6000"/>
    </local-cache>
</cache-container>

I need to persist the cache so I'm trying to use jdbc-store, using this data source

<datasource jta="true" jndi-name="java:jboss/datasources/MyDS" pool-name="MyDS" enabled="true" use-ccm="true">
    <connection-url>jdbc:h2:file:${jboss.server.data.dir}/db;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
    <driver-class>org.h2.Driver</driver-class>
    <driver>h2</driver>
    <security>
        <user-name>abc</user-name>
        <password>abc</password>
    </security>
</datasource>

When i try to configure the jdbc-store in the wildfly web console i had this error:

Internal Server Error
{
    "outcome" => "failed",
    "result" => {"step-1" => undefined},
    "failure-description" => "JBAS014883: No resource definition is registered for address [
    (\"subsystem\" => \"infinispan\"),
    (\"cache-container\" => \"MyCacheContainer\"),
    (\"local-cache\" => \"MyCache\"),
    (\"jdbc-store\" => \"JDBC_STORE\")
]",
    "rolled-back" => true
}

If i manually edit the standalone.xml adding this configs

<cache-container name="MyCacheContainer">
    <local-cache name="MyCache">
        <expiration max-idle="60000" interval="6000"/>
        <string-keyed-jdbc-store preload="false" passivation="false" purge="false" datasource="java:jboss/datasources/MyDS"/>
    </local-cache>
</cache-container>

I have regular cache serialization on the db, but it doesn't work as expected because data are removed from the db (not from memory) every 60000 milliseconds regardless they are idle. So, if I restart wildfly the cache is empty. Moreover i noticed that web console still say that jdbc-store in disableb and if I use file-store instead of jdbc-store all works fine, so I suspect that there's some problem in my configs.

codadilupo
  • 158
  • 4
  • 13
  • Quick note: I can see you have configured option preload="false". If you restart Wildfly (with your cache) then the data will NOT be preloaded from the store and therefore the cache will be empty. If you have some persisted entries in your store they should be loaded lazily when requested. Try get(some_key) on your restarted cache. What version of Infinispan do you use? – tsykora Sep 24 '14 at 08:08
  • @tsykora thanks for reply. I've tried to get an entry and the cache is empty. Same configs but with file-store works as expected. I use infinispan 6.0.2.Final – codadilupo Sep 24 '14 at 09:09
  • Hmmm strange. Might be a bug. Did you try also binary-keyed store? + try to remove expiration settings to see what will happen then. And thanks for info! – tsykora Sep 24 '14 at 09:44

1 Answers1

0

Regarding manual configuration in standalone.xml - you have to do that, how else should Infinispan know which cache (in general case) should be persisted into this storage?

Regarding the max-idle timeout: you're right that it's unexpected. When the entry is persisted into the DB, the expiration date is written there. However, when you read an entry, this timestamp is not updated - then, when the DB purge is fired, those entries are removed as well.

I don't think there will be any easy fix for that, but I wonder how could this work with SingleFileStore.

Radim Vansa
  • 5,686
  • 2
  • 25
  • 40
  • thank you! regarding "manual configuration" I mean editing standalone.xml despite using wildfly web console. For file store I'm able to use web console but for jdbc store I have error as I described in my post. Moreover, adding jdbc-store in the standalone.xml is not reflected in the web console. However I will try again with file store because i think it works fine (the reported bug is relative to version 5.2.6.Final) – codadilupo Sep 24 '14 at 12:17
  • Ok, I was wrong...file store doesn't work. Maybe I messed up during the test. Anyway, I think a bug like this is very very very bad for a "NoSQL key/value store or object database" with expiration feature – codadilupo Sep 24 '14 at 13:06