fiware-cygnus icon indicating copy to clipboard operation
fiware-cygnus copied to clipboard

Schema creation fails when using Postgresql Sink

Open ueba-yuki opened this issue 2 years ago • 2 comments

When using Postgresql, the creation of the database schema fails. This occurs when there is no database matching the PostgreSQL user name.

As a specification of the Postgresql driver, if a connection is made without specifying a database name, it will attempt to connect to a database that matches the user name. The first time data is transferred using PostgreSQL Sink, it attempts to create a schema, but the code does not specify a database name and attempts to connect to a database that matches the user name. Therefore, if there is no database matching the user name, the connection creation will fail.

https://github.com/telefonicaid/fiware-cygnus/blob/master/cygnus-common/src/main/java/com/telefonica/iot/cygnus/backends/sql/SQLBackendImpl.java#L143

In the default state, the user name and database name are both postgres, so this bug is not noticed.

https://github.com/telefonicaid/fiware-cygnus/blob/master/cygnus-ngsi-ld/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIPostgreSQLSink.java#L47

ueba-yuki avatar Jul 04 '22 08:07 ueba-yuki

Could you please provide which configuration are you using for postgresql sink ?

AlvaroVega avatar Jul 27 '22 08:07 AlvaroVega

Could you please provide a link in postgresql driver documentation which describes this behavior "As a specification of the Postgresql driver, if a connection is made without specifying a database name, it will attempt to connect to a database that matches the user name." ?

AlvaroVega avatar Jul 27 '22 08:07 AlvaroVega