Set Postgres statement_timeout in JDBC connection options

I'm trying to set the postgres statement_timeout using the Additional JDBC connection string options, but it doesn't seem to be taking effect. I've tested the option using JDBC connection string options in DBeaver, which I believe uses the same driver, and it works, -c statement_timeout=300000.

The error I am getting in the logs is ERROR: canceling statement due to statement timeout.

Is there something I have to do to get the connections in the connection pool to pickup these changes? Restart metabase or something?

Below is my Dianostic Info

    {
  "browser-info": {
    "language": "en-US",
    "platform": "MacIntel",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.83 Safari/537.36",
    "vendor": "Google Inc."
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "11.0.13+8",
    "java.vendor": "Eclipse Adoptium",
    "java.vendor.url": "https://adoptium.net/",
    "java.version": "11.0.13",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "11.0.13+8",
    "os.name": "Linux",
    "os.version": "4.14.262-200.489.amzn2.x86_64",
    "user.language": "en",
    "user.timezone": "GMT"
  },
  "metabase-info": {
    "databases": [
      "postgres",
      "googleanalytics",
      "bigquery"
    ],
    "hosting-env": "unknown",
    "application-database": "postgres",
    "application-database-details": {
      "database": {
        "name": "PostgreSQL",
        "version": "9.6.22"
      },
      "jdbc-driver": {
        "name": "PostgreSQL JDBC Driver",
        "version": "42.2.23"
      }
    },
    "run-mode": "prod",
    "version": {
      "date": "2021-12-16",
      "tag": "v0.41.5",
      "branch": "release-x.41.x",
      "hash": "fbfffc6"
    },
    "settings": {
      "report-timezone": "UTC"
    }
  }
}

Hi @metabaserules
What exactly are you inputting into the connection string? This should work:
options=-c statement_timeout=300000
For reference: https://jdbc.postgresql.org/documentation/head/connect.html
When you change any settings in the connection, then it restarts the pool to pick up the changes.

I knew I was missing something obvious, I wasn't including the options=. Thanks for the help.

@flamber @metabaserules

I tried the exact same thing, but it didn't work for me!

I tried setting the Additional JDBC connection string options to both:

  • options=-c statement_timeout=600000
  • options=-c%20statement_timeout=600000 (since the docs specify that postgres connection URLs use percent-encoding)
  • -c statement_timeout=600000
  • -c%20statement_timeout=600000

But none of them worked.
Any thoughts? Could you share the exact value you tried?

We're on metabase version 1.46.6.4