pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedNullPointerException in TypeInfoCache.getSQLType
6+ messages / 3 participants
[nested] [flat]
* NullPointerException in TypeInfoCache.getSQLType
@ 2016-02-17 13:50 Zachary Marshall <Zachary.Marshall@sas.com>
2016-02-17 14:20 ` Re: NullPointerException in TypeInfoCache.getSQLType Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Zachary Marshall @ 2016-02-17 13:50 UTC (permalink / raw)
To: pgsql-jdbc
Hello,
I am running into a NullPointerException in the Postgres JDBC driver. I am running driver version postgresql-9.4.1208.jre7-SNAPSHOT.jar?. I am running against Postgres server version "PostgreSQL 9.4.5 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit". The error occurs when I am starting up my Spring Boot application. Typically this is concurrent with the startup of several dozen other Spring Boot apps, all which use the same Postgres server, but each in an entirely different JVM. These concurrent startups all are typically creating new schemas (then tables and other things in those schemas). If the error occurs, restarting the Spring Boot app resolves it. I have searched google and the mailing list but didn't see any obvious hits (other than the mention of this revert from the 9.4-1205 changelog: https://github.com/pgjdbc/pgjdbc/pull/406)<https://github.com/pgjdbc/pgjdbc/pull/406;. The relevant part of the stack trace is at the end of the email. One possible cause I can imagine is that org.postgresql.jdbc.TypeInfoCache.getPGType(int) returns null (because oid == Oid.UNSPECIFIED)(https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/jdbc/TypeInfoCache....) and then org.postgresql.jdbc.TypeInfoCache.getSQLType(String) doesn't correctly handle this null (https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/jdbc/TypeInfoCache....).
Has anyone seen this before? Thanks in advance for any help.?
Caused by: java.lang.NullPointerException
at org.postgresql.jdbc.TypeInfoCache.getSQLType(TypeInfoCache.java:182)
at org.postgresql.jdbc.TypeInfoCache.getSQLType(TypeInfoCache.java:178)
at org.postgresql.jdbc.TypeInfoCache.requiresQuoting(TypeInfoCache.java:851)
at org.postgresql.jdbc.PgDatabaseMetaData.getTypeInfo(PgDatabaseMetaData.java:2785)
at org.hibernate.engine.jdbc.spi.TypeInfo.extractTypeInfo(TypeInfo.java:101)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:163)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1887)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
... 22 more
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: NullPointerException in TypeInfoCache.getSQLType
2016-02-17 13:50 NullPointerException in TypeInfoCache.getSQLType Zachary Marshall <Zachary.Marshall@sas.com>
@ 2016-02-17 14:20 ` Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
2016-02-17 14:24 ` Re: NullPointerException in TypeInfoCache.getSQLType Zachary Marshall <Zachary.Marshall@sas.com>
0 siblings, 1 reply; 6+ messages in thread
From: Vladimir Sitnikov @ 2016-02-17 14:20 UTC (permalink / raw)
To: Zachary Marshall <Zachary.Marshall@sas.com>; +Cc: pgsql-jdbc
Do you have a reproducer?
Can you check if you have types with typname of null?
select * from pg_catalog.pg_type t where t.typname is null
> all are typically creating new schemas
Can it be like:
1) org.postgresql.jdbc.PgDatabaseMetaData#getTypeInfo loads all the type ids
2) as it reaches org.postgresql.jdbc.TypeInfoCache#getPGType(int), the
type is no longer in the DB (e.g. dropped)
?
Can you add logging to TypeInfoCache#getPGType & rebuild & test to log
the actual oid in question?
Vladimir
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: NullPointerException in TypeInfoCache.getSQLType
2016-02-17 13:50 NullPointerException in TypeInfoCache.getSQLType Zachary Marshall <Zachary.Marshall@sas.com>
2016-02-17 14:20 ` Re: NullPointerException in TypeInfoCache.getSQLType Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
@ 2016-02-17 14:24 ` Zachary Marshall <Zachary.Marshall@sas.com>
2016-02-17 14:50 ` Re: NullPointerException in TypeInfoCache.getSQLType Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Zachary Marshall @ 2016-02-17 14:24 UTC (permalink / raw)
To: Vladimir Sitnikov <sitnikov.vladimir@gmail.com>; +Cc: pgsql-jdbc
It will be hard to supply a reproducer since it seems to require lots of concurrent startups, but I will see if I can simplify the reproducible case.
Your explanation seems plausible. I will add the suggested logging and rebuild and test to log the oid and other information. It will probably be a few days before I have those results.
Thanks for your suggestions and time,
Zach Marshall
-----Original Message-----
From: Vladimir Sitnikov [mailto:sitnikov.vladimir@gmail.com]
Sent: Wednesday, February 17, 2016 9:20 AM
To: Zachary Marshall <Zachary.Marshall@sas.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] NullPointerException in TypeInfoCache.getSQLType
Do you have a reproducer?
Can you check if you have types with typname of null?
select * from pg_catalog.pg_type t where t.typname is null
> all are typically creating new schemas
Can it be like:
1) org.postgresql.jdbc.PgDatabaseMetaData#getTypeInfo loads all the type ids
2) as it reaches org.postgresql.jdbc.TypeInfoCache#getPGType(int), the type is no longer in the DB (e.g. dropped) ?
Can you add logging to TypeInfoCache#getPGType & rebuild & test to log the actual oid in question?
Vladimir
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: NullPointerException in TypeInfoCache.getSQLType
2016-02-17 13:50 NullPointerException in TypeInfoCache.getSQLType Zachary Marshall <Zachary.Marshall@sas.com>
2016-02-17 14:20 ` Re: NullPointerException in TypeInfoCache.getSQLType Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
2016-02-17 14:24 ` Re: NullPointerException in TypeInfoCache.getSQLType Zachary Marshall <Zachary.Marshall@sas.com>
@ 2016-02-17 14:50 ` Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
2016-03-07 15:20 ` Re: NullPointerException in TypeInfoCache.getSQLType Stephanie Smith <Stephanie.Smith@sas.com>
0 siblings, 1 reply; 6+ messages in thread
From: Vladimir Sitnikov @ 2016-02-17 14:50 UTC (permalink / raw)
To: Zachary Marshall <Zachary.Marshall@sas.com>; +Cc: pgsql-jdbc
>It will be hard to supply a reproducer since it seems to require lots of concurrent startups
Blind guess would be: a two-threaded test.
Thread 1: create & drop table in a loop
Thread 2: PgDatabaseMetaData.getTypeInfo & clear cache in a loop
>Your explanation seems plausible. I will add the suggested logging
That would be awesome.
Vladimir
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: NullPointerException in TypeInfoCache.getSQLType
2016-02-17 13:50 NullPointerException in TypeInfoCache.getSQLType Zachary Marshall <Zachary.Marshall@sas.com>
2016-02-17 14:20 ` Re: NullPointerException in TypeInfoCache.getSQLType Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
2016-02-17 14:24 ` Re: NullPointerException in TypeInfoCache.getSQLType Zachary Marshall <Zachary.Marshall@sas.com>
2016-02-17 14:50 ` Re: NullPointerException in TypeInfoCache.getSQLType Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
@ 2016-03-07 15:20 ` Stephanie Smith <Stephanie.Smith@sas.com>
2016-03-07 17:21 ` Re: NullPointerException in TypeInfoCache.getSQLType Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Stephanie Smith @ 2016-03-07 15:20 UTC (permalink / raw)
To: Zachary Marshall <Zachary.Marshall@sas.com>; sitnikov.vladimir@gmail.com <sitnikov.vladimir@gmail.com>; +Cc: pgsql-jdbc
Vladimir
I am able to reproduce the NullPointerException with a standalone test.
I have created the following repository with the test case, https://github.com/stephraleigh/postgres-jdbc-npe-rep
Please let me know if you are able to clone and reproduce the NPE.
Thanks
Steph
-----Original Message-----
From: Vladimir Sitnikov [mailto:sitnikov.vladimir@gmail.com]
Sent: Wednesday, February 17, 2016 9:50 AM
To: Zachary Marshall <Zachary.Marshall@sas.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] NullPointerException in TypeInfoCache.getSQLType
>It will be hard to supply a reproducer since it seems to require lots of concurrent startups
Blind guess would be: a two-threaded test.
Thread 1: create & drop table in a loop
Thread 2: PgDatabaseMetaData.getTypeInfo & clear cache in a loop
>Your explanation seems plausible. I will add the suggested logging
That would be awesome.
Vladimir
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: NullPointerException in TypeInfoCache.getSQLType
2016-02-17 13:50 NullPointerException in TypeInfoCache.getSQLType Zachary Marshall <Zachary.Marshall@sas.com>
2016-02-17 14:20 ` Re: NullPointerException in TypeInfoCache.getSQLType Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
2016-02-17 14:24 ` Re: NullPointerException in TypeInfoCache.getSQLType Zachary Marshall <Zachary.Marshall@sas.com>
2016-02-17 14:50 ` Re: NullPointerException in TypeInfoCache.getSQLType Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
2016-03-07 15:20 ` Re: NullPointerException in TypeInfoCache.getSQLType Stephanie Smith <Stephanie.Smith@sas.com>
@ 2016-03-07 17:21 ` Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: Vladimir Sitnikov @ 2016-03-07 17:21 UTC (permalink / raw)
To: Stephanie Smith <Stephanie.Smith@sas.com>; +Cc: Zachary Marshall <Zachary.Marshall@sas.com>; pgsql-jdbc
Thanks for the reproducer.
I've implemented a fix here: https://github.com/pgjdbc/pgjdbc/pull/530
There are other similar places when type information is loaded by
using several queries.
For example: getProcedureColumns, however it is likely to be used with
some reasonable
schema/procedure patterns, thus it is less likely to fail.
Vladimir
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2016-03-07 17:21 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-02-17 13:50 NullPointerException in TypeInfoCache.getSQLType Zachary Marshall <Zachary.Marshall@sas.com>
2016-02-17 14:20 ` Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
2016-02-17 14:24 ` Zachary Marshall <Zachary.Marshall@sas.com>
2016-02-17 14:50 ` Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
2016-03-07 15:20 ` Stephanie Smith <Stephanie.Smith@sas.com>
2016-03-07 17:21 ` Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox