ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
137 stars 58 forks source link

[Ballerina Persist] Error when connecting to PostgreSQL on AWS #6931

Open abeykoon opened 1 month ago

abeykoon commented 1 month ago

Description: When PosgreySQL connector is used with Bal persist, it cannot connect to Azure hosted PostgreSQL instance out of the box.

Steps to reproduce:

  1. Write a code using generated persist_client
  2. Point the code to Azure hosted PostgreSQL instance (can use a private account for testing) using Config.toml file. Do not configure anything for connection options. Keep it as default.
  3. Run the code

You will see an exception like below

error: Error in SQL connector configuration: Failed to initialize pool: FATAL: no pg_hba.conf entry for host "172.18.128.15", user "choreo_workflow_mgt_db_user", database "choreo_workflow_mgt_db", no encryption Caused by :FATAL: no pg_hba.conf entry for host "172.18.128.15", user "choreo_workflow_mgt_db_user", database "choreo_workflow_mgt_db", no encryption

Affected Versions:

Ballerina 2201.9.2

OS, DB, other environment details and versions:

MAC OS Azure PostgreSQL

Analysis

It seems like the generated code for bal persist passes empty record by default for options. When null is passed, it works. Maybe the underneath java client sends some default options and by passing {} we just override them?

image