fiware-cygnus
fiware-cygnus copied to clipboard
Schema creation fails when using Postgresql Sink
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
Could you please provide which configuration are you using for postgresql sink ?
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." ?