Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-14954

Exception is thrown while reading cache size with embedded persistent cache

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • None
    • Persistence
    • None

    Description

      While trying embedded cache with persistence on Tomcat with configured Datasource connecting to PostgreSQL database, I am receiving the following exception while cache.size() operation:

      02-Jun-2023 06:29:35.827 SEVERE [http-nio-8080-exec-7] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [Servlet Name For Demo1] in context with path [/test] threw exception
          org.infinispan.commons.CacheException: Unexpected tag : 92 (Field number : 11, Wire type : 4)
              at org.infinispan.interceptors.impl.InvocationContextInterceptor.rethrowException(InvocationContextInterceptor.java:139)
              at org.infinispan.interceptors.impl.InvocationContextInterceptor.lambda$new$0(InvocationContextInterceptor.java:62)
              at org.infinispan.interceptors.InvocationExceptionFunction.apply(InvocationExceptionFunction.java:25)
              at org.infinispan.interceptors.impl.QueueAsyncInvocationStage.invokeQueuedHandlers(QueueAsyncInvocationStage.java:124)
              at org.infinispan.interceptors.impl.QueueAsyncInvocationStage.accept(QueueAsyncInvocationStage.java:87)
              at org.infinispan.interceptors.impl.QueueAsyncInvocationStage.accept(QueueAsyncInvocationStage.java:33)
              at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863)
              at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841)
              at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
              at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2162)
              at io.reactivex.rxjava3.internal.jdk8.CompletionStageConsumer.completeExceptionally(CompletionStageConsumer.java:98)
              at io.reactivex.rxjava3.internal.jdk8.CompletionStageConsumer.onError(CompletionStageConsumer.java:61)
              at io.reactivex.rxjava3.internal.operators.flowable.FlowableCountSingle$CountSubscriber.onError(FlowableCountSingle.java:71)
              at io.reactivex.rxjava3.internal.operators.flowable.FlowableConcatArray$ConcatArraySubscriber.onError(FlowableConcatArray.java:92)
              at io.reactivex.rxjava3.internal.operators.flowable.FlowableUsing$UsingSubscriber.onError(FlowableUsing.java:123)
              at io.reactivex.rxjava3.internal.operators.flowable.FlowableObserveOn$BaseObserveOnSubscriber.checkTerminated(FlowableObserveOn.java:211)
              at io.reactivex.rxjava3.internal.operators.flowable.FlowableObserveOn$ObserveOnSubscriber.runAsync(FlowableObserveOn.java:396)
              at io.reactivex.rxjava3.internal.operators.flowable.FlowableObserveOn$BaseObserveOnSubscriber.run(FlowableObserveOn.java:178)
              at io.reactivex.rxjava3.internal.schedulers.ExecutorScheduler$ExecutorWorker$BooleanRunnable.run(ExecutorScheduler.java:324)
              at io.reactivex.rxjava3.internal.schedulers.ExecutorScheduler$ExecutorWorker.runEager(ExecutorScheduler.java:289)
              at io.reactivex.rxjava3.internal.schedulers.ExecutorScheduler$ExecutorWorker.run(ExecutorScheduler.java:250)
              at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
              at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
              at java.base/java.lang.Thread.run(Thread.java:833)
              Suppressed: org.infinispan.commons.util.logging.TraceException
                  at org.infinispan.interceptors.impl.SimpleAsyncInvocationStage.get(SimpleAsyncInvocationStage.java:39)
                  at org.infinispan.interceptors.impl.AsyncInterceptorChainImpl.invoke(AsyncInterceptorChainImpl.java:249)
                  at org.infinispan.cache.impl.InvocationHelper.doInvoke(InvocationHelper.java:323)
                  at org.infinispan.cache.impl.InvocationHelper.invoke(InvocationHelper.java:111)
                  at org.infinispan.cache.impl.CacheImpl.size(CacheImpl.java:497)
                  at org.infinispan.cache.impl.CacheImpl.size(CacheImpl.java:492)
                  at org.infinispan.cache.impl.AbstractDelegatingCache.size(AbstractDelegatingCache.java:361)
                  at test.TestServlet.doGet(TestServlet.java:41)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:228)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163)
                  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163)
                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
                  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
                  at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
                  at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
                  at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
                  at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)
                  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1723)
                  at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
                  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
                  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
                  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
                  ... 1 more
          Caused by: java.lang.IllegalStateException: Unexpected tag : 92 (Field number : 11, Wire type : 4)
              at org.infinispan.protostream.WrappedMessage.readMessage(WrappedMessage.java:513)
              at org.infinispan.protostream.WrappedMessage.read(WrappedMessage.java:351)
              at org.infinispan.protostream.ProtobufUtil.fromWrappedStream(ProtobufUtil.java:137)
              at org.infinispan.marshall.protostream.impl.AbstractInternalProtoStreamMarshaller.readObject(AbstractInternalProtoStreamMarshaller.java:120)
              at org.infinispan.persistence.jdbc.common.JdbcUtil.unmarshall(JdbcUtil.java:68)
              at org.infinispan.persistence.jdbc.impl.table.AbstractTableManager.entryFromResultSet(AbstractTableManager.java:630)
              at org.infinispan.persistence.jdbc.common.sql.BaseTableOperations$ResultSetEntryIterator.getNext(BaseTableOperations.java:301)
              at org.infinispan.persistence.jdbc.common.sql.BaseTableOperations$ResultSetEntryIterator.getNext(BaseTableOperations.java:286)
              at org.infinispan.commons.util.AbstractIterator.hasNext(AbstractIterator.java:26)
              at io.reactivex.rxjava3.internal.operators.flowable.FlowableFromIterable.subscribe(FlowableFromIterable.java:53)
              at io.reactivex.rxjava3.internal.operators.flowable.FlowableFromIterable.subscribeActual(FlowableFromIterable.java:47)
              at io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15917)
              at io.reactivex.rxjava3.internal.operators.flowable.FlowableDoFinally.subscribeActual(FlowableDoFinally.java:47)
              at io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15917)
              at io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15863)
              at io.reactivex.rxjava3.internal.operators.flowable.FlowableUsing.subscribeActual(FlowableUsing.java:73)
              at io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15917)
              at io.reactivex.rxjava3.internal.operators.flowable.FlowableMap.subscribeActual(FlowableMap.java:38)
              at io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15917)
              at io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15863)
              at io.reactivex.rxjava3.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)
              at io.reactivex.rxjava3.internal.schedulers.ExecutorScheduler$ExecutorWorker$BooleanRunnable.run(ExecutorScheduler.java:324)
              at io.reactivex.rxjava3.internal.schedulers.ExecutorScheduler$ExecutorWorker.runEager(ExecutorScheduler.java:289)
              at io.reactivex.rxjava3.internal.schedulers.ExecutorScheduler$ExecutorWorker.run(ExecutorScheduler.java:250)
              at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
              at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
              at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
              at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
              at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
              ... 1 more 

      The datasource is configured directly in Tomcat context.xml/server.xml files (please find attached).

      The interesting part is that, if the number of entries put to the cache (and later cache.size() calculated) is 100 then the exception is not thrown and after each refresh the app shows the number of entries in the cache. If I increase the number of entries put to the cache to 110 then on first try all is good and all 110 entries were put to the cache. After the next refresh when the cache size should be calculated and return 110, the exception above is thrown.

      The same exception is also thrown, if expiration is configured with minimum time to live for entries. But this time, as the entries are expired the cache.size() is always 0. The exception is thrown during put operation.

      Reproducer app is:

      https://github.com/andyuk1986/persistent-embedded-test

      Build it with command: mvn clean compile war:war

      and just copy the war file to Tomcat's webapp directory. Start the tomcat and access the app with: http://localhost:8080/test/Demo1?count=110

      Tomcat used from jws-5.6.0-application-server.zip .

      Also I have tried with different Infinispan version any 14+, 13latest, the issue is there.

      Attachments

        1. context.xml
          2 kB
        2. server.xml
          8 kB

        Activity

          People

            Unassigned Unassigned
            amanukya@redhat.com Anna Manukyan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: