Skip to content

error in Postgres when setting a small prepared statement cache size #672

@gavinking

Description

@gavinking

If I set the prepared statement cache size to 32, I get this, the very first time I get a hit on the cache:

select cascadecom0_.id as id1_0_0_, cascadecom0_.uuid as uuid2_0_0_, cascadecom0_.c_id as c_id3_0_0_, cascadecom0_.d_id as d_id4_0_0_ from B cascadecom0_ where cascadecom0_.id=?
select cascadecom0_.id as id1_0_3_, cascadecom0_.uuid as uuid2_0_3_, cascadecom0_.c_id as c_id3_0_3_, cascadecom0_.d_id as d_id4_0_3_, cascadecom1_.id as id1_1_0_, cascadecom1_.uuid as uuid2_1_0_, dcollectio2_.c_id as c_id3_2_5_, dcollectio2_.id as id1_2_5_, dcollectio2_.id as id1_2_1_, dcollectio2_.uuid as uuid2_2_1_, dcollectio2_.c_id as c_id3_2_1_, dcollectio2_.e_id as e_id4_2_1_, cascadecom3_.id as id1_2_2_, cascadecom3_.uuid as uuid2_2_2_, cascadecom3_.c_id as c_id3_2_2_, cascadecom3_.e_id as e_id4_2_2_ from B cascadecom0_ inner join C cascadecom1_ on cascadecom0_.c_id=cascadecom1_.id left outer join D dcollectio2_ on cascadecom1_.id=dcollectio2_.c_id inner join D cascadecom3_ on cascadecom0_.d_id=cascadecom3_.id where cascadecom0_.id=?
select cascadecom0_.id as id1_0_0_, cascadecom0_.uuid as uuid2_0_0_, cascadecom0_.c_id as c_id3_0_0_, cascadecom0_.d_id as d_id4_0_0_ from B cascadecom0_ where cascadecom0_.id=?
java.lang.NullPointerException
	at io.vertx.sqlclient.impl.SqlResultHandler.complete(SqlResultHandler.java:93)
	at io.vertx.sqlclient.impl.SqlResultHandler.handle(SqlResultHandler.java:86)
	at io.vertx.sqlclient.impl.SqlResultHandler.handle(SqlResultHandler.java:33)
	at io.vertx.sqlclient.impl.SqlConnectionImpl.lambda$schedule$0(SqlConnectionImpl.java:52)
	at io.vertx.sqlclient.impl.SocketConnectionBase.handleMessage(SocketConnectionBase.java:188)
	at io.vertx.sqlclient.impl.SocketConnectionBase.lambda$init$0(SocketConnectionBase.java:78)
	at io.vertx.core.net.impl.NetSocketImpl.lambda$new$2(NetSocketImpl.java:101)
	at io.vertx.core.streams.impl.InboundBuffer.handleEvent(InboundBuffer.java:237)
	at io.vertx.core.streams.impl.InboundBuffer.emitPending(InboundBuffer.java:185)
	at io.vertx.core.streams.impl.InboundBuffer.write(InboundBuffer.java:128)
	at io.vertx.core.net.impl.NetSocketImpl.handleMessage(NetSocketImpl.java:357)
	at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366)
	at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:43)
	at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:229)
	at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:173)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
	at io.vertx.pgclient.impl.codec.PgEncoder.lambda$write$0(PgEncoder.java:78)
	at io.vertx.pgclient.impl.codec.PgCommandCodec.handleReadyForQuery(PgCommandCodec.java:136)
	at io.vertx.pgclient.impl.codec.PrepareStatementCommandCodec.handleReadyForQuery(PrepareStatementCommandCodec.java:76)
	at io.vertx.pgclient.impl.codec.PgDecoder.decodeReadyForQuery(PgDecoder.java:227)
	at io.vertx.pgclient.impl.codec.PgDecoder.channelRead(PgDecoder.java:86)
	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:745)
[2020-06-02 20:40:05] WARNING io.vertx.pgclient.impl.codec.PgCommandCodec             CloseStatementCommandCodec should handle message ParseComplete
[2020-06-02 20:40:05] WARNING io.vertx.pgclient.impl.codec.PgCommandCodec             CloseStatementCommandCodec should handle message BindComplete
12032 ERROR org.hibernate.reactive.errors  - failed to execute statement [select cascadecom0_.id as id1_0_3_, cascadecom0_.uuid as uuid2_0_3_, cascadecom0_.c_id as c_id3_0_3_, cascadecom0_.d_id as d_id4_0_3_, cascadecom1_.id as id1_1_0_, cascadecom1_.uuid as uuid2_1_0_, dcollectio2_.c_id as c_id3_2_5_, dcollectio2_.id as id1_2_5_, dcollectio2_.id as id1_2_1_, dcollectio2_.uuid as uuid2_2_1_, dcollectio2_.c_id as c_id3_2_1_, dcollectio2_.e_id as e_id4_2_1_, cascadecom3_.id as id1_2_2_, cascadecom3_.uuid as uuid2_2_2_, cascadecom3_.c_id as c_id3_2_2_, cascadecom3_.e_id as e_id4_2_2_ from B cascadecom0_ inner join C cascadecom1_ on cascadecom0_.c_id=cascadecom1_.id left outer join D dcollectio2_ on cascadecom1_.id=dcollectio2_.c_id inner join D cascadecom3_ on cascadecom0_.d_id=cascadecom3_.id where cascadecom0_.id=?]
12034 ERROR org.hibernate.reactive.errors  - could not load an entity: [org.hibernate.reactive.CascadeComplicatedTest$B#1]
java.util.concurrent.CompletionException: java.lang.ClassCastException: io.vertx.pgclient.impl.codec.CloseStatementCommandCodec cannot be cast to io.vertx.pgclient.impl.codec.QueryCommandBaseCodec
	at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292)
	at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308)
	at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:593)
	at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577)
	at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
	at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977)
	at org.hibernate.reactive.pool.impl.Handlers.lambda$toCompletionStage$0(Handlers.java:29)
	at io.vertx.sqlclient.impl.SqlResultHandler.fail(SqlResultHandler.java:102)
	at io.vertx.sqlclient.impl.SqlResultHandler.handle(SqlResultHandler.java:88)
	at io.vertx.sqlclient.impl.SqlResultHandler.handle(SqlResultHandler.java:33)
	at io.vertx.sqlclient.impl.SqlConnectionImpl.lambda$schedule$0(SqlConnectionImpl.java:52)
	at io.vertx.sqlclient.impl.SocketConnectionBase.handleMessage(SocketConnectionBase.java:188)
	at io.vertx.sqlclient.impl.SocketConnectionBase.lambda$init$0(SocketConnectionBase.java:78)
	at io.vertx.core.net.impl.NetSocketImpl.lambda$new$2(NetSocketImpl.java:101)
	at io.vertx.core.streams.impl.InboundBuffer.handleEvent(InboundBuffer.java:237)
	at io.vertx.core.streams.impl.InboundBuffer.write(InboundBuffer.java:127)
	at io.vertx.core.net.impl.NetSocketImpl.handleMessage(NetSocketImpl.java:357)
	at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366)
	at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:43)
	at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:229)
	at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:173)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.vertx.pgclient.impl.codec.PgCodec.fail(PgCodec.java:50)
	at io.vertx.pgclient.impl.codec.PgCodec.exceptionCaught(PgCodec.java:40)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:381)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: io.vertx.pgclient.impl.codec.CloseStatementCommandCodec cannot be cast to io.vertx.pgclient.impl.codec.QueryCommandBaseCodec
	at io.vertx.pgclient.impl.codec.PgDecoder.decodeDataRow(PgDecoder.java:186)
	at io.vertx.pgclient.impl.codec.PgDecoder.channelRead(PgDecoder.java:90)
	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	... 15 more

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions