The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Pool error fix (#77212)
Alexander Polyankin5e05b04e53c4
diff --git a/src/metabase/query_processor/middleware/catch_exceptions.clj b/src/metabase/query_processor/middleware/catch_exceptions.cljindex 6a0de6da57c..dd4a94ae7a5 100644--- a/src/metabase/query_processor/middleware/catch_exceptions.clj+++ b/src/metabase/query_processor/middleware/catch_exceptions.clj@@ -142,8 +142,10 @@;; format the Exception and return it(let [formatted-exception (format-exception* query e @extra-info)query-canceled? (some (comp :query/query-canceled? ex-data)- (u/full-exception-chain e))]- (when-not query-canceled?+ (u/full-exception-chain e))+ pool-saturated? (qp.error-type/connection-pool-saturated?+ (:error_type formatted-exception))]+ (when-not (or query-canceled? pool-saturated?)(log/errorf "Error processing query: %s\n%s"(or (:error formatted-exception) "Error running query")(u/pprint-to-str formatted-exception)))diff --git a/test/metabase/query_processor/middleware/catch_exceptions_test.clj b/test/metabase/query_processor/middleware/catch_exceptions_test.cljindex 6b4a954d6a9..ce6272adeea 100644--- a/test/metabase/query_processor/middleware/catch_exceptions_test.clj+++ b/test/metabase/query_processor/middleware/catch_exceptions_test.clj@@ -127,6 +127,24 @@:data {:cols []}}(catch-exceptions (fn [] (throw (Exception. "Something went wrong"))))))))+(deftest ^:synchronized connection-pool-saturated-not-logged-test+ (testing "connection-pool saturation is transient load shedding: fail the query (503 for clients) but don't log an error"+ (doseq [error-type [qp.error-type/connection-pool-checkout-timeout+ qp.error-type/connection-pool-checkout-queue-full]]+ (testing error-type+ (mt/with-log-messages-for-level [messages [metabase.query-processor.middleware.catch-exceptions :error]]+ (is (=? {:status :failed+ :error_type error-type+ :error "The pool is full"}+ (catch-exceptions (fn [] (throw (ex-info "The pool is full" {:type error-type}))))))+ (is (empty? (messages)))))))+ (testing "control: other errors still log"+ (mt/with-log-messages-for-level [messages [metabase.query-processor.middleware.catch-exceptions :error]]+ (is (=? {:status :failed}+ (catch-exceptions (fn [] (throw (Exception. "Something went wrong"))))))+ (is (=? [{:level :error, :message #"(?s)^Error processing query.*"}]+ (messages))))))+(deftest ^:parallel catch-exceptions-test(testing "include-query-execution-info-test"(testing "Should include info from QueryExecution if added to the thrown/raised Exception"