8 Commits

Author SHA1 Message Date
6a0cf22b53 Revert "Postgres: Switch the datasource plugin from lib/pq to pgx (#103961)" (#106270)
This reverts commit 1e383b0c1e98734ad4bf974f0435512d10c33246.
2025-06-03 08:45:07 -04:00
1e383b0c1e Postgres: Switch the datasource plugin from lib/pq to pgx (#103961)
* Create libpqToPGX feature toggle

* Refactor PostgreSQL datasource to support PGX with feature toggle

- Updated `ProvideService` to accept feature toggles for enabling PGX.
- Modified integration tests to use the new PGX connection method.
- Introduced new functions for handling PGX connections and queries.
- Enhanced TLS configuration handling for PostgreSQL connections.
- Updated existing tests to ensure compatibility with PGX and new connection methods.

* Update PostgreSQL datasource to enhance connection pooling and error handling

- Increased `MaxOpenConns` to 10 in integration tests for improved connection management.
- Refactored connection handling in `newPostgresPGX` to return a connection pool instead of a single connection.
- Updated health check error handling to utilize context and feature toggles for better error reporting.
- Adjusted `DisposePGX` method to close the connection pool properly.
- Enhanced query execution to acquire connections from the pool, ensuring efficient resource usage.

* Cleanup

* Revert postgres_test unnecessary changes

* Rename feature toggle from `libpqToPGX` to `postgresDSUsePGX`

* Add null check to dispose method

* Fix lint issues

* Refactor connection string generation

* Address comment in health check file

* Rename p to pool

* Refactor executeQueryPGX and split into multiple functions

* Fix lint issues

* The returning error message from PGX is enough no need to separate the error code.

* Move TLS handling to newPostgresPGX function

* Disable ssl for integration tests

* Use MaxIdleConns option

* Remove old feature toggle

* Rename`generateConnectionConfigPGX` to `generateConnectionStringPGX`

* Add back part of the error messages

* Don't show max idle connections option when PGX enabled

* Address comments from Sriram

* Add back Sriram's changes

* PostgreSQL: Rework tls manager to use temporary files instead (#105330)

* Rework tls manager to use temporary files instead

* Lint and test fixes

* Update pkg/tsdb/grafana-postgresql-datasource/postgres.go

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>

* Update betterer

---------

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>

---------

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2025-05-26 08:54:18 +02:00
a8e87fc674 Postgres: Config diagnostics / logging update (#105666)
* config diagnostics update

* update tests

* fix typo
2025-05-22 08:27:36 +01:00
fcb1e9c9e5 Postgres: Improve invalid port specifier error during health check (#105536)
normalize error message in postgres invalid port specifier error
2025-05-16 11:51:12 +01:00
d48e9afd5d Datasources: Improved network health check error messages (sql datasources) (#97783)
remove unique identifiers from common network error messages
2024-12-11 13:05:06 +00:00
b4927ff1cd MS SQL: Datasource health check error message improvements (#97643)
improve mssql healthcheck error messages
2024-12-10 13:13:32 +00:00
16c78f6a98 Postgres: Datasource health check error message improvements #96906 (#96990)
* updated postgres health check error messages

* addressed review comments / added tests
2024-11-27 13:14:44 +00:00
492e7d4a3d Datasources: health check logging improvements (#96403)
* basic healthcheck logging

* show detailed error for admins

* fix linting errors

* fix config summary keys

* passing context to logger

* tracking health check errors

* remove tracking
2024-11-20 11:42:05 +00:00