22 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
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
7ce7584151 postgres: decouple sqleng (#86055) 2024-04-15 14:28:03 +02:00
8a15ed42ae PostgreSQL: Fix the verify-ca mode (#85530)
postgres: fix the verify-ca problem
2024-04-09 08:39:45 +02:00
8159e1db3a Revert "Postgres: Switch the datasource plugin from lib/pq to pgx (#8… (#85509)
Revert "Postgres: Switch the datasource plugin from lib/pq to pgx (#83768)"

This reverts commit ecd6de826a315526ed5fac0ce9e70f9f50e217c8.
2024-04-03 11:02:22 +02:00
ecd6de826a Postgres: Switch the datasource plugin from lib/pq to pgx (#83768)
postgres: switch from lib/pq to pgx
2024-03-13 09:52:39 +01:00
142ac22023 Revert "Postgres: Switch the datasource plugin from lib/pq to pgx" (#83760)
Revert "Postgres: Switch the datasource plugin from lib/pq to pgx (#81353)"

This reverts commit 8c18d06386c87f2786119ea9a6334e35e4181cbe.
2024-03-01 12:20:47 +01:00
8c18d06386 Postgres: Switch the datasource plugin from lib/pq to pgx (#81353)
* postgres: switch from lib/pq to pgx

* postgres: improved tls handling
2024-02-28 07:52:45 +01:00
ae77fe3602 postgres: do not use unexported grafana-core config (#83241)
* postgres: do not use unexported grafana-core config

* fixed wrong value
2024-02-22 16:47:03 +01:00
4c221966e4 postgres: socks proxy: use plugin-sdk (#82376) 2024-02-14 13:05:31 +01:00
67f006a91d sql: remove setting-import from sqleng (#82088) 2024-02-12 12:37:23 +01:00
2332bfb007 Set DatasourceName and DatasourceType in proxy.Options (#80923)
* Set DatasourceName and DatasourceType in proxy.Options

* upgrade github.com/grafana/grafana-plugin-sdk-go to v0.206.0 and fix merge conflicts
2024-02-01 11:09:58 -03:00
b1d1aa667a postgres: refactor code that is called by tests (#81279)
* postgres: refactor code that is called by tests too

* removed debug log
2024-01-26 09:11:25 +01:00
2bf56b12cf postgres: simplify proxy code (#80121) 2024-01-17 09:20:27 +01:00
6a36525d61 postgres: better error handling (#80375) 2024-01-15 12:50:01 +01:00
bfb85f27b1 sql: improve sqleng-api, leave sql.DB creation to the plugins (#79672) 2024-01-05 08:37:15 +01:00
53863c52ca sql: use logging functionality from plugin-sdk (#79294) 2023-12-14 09:42:06 +01:00
92044a9009 postgres: refactor logs-handling (#79147)
* postgres: refactor logs-handling

* fixed unit test
2023-12-07 13:18:49 +01:00
2d391c1bf5 postgresql: change plugin id (#77444)
* postgres: change plugin id

* fixed cue file

* codeowners update

* fixed backend test
2023-11-13 08:49:26 +01:00