Skip to content

Commit

Permalink
Merge pull request #1601 from Permify/fix-rds-proxy-connection-bug-1340
Browse files Browse the repository at this point in the history
fix: plan_cache_mode issue for RDS Proxy
  • Loading branch information
tolgaOzen committed Sep 17, 2024
2 parents a8076ff + 9353871 commit fa43f8c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/database/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,21 @@ func setDefaultQueryExecMode(config *pgx.ConnConfig) {
var planCacheModes = map[string]string{
"auto": "auto",
"force_custom_plan": "force_custom_plan",
"disable": "disable",
}

func setPlanCacheMode(config *pgx.ConnConfig) {
// Default mode if no specific mode is found in the connection string
defaultMode := "auto"

// Check if a plan cache mode is mentioned in the connection string and set it
for key := range planCacheModes {
if strings.Contains(config.ConnString(), "plan_cache_mode="+key) {
if key == "disable" {
delete(config.Config.RuntimeParams, "plan_cache_mode")
slog.Info("plan_cache_mode disabled")
return
}
config.Config.RuntimeParams["plan_cache_mode"] = planCacheModes[key]
slog.Info("setPlanCacheMode", slog.String("mode", key))
return
Expand Down

0 comments on commit fa43f8c

Please sign in to comment.