Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexOutOfBoundsException when decoding in sqlserver dialect #513

Open
patriknw opened this issue Feb 2, 2024 · 0 comments
Open

IndexOutOfBoundsException when decoding in sqlserver dialect #513

patriknw opened this issue Feb 2, 2024 · 0 comments
Labels
bug Something isn't working sqlserver

Comments

@patriknw
Copy link
Member

patriknw commented Feb 2, 2024

Noticed when running EventsBySlicePerfSpec

[2024-02-02 07:49:40,677] [ERROR] [akka.persistence.r2dbc.TestActors$Persister$] [akka://EventsBySlicePerfSpec] [] [EventsBySlicePerfSpec-akka.actor.default-dispatcher-9] - Supervisor StopSupervisor saw failure: Exception during recovery. Last known sequence number [0]. PersistenceId [TestEntity-2|p-37], due to: Exception during recovery. Last known sequence number [0]. PersistenceId [TestEntity-2|p-37], due to: index: 2, length: 29696 (expected: range(0, 2))
akka.persistence.typed.internal.JournalFailureException: Exception during recovery. Last known sequence number [0]. PersistenceId [TestEntity-2|p-37], due to: Exception during recovery. Last known sequence number [0]. PersistenceId [TestEntity-2|p-37], due to: index: 2, length: 29696 (expected: range(0, 2))
	at akka.persistence.typed.internal.ReplayingEvents.onRecoveryFailure(ReplayingEvents.scala:278)
	at akka.persistence.typed.internal.ReplayingEvents.onJournalResponse(ReplayingEvents.scala:211)
	at akka.persistence.typed.internal.ReplayingEvents.onMessage(ReplayingEvents.scala:105)
	at akka.persistence.typed.internal.ReplayingEvents.onMessage(ReplayingEvents.scala:80)
	at akka.actor.typed.scaladsl.AbstractBehavior.receive(AbstractBehavior.scala:84)
	at akka.actor.typed.Behavior$.interpret(Behavior.scala:282)
	at akka.actor.typed.Behavior$.interpretMessage(Behavior.scala:238)
	at akka.actor.typed.internal.InterceptorImpl$$anon$2.apply(InterceptorImpl.scala:57)
	at akka.persistence.typed.internal.EventSourcedBehaviorImpl$$anon$1.aroundReceive(EventSourcedBehaviorImpl.scala:220)
	at akka.actor.typed.internal.InterceptorImpl.receive(InterceptorImpl.scala:85)
	at akka.actor.typed.Behavior$.interpret(Behavior.scala:282)
	at akka.actor.typed.Behavior$.interpretMessage(Behavior.scala:238)
	at akka.actor.typed.internal.InterceptorImpl$$anon$2.apply(InterceptorImpl.scala:57)
	at akka.actor.typed.internal.SimpleSupervisor.aroundReceive(Supervision.scala:132)
	at akka.actor.typed.internal.InterceptorImpl.receive(InterceptorImpl.scala:85)
	at akka.actor.typed.Behavior$.interpret(Behavior.scala:282)
	at akka.actor.typed.Behavior$.interpretMessage(Behavior.scala:238)
	at akka.actor.typed.internal.adapter.ActorAdapter.handleMessage(ActorAdapter.scala:133)
	at akka.actor.typed.internal.adapter.ActorAdapter.aroundReceive(ActorAdapter.scala:109)
	at akka.actor.ActorCell.receiveMessage(ActorCell.scala:579)
	at akka.actor.ActorCell.invoke(ActorCell.scala:547)
	at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:270)
	at akka.dispatch.Mailbox.run(Mailbox.scala:231)
	at akka.dispatch.Mailbox.exec(Mailbox.scala:243)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: akka.persistence.typed.internal.JournalFailureException: Exception during recovery. Last known sequence number [0]. PersistenceId [TestEntity-2|p-37], due to: index: 2, length: 29696 (expected: range(0, 2))
	at akka.persistence.typed.internal.ReplayingEvents.onRecoveryFailure(ReplayingEvents.scala:278)
	at akka.persistence.typed.internal.ReplayingEvents.onJournalResponse(ReplayingEvents.scala:201)
	... 27 common frames omitted
Caused by: java.lang.IndexOutOfBoundsException: index: 2, length: 29696 (expected: range(0, 2))
	at io.netty.buffer.AbstractByteBuf.checkRangeBounds(AbstractByteBuf.java:1390)
	at io.netty.buffer.AbstractByteBuf.checkIndex0(AbstractByteBuf.java:1397)
	at io.netty.buffer.PooledSlicedByteBuf.getBytes(PooledSlicedByteBuf.java:234)
	at io.netty.buffer.ByteBufUtil.decodeString(ByteBufUtil.java:1300)
	at io.netty.buffer.AbstractByteBuf.toString(AbstractByteBuf.java:1246)
	at io.r2dbc.mssql.codec.StringCodec.doDecode(StringCodec.java:154)
	at io.r2dbc.mssql.codec.StringCodec.decode(StringCodec.java:119)
	at io.r2dbc.mssql.codec.StringCodec.decode(StringCodec.java:49)
	at io.r2dbc.mssql.codec.DefaultCodecs.doDecode(DefaultCodecs.java:201)
	at io.r2dbc.mssql.codec.DefaultCodecs.decode(DefaultCodecs.java:196)
	at io.r2dbc.mssql.MssqlRow.doGet(MssqlRow.java:122)
	at io.r2dbc.mssql.MssqlRow.get(MssqlRow.java:103)
	at akka.persistence.r2dbc.internal.postgres.PostgresQueryDao.$anonfun$eventsByPersistenceId$2(PostgresQueryDao.scala:369)
	at akka.persistence.r2dbc.internal.R2dbcExecutor$.$anonfun$selectInTx$3(R2dbcExecutor.scala:95)
	at io.r2dbc.mssql.DefaultMssqlResult.lambda$map$1(DefaultMssqlResult.java:137)
	at io.r2dbc.mssql.DefaultMssqlResult.lambda$doMap$5(DefaultMssqlResult.java:220)
	at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.onNext(FluxHandleFuseable.java:179)
	at reactor.core.publisher.FluxWindowPredicate$WindowFlux.drainRegular(FluxWindowPredicate.java:670)
	at reactor.core.publisher.FluxWindowPredicate$WindowFlux.drain(FluxWindowPredicate.java:748)
	at reactor.core.publisher.FluxWindowPredicate$WindowFlux.subscribe(FluxWindowPredicate.java:823)
	at reactor.core.publisher.Mono.subscribe(Mono.java:4495)
	at reactor.core.publisher.Mono.subscribeWith(Mono.java:4561)
	at reactor.core.publisher.Mono.toFuture(Mono.java:5073)
	at akka.persistence.r2dbc.internal.R2dbcExecutor$PublisherOps$.asFuture$extension(R2dbcExecutor.scala:43)
	at akka.persistence.r2dbc.internal.R2dbcExecutor$.$anonfun$selectInTx$1(R2dbcExecutor.scala:97)
	at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:470)
	at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:64)
	at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:101)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
	at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:94)
	at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:101)
	at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:49)
	at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48)

Note that PostgresQueryDao.scala:369 is:

serManifest = row.get("event_ser_manifest", classOf[String]),

Might be something similar to #512 if decoding is completely off track.
Might be a bug in r2dbc-mssql?

Maybe something similar noticed when running R2dbcJournalPerfSpec

[2024-02-02 07:35:16,015] [ERROR] [akka.persistence.journal.JournalPerfSpec$BenchActor] [akka://JournalSpec] [] [JournalSpec-akka.actor.default-dispatcher-9] - Persistence failure when replaying events for persistenceId [p-18]. Last known sequence number [5]
java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 3
	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4606)
	at java.base/java.lang.String.substring(String.java:2709)
	at akka.persistence.journal.JournalPerfSpec$CmdSerializer.fromBinary(JournalPerfSpec.scala:95)
	at akka.serialization.Serialization.$anonfun$deserializeByteArray$1(Serialization.scala:218)
	at akka.serialization.Serialization.withTransportInformation(Serialization.scala:157)
	at akka.serialization.Serialization.deserializeByteArray(Serialization.scala:216)
	at akka.serialization.Serialization.$anonfun$deserialize$5(Serialization.scala:206)
	at scala.util.Try$.apply(Try.scala:210)
	at akka.serialization.Serialization.deserialize(Serialization.scala:198)
	at akka.persistence.r2dbc.journal.R2dbcJournal$.deserializeRow(R2dbcJournal.scala:56)
	at akka.persistence.r2dbc.journal.R2dbcJournal.$anonfun$asyncReplayMessages$1(R2dbcJournal.scala:219)
	at akka.persistence.r2dbc.journal.R2dbcJournal.$anonfun$asyncReplayMessages$1$adapted(R2dbcJournal.scala:218)
@patriknw patriknw added bug Something isn't working sqlserver labels Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sqlserver
Projects
None yet
Development

No branches or pull requests

1 participant