diff --git a/.github/actions/github-script-tests/action.yml b/.github/actions/github-script-tests/action.yml index 2d2a310a9ef..7dd4f56866e 100644 --- a/.github/actions/github-script-tests/action.yml +++ b/.github/actions/github-script-tests/action.yml @@ -25,6 +25,9 @@ runs: - name: Run enterprise license check tests shell: bash run: python3 scripts/check-enterprise-license-test.py + - name: Run snafu variant check tests + shell: bash + run: python3 scripts/check-snafu-test.py - name: Run fuzz orchestration script tests shell: bash run: .github/scripts/run-fuzz-targets-test.sh diff --git a/Cargo.lock b/Cargo.lock index 2b5ad408991..24d13caa688 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2042,37 +2042,29 @@ dependencies = [ "async-stream", "async-trait", "base64 0.22.1", - "cache", "chrono", "clap", "client", "common-base", "common-catalog", - "common-config", "common-datasource", "common-error", "common-grpc", "common-macro", "common-meta", - "common-procedure", - "common-runtime", "common-telemetry", "common-test-util", - "common-time", "common-wal", "datatypes", - "etcd-client", "fs2", "futures", "humantime", "indicatif", - "meta-client", "meta-srv", "object-store", "operator", "partition", "paste", - "query", "rand 0.9.4", "reqwest 0.13.4", "serde", @@ -2209,7 +2201,6 @@ dependencies = [ "datafusion-physical-plan", "datanode", "datatypes", - "etcd-client", "file-engine", "flow", "frontend", @@ -4601,7 +4592,6 @@ dependencies = [ "query", "rand 0.9.4", "relational-engine", - "reqwest 0.13.4", "serde", "serde_json", "servers", @@ -8662,7 +8652,6 @@ dependencies = [ "common-workload", "dashmap", "datatypes", - "deadpool", "deadpool-postgres", "derive_builder 0.20.2", "either", @@ -13865,7 +13854,6 @@ dependencies = [ "moka", "mysql_async", "mysql_common 0.38.2", - "notify", "object-pool", "once_cell", "opensrv-mysql", @@ -15215,7 +15203,6 @@ dependencies = [ "common-macro", "common-query", "common-recordbatch", - "common-sql", "common-telemetry", "common-test-util", "common-time", diff --git a/scripts/check-snafu-test.py b/scripts/check-snafu-test.py new file mode 100644 index 00000000000..c7a7e4aefd0 --- /dev/null +++ b/scripts/check-snafu-test.py @@ -0,0 +1,87 @@ +# Copyright 2023 Greptime Team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import importlib.util +import textwrap +import unittest +from pathlib import Path + +SCRIPT_PATH = Path(__file__).resolve().parent / "check-snafu.py" + +spec = importlib.util.spec_from_file_location("check_snafu", SCRIPT_PATH) +checker = importlib.util.module_from_spec(spec) +spec.loader.exec_module(checker) + +ERROR_FILE = "/repo/src/a/src/error.rs" +CRATE = ("/repo/src/a", "a") +ERROR_ENUM = """ + pub enum Error { + #[snafu(display("Broken ({path})"))] + Broken { path: String, source: std::io::Error }, + } + + impl ErrorExt for Error { + fn status_code(&self) -> StatusCode { + match self { + Error::Broken { .. } => StatusCode::Internal, + } + } + } +""" + + +def is_used(error_file_extra="", **other_files): + files = {ERROR_FILE: textwrap.dedent(ERROR_ENUM + error_file_extra)} + files.update( + {path: textwrap.dedent(content) for path, content in other_files.items()} + ) + return checker.is_used(ERROR_FILE, "Error", "Broken", CRATE, files) + + +class CheckSnafuTest(unittest.TestCase): + def test_finds_variant_whose_display_has_parentheses(self): + self.assertEqual( + list(checker.extract_variants(textwrap.dedent(ERROR_ENUM))), + [("Error", "Broken")], + ) + + def test_match_arm_is_not_a_use(self): + self.assertFalse(is_used()) + + def test_helper_in_error_file_builds_variant(self): + for construction in [ + "Error::Broken { path, source }", + 'Error::Broken { path: format!("failed: {reason}"), source }', + 'Error::Broken { path: "../data".to_string(), source }', + "Error::Broken { path: Path { parts: vec![] }.to_string(), source }", + "read().map_err(|source| Error::Broken { path, source })", + ]: + with self.subTest(construction): + self.assertTrue(is_used(f"fn broken() -> Error {{ {construction} }}\n")) + + def test_or_pattern_is_not_a_use(self): + arms = "fn f(e: &Error) { match e { Error::Broken { path, source } | Error::Other => {} } }\n" + self.assertFalse(is_used(arms)) + + def test_same_named_selector_of_another_crate_is_not_a_use(self): + other = "use crate::error::BrokenSnafu;\nuse a::error::Result;\n" + self.assertFalse(is_used(**{"/repo/src/b/src/lib.rs": other})) + + def test_selector_through_module_alias_is_a_use(self): + other = "use a::error as a_error;\nfn f() { g().context(a_error::BrokenSnafu { path }) }\n" + self.assertTrue(is_used(**{"/repo/src/b/src/lib.rs": other})) + + +if __name__ == "__main__": + unittest.main() diff --git a/scripts/check-snafu.py b/scripts/check-snafu.py index 662f6758d53..a0e7f43fef6 100644 --- a/scripts/check-snafu.py +++ b/scripts/check-snafu.py @@ -16,56 +16,173 @@ import os import re from multiprocessing import Pool +ENUM_PATTERN = re.compile(r"\benum\s+(\w+)") +# The display arguments may contain `)` inside string literals. +VARIANT_PATTERN = re.compile( + r'#\[snafu\(display\((?:"(?:\\.|[^"\\])*"|[^"])*?\)\)\]\s*(?:#\[[^\]]*\]\s*)*(\w+)\s*\{' +) + def find_rust_files(directory): - error_files = [] - other_rust_files = [] + rust_files = [] for root, _, files in os.walk(directory): for file in files: - if file == "error.rs": - error_files.append(os.path.join(root, file)) - elif file.endswith(".rs"): - other_rust_files.append(os.path.join(root, file)) - return error_files, other_rust_files + if file.endswith(".rs"): + rust_files.append(os.path.abspath(os.path.join(root, file))) + return rust_files -def extract_branch_names(file_content): - pattern = re.compile(r"#\[snafu\(display\([^\)]*\)\)\]\s*(\w+)\s*\{") - return pattern.findall(file_content) +def crate_of(path): + """Returns the (root directory, library name) of the crate that contains `path`.""" + directory = os.path.dirname(os.path.abspath(path)) + while not os.path.exists(os.path.join(directory, "Cargo.toml")): + directory = os.path.dirname(directory) + with open(os.path.join(directory, "Cargo.toml"), "r") as file: + name = re.search(r'^name\s*=\s*"([^"]+)"', file.read(), re.MULTILINE).group(1) + return directory, name.replace("-", "_") -def check_snafu_in_files(branch_name, rust_files_content): - branch_name_snafu = f"{branch_name}Snafu" - for content in rust_files_content.values(): - if branch_name_snafu in content: +def extract_variants(file_content): + """Yields (enum, variant) for every variant with a snafu display.""" + enums = [(m.start(), m.group(1)) for m in ENUM_PATTERN.finditer(file_content)] + for m in VARIANT_PATTERN.finditer(file_content): + enum = [name for start, name in enums if start < m.start()][-1] + yield enum, m.group(1) + + +def error_module_paths(crate_name, content): + """Returns the paths through which `content` refers to `crate_name`'s error module.""" + paths = [f"{crate_name}::error"] + for m in re.finditer( + rf"\buse\s+{crate_name}::(?:error(?:\s+as\s+(\w+))?\s*;|error::\{{\s*self\b(?:\s+as\s+(\w+))?" + rf"|\{{[^}}]*\berror\b(?:\s+as\s+(\w+))?)", + content, + ): + paths.append(next((alias for alias in m.groups() if alias), "error")) + return paths + + +LITERAL_PATTERN = re.compile(r'"(?:\\.|[^"\\])*"|\'(?:\\.|[^\'\\])\'') + + +def struct_body(content, open_brace): + """Splits the struct body starting at `open_brace` into its top-level fields. + + Returns the fields and the index of the closing brace, or None if the body is unclosed. + String and char literals are skipped, so braces and commas inside them do not count. + """ + fields, field, depth, i = [], "", 0, open_brace + while i < len(content): + literal = LITERAL_PATTERN.match(content, i) + if literal: + field += literal.group() + i = literal.end() + continue + c = content[i] + if c in "{([": + depth += 1 + elif c in "})]": + depth -= 1 + if depth == 0: + fields.append(field.strip()) + return [f for f in fields if f], i + if depth == 1 and c in "{,": + if c == ",": + fields.append(field.strip()) + field = "" + else: + field += c + i += 1 + return None + + +def builds_variant(enum, variant, content): + """Returns whether `content` builds `variant` with a struct expression, not a pattern.""" + for m in re.finditer(rf"\b(?:{enum}|Self)::{variant}\s*\{{", content): + body = struct_body(content, m.end() - 1) + if body is None: + continue + fields, close = body + # An alternative of an or-pattern is always followed by `|`, `=>` or a guard. + after = content[close + 1 :].lstrip() + is_pattern = (fields and fields[-1] == "..") or after.startswith( + ("=>", "|", "if ") + ) + if not is_pattern: + return True + return False + + +def is_used(error_file, enum, variant, crate, rust_files_content): + crate_root, crate_name = crate + # Match arms in the error file are not uses, but a helper there may build the variant, and a + # macro may take it, e.g. `define_from_tonic_status!(Error, X)`. + error_file_content = rust_files_content[error_file] + if re.search( + rf"\b{variant}Snafu\b|\b{enum},\s*{variant}\b", error_file_content + ) or builds_variant(enum, variant, error_file_content): + return True + crate_uses = re.compile(rf"\b({variant}Snafu|{enum}::{variant}|Self::{variant})\b") + imported_selector = re.compile( + rf"\b{crate_name}::error::\{{[^}}]*\b{variant}Snafu\b" + ) + for path, content in rust_files_content.items(): + if path == error_file or variant not in content: + continue + if path.startswith(crate_root + os.sep): + if crate_uses.search(content): + return True + continue + # Other crates may define variants with the same names, so a use there must go through + # this crate's error module: an imported selector, a path, or `Self::X` in a `From` impl. + if crate_name not in content: + continue + if imported_selector.search(content): + return True + modules = "|".join(map(re.escape, error_module_paths(crate_name, content))) + if re.search( + rf"\b(?:{modules})::(?:{variant}Snafu|{enum}::{variant})\b", content + ): + return True + if f"for {crate_name}::error::{enum}" in content and re.search( + rf"\bSelf::{variant}\b", content + ): return True return False def main(): - error_files, other_rust_files = find_rust_files(".") - branch_names = [] - - for error_file in error_files: - with open(error_file, "r") as file: - branch_names.extend(extract_branch_names(file.read())) - # Read all rust files into memory once rust_files_content = {} - for rust_file in other_rust_files: + for rust_file in find_rust_files("."): with open(rust_file, "r") as file: rust_files_content[rust_file] = file.read() + variants = [] + for path, content in rust_files_content.items(): + if os.path.basename(path) == "error.rs": + crate = crate_of(path) + for enum, variant in extract_variants(content): + variants.append((path, enum, variant, crate)) + with Pool() as pool: results = pool.starmap( - check_snafu_in_files, [(bn, rust_files_content) for bn in branch_names] + is_used, + [ + (error_file, enum, variant, crate, rust_files_content) + for error_file, enum, variant, crate in variants + ], ) - unused_snafu = [bn for bn, found in zip(branch_names, results) if not found] + unused_snafu = [ + (error_file, variant) + for (error_file, _, variant, _), found in zip(variants, results) + if not found + ] if unused_snafu: print("Unused error variants:") - for name in unused_snafu: - print(name) + for error_file, variant in unused_snafu: + print(f"{os.path.relpath(error_file)}: {variant}") raise SystemExit(1) diff --git a/src/auth/src/error.rs b/src/auth/src/error.rs index f99a485db4e..2710f1d5a6d 100644 --- a/src/auth/src/error.rs +++ b/src/auth/src/error.rs @@ -38,14 +38,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to convert to utf8"))] - FromUtf8 { - #[snafu(source)] - error: std::string::FromUtf8Error, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Authentication source failure"))] AuthBackend { #[snafu(implicit)] @@ -101,7 +93,7 @@ impl ErrorExt for Error { fn status_code(&self) -> StatusCode { match self { Error::InvalidConfig { .. } => StatusCode::InvalidArguments, - Error::IllegalParam { .. } | Error::FromUtf8 { .. } => StatusCode::InvalidArguments, + Error::IllegalParam { .. } => StatusCode::InvalidArguments, Error::FileWatch { .. } => StatusCode::InvalidArguments, Error::InternalState { .. } => StatusCode::Unexpected, Error::Io { .. } => StatusCode::StorageUnavailable, diff --git a/src/catalog/src/error.rs b/src/catalog/src/error.rs index 24bf61a6b0e..684020b7f2a 100644 --- a/src/catalog/src/error.rs +++ b/src/catalog/src/error.rs @@ -122,14 +122,6 @@ pub enum Error { source: BoxedError, }, - #[snafu(display("Failed to create table, table info: {}", table_info))] - CreateTable { - table_info: String, - #[snafu(implicit)] - location: Location, - source: table::error::Error, - }, - #[snafu(display("Cannot find catalog by name: {}", catalog_name))] CatalogNotFound { catalog_name: String, @@ -359,8 +351,6 @@ impl ErrorExt for Error { | Error::ListRegionStats { source, .. } | Error::ConvertProtoData { source, .. } => source.status_code(), - Error::CreateTable { source, .. } => source.status_code(), - Error::DecodePlan { source, .. } => source.status_code(), Error::Internal { source, .. } => source.status_code(), diff --git a/src/cli/Cargo.toml b/src/cli/Cargo.toml index 6abe504a3ab..f07e0bacd26 100644 --- a/src/cli/Cargo.toml +++ b/src/cli/Cargo.toml @@ -19,38 +19,30 @@ workspace = true async-stream.workspace = true async-trait.workspace = true base64.workspace = true -cache.workspace = true chrono.workspace = true clap.workspace = true client = { workspace = true, features = ["testing"] } common-base.workspace = true common-catalog.workspace = true -common-config.workspace = true common-datasource.workspace = true common-error.workspace = true common-grpc.workspace = true common-macro.workspace = true common-meta.workspace = true -common-procedure.workspace = true -common-runtime.workspace = true common-telemetry = { workspace = true, features = [ "deadlock_detection", ] } -common-time.workspace = true common-wal.workspace = true datatypes.workspace = true -etcd-client.workspace = true fs2.workspace = true futures.workspace = true humantime.workspace = true indicatif.workspace = true -meta-client.workspace = true meta-srv.workspace = true object-store.workspace = true operator.workspace = true partition.workspace = true paste.workspace = true -query.workspace = true rand.workspace = true reqwest.workspace = true serde.workspace = true diff --git a/src/cli/src/error.rs b/src/cli/src/error.rs index f59130a1f89..c3c7991db9d 100644 --- a/src/cli/src/error.rs +++ b/src/cli/src/error.rs @@ -26,55 +26,6 @@ use store_api::storage::{RegionId, TableId}; #[snafu(visibility(pub))] #[stack_trace_debug] pub enum Error { - #[snafu(display("Failed to install ring crypto provider: {}", msg))] - InitTlsProvider { - #[snafu(implicit)] - location: Location, - msg: String, - }, - - #[snafu(display("Failed to create default catalog and schema"))] - InitMetadata { - #[snafu(implicit)] - location: Location, - source: common_meta::error::Error, - }, - - #[snafu(display("Failed to init DDL manager"))] - InitDdlManager { - #[snafu(implicit)] - location: Location, - source: common_meta::error::Error, - }, - - #[snafu(display("Failed to init default timezone"))] - InitTimezone { - #[snafu(implicit)] - location: Location, - source: common_time::error::Error, - }, - - #[snafu(display("Failed to start procedure manager"))] - StartProcedureManager { - #[snafu(implicit)] - location: Location, - source: common_procedure::error::Error, - }, - - #[snafu(display("Failed to stop procedure manager"))] - StopProcedureManager { - #[snafu(implicit)] - location: Location, - source: common_procedure::error::Error, - }, - - #[snafu(display("Failed to start wal provider"))] - StartWalProvider { - #[snafu(implicit)] - location: Location, - source: common_meta::error::Error, - }, - #[snafu(display("Failed to get table metadata"))] TableMetadata { #[snafu(implicit)] @@ -104,13 +55,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Illegal config: {}", msg))] - IllegalConfig { - msg: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to parse proxy options: {}", error))] ParseProxyOpts { #[snafu(source)] @@ -127,46 +71,6 @@ pub enum Error { error: reqwest::Error, }, - #[snafu(display("Failed to parse SQL: {}", sql))] - ParseSql { - sql: String, - #[snafu(implicit)] - location: Location, - source: query::error::Error, - }, - - #[snafu(display("Failed to plan statement"))] - PlanStatement { - #[snafu(implicit)] - location: Location, - source: query::error::Error, - }, - - #[snafu(display("Failed to load layered config"))] - LoadLayeredConfig { - #[snafu(source(from(common_config::error::Error, Box::new)))] - source: Box, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Failed to connect to Etcd at {etcd_addr}"))] - ConnectEtcd { - etcd_addr: String, - #[snafu(source)] - error: etcd_client::Error, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Failed to serde json"))] - SerdeJson { - #[snafu(source)] - error: serde_json::error::Error, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to run http request: {reason}"))] HttpQuerySql { reason: String, @@ -190,19 +94,6 @@ pub enum Error { error: std::io::Error, }, - #[snafu(display("Failed to create directory {}", dir))] - CreateDir { - dir: String, - #[snafu(source)] - error: std::io::Error, - }, - - #[snafu(display("Failed to spawn thread"))] - SpawnThread { - #[snafu(source)] - error: std::io::Error, - }, - #[snafu(display("Other error"))] Other { source: BoxedError, @@ -210,34 +101,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to build runtime"))] - BuildRuntime { - #[snafu(implicit)] - location: Location, - source: common_runtime::error::Error, - }, - - #[snafu(display("Failed to get cache from cache registry: {}", name))] - CacheRequired { - #[snafu(implicit)] - location: Location, - name: String, - }, - - #[snafu(display("Failed to build cache registry"))] - BuildCacheRegistry { - #[snafu(implicit)] - location: Location, - source: cache::error::Error, - }, - - #[snafu(display("Failed to initialize meta client"))] - MetaClientInit { - #[snafu(implicit)] - location: Location, - source: meta_client::error::Error, - }, - #[snafu(display("Cannot find schema {schema} in catalog {catalog}"))] SchemaNotFound { catalog: String, @@ -279,13 +142,6 @@ pub enum Error { location: Location, }, - #[snafu(display("File path invalid: {}", msg))] - InvalidFilePath { - msg: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Invalid arguments: {}", msg))] InvalidArguments { msg: String, @@ -330,19 +186,11 @@ pub type Result = std::result::Result; impl ErrorExt for Error { fn status_code(&self) -> StatusCode { match self { - Error::InitMetadata { source, .. } - | Error::InitDdlManager { source, .. } - | Error::TableMetadata { source, .. } + Error::TableMetadata { source, .. } | Error::BuildCreateRegionRequest { source, .. } => source.status_code(), Error::MissingConfig { .. } - | Error::LoadLayeredConfig { .. } - | Error::IllegalConfig { .. } - | Error::InitTimezone { .. } - | Error::ConnectEtcd { .. } - | Error::CreateDir { .. } | Error::EmptyResult { .. } - | Error::InvalidFilePath { .. } | Error::UnsupportedMemoryBackend { .. } | Error::InvalidArguments { .. } | Error::ParseProxyOpts { .. } => StatusCode::InvalidArguments, @@ -350,20 +198,10 @@ impl ErrorExt for Error { Error::CovertColumnSchemasToDefs { source, .. } => source.status_code(), Error::SendRequestToDatanode { source, .. } => source.status_code(), - Error::StartProcedureManager { source, .. } - | Error::StopProcedureManager { source, .. } => source.status_code(), - Error::StartWalProvider { source, .. } => source.status_code(), Error::HttpQuerySql { .. } => StatusCode::Internal, - Error::ParseSql { source, .. } | Error::PlanStatement { source, .. } => { - source.status_code() - } Error::Unexpected { .. } => StatusCode::Unexpected, - Error::SerdeJson { .. } - | Error::FileIo { .. } - | Error::SpawnThread { .. } - | Error::InitTlsProvider { .. } - | Error::BuildClient { .. } => StatusCode::Unexpected, + Error::FileIo { .. } | Error::BuildClient { .. } => StatusCode::Unexpected, Error::Other { source, .. } => source.status_code(), Error::OpenDal { .. } | Error::InitBackend { .. } => StatusCode::Internal, @@ -371,12 +209,7 @@ impl ErrorExt for Error { StatusCode::InvalidArguments } - Error::BuildRuntime { source, .. } => source.status_code(), - - Error::CacheRequired { .. } - | Error::BuildCacheRegistry { .. } - | Error::GetCurrentDir { .. } => StatusCode::Internal, - Error::MetaClientInit { source, .. } => source.status_code(), + Error::GetCurrentDir { .. } => StatusCode::Internal, Error::TableNotFound { .. } => StatusCode::TableNotFound, Error::SchemaNotFound { .. } => StatusCode::DatabaseNotFound, } diff --git a/src/cmd/Cargo.toml b/src/cmd/Cargo.toml index ca5f3a9c41c..59ea7777915 100644 --- a/src/cmd/Cargo.toml +++ b/src/cmd/Cargo.toml @@ -76,7 +76,6 @@ datafusion-physical-plan.workspace = true datafusion_object_store.workspace = true datanode.workspace = true datatypes.workspace = true -etcd-client.workspace = true flow.workspace = true frontend = { workspace = true, default-features = false } futures.workspace = true diff --git a/src/cmd/src/error.rs b/src/cmd/src/error.rs index 84553439ab1..f53724fbcc4 100644 --- a/src/cmd/src/error.rs +++ b/src/cmd/src/error.rs @@ -191,21 +191,6 @@ pub enum Error { source: meta_srv::error::Error, }, - #[snafu(display("Failed to parse SQL: {}", sql))] - ParseSql { - sql: String, - #[snafu(implicit)] - location: Location, - source: query::error::Error, - }, - - #[snafu(display("Failed to plan statement"))] - PlanStatement { - #[snafu(implicit)] - location: Location, - source: query::error::Error, - }, - #[snafu(display("Failed to load layered config"))] LoadLayeredConfig { #[snafu(source(from(common_config::error::Error, Box::new)))] @@ -214,15 +199,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to connect to Etcd at {etcd_addr}"))] - ConnectEtcd { - etcd_addr: String, - #[snafu(source)] - error: etcd_client::Error, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to serde json"))] SerdeJson { #[snafu(source)] @@ -231,21 +207,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to run http request: {reason}"))] - HttpQuerySql { - reason: String, - #[snafu(source)] - error: reqwest::Error, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Empty result from output"))] - EmptyResult { - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to manipulate file"))] FileIo { #[snafu(implicit)] @@ -274,20 +235,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to build runtime"))] - BuildRuntime { - #[snafu(implicit)] - location: Location, - source: common_runtime::error::Error, - }, - - #[snafu(display("Failed to get cache from cache registry: {}", name))] - CacheRequired { - #[snafu(implicit)] - location: Location, - name: String, - }, - #[snafu(display("Failed to build cache registry"))] BuildCacheRegistry { #[snafu(implicit)] @@ -302,14 +249,6 @@ pub enum Error { source: meta_client::error::Error, }, - #[snafu(display("Cannot find schema {schema} in catalog {catalog}"))] - SchemaNotFound { - catalog: String, - schema: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to build wal provider"))] BuildWalProvider { #[snafu(implicit)] @@ -367,19 +306,13 @@ impl ErrorExt for Error { | Error::LoadLayeredConfig { .. } | Error::IllegalConfig { .. } | Error::InitTimezone { .. } - | Error::ConnectEtcd { .. } - | Error::CreateDir { .. } - | Error::EmptyResult { .. } => StatusCode::InvalidArguments, + | Error::CreateDir { .. } => StatusCode::InvalidArguments, Error::StartProcedureManager { source, .. } | Error::StopProcedureManager { source, .. } => source.status_code(), Error::BuildWalProvider { source, .. } | Error::StartWalProvider { source, .. } => { source.status_code() } - Error::HttpQuerySql { .. } => StatusCode::Internal, - Error::ParseSql { source, .. } | Error::PlanStatement { source, .. } => { - source.status_code() - } Error::SerdeJson { .. } | Error::FileIo { .. } @@ -389,14 +322,11 @@ impl ErrorExt for Error { Error::Other { source, .. } => source.status_code(), - Error::BuildRuntime { source, .. } => source.status_code(), - - Error::CacheRequired { .. } | Error::BuildCacheRegistry { .. } => StatusCode::Internal, + Error::BuildCacheRegistry { .. } => StatusCode::Internal, Self::StartFlownode { source, .. } | Self::ShutdownFlownode { source, .. } => { source.status_code() } Error::MetaClientInit { source, .. } => source.status_code(), - Error::SchemaNotFound { .. } => StatusCode::DatabaseNotFound, Error::InvalidWalProvider { .. } => StatusCode::InvalidArguments, } } diff --git a/src/common/event-recorder/src/error.rs b/src/common/event-recorder/src/error.rs index dc39943f670..154af09b0eb 100644 --- a/src/common/event-recorder/src/error.rs +++ b/src/common/event-recorder/src/error.rs @@ -45,14 +45,6 @@ pub enum Error { #[snafu(implicit)] location: Location, }, - - #[snafu(display("Keyvalue backend error"))] - KvBackend { - // BoxedError is utilized here to prevent introducing a circular dependency that would arise from directly referencing `common_meta::error::Error`. - source: BoxedError, - #[snafu(implicit)] - location: Location, - }, } pub type Result = std::result::Result; @@ -63,7 +55,7 @@ impl ErrorExt for Error { Error::MismatchedSchema { .. } | Error::SerializeEvent { .. } => { StatusCode::InvalidArguments } - Error::InsertEvents { .. } | Error::KvBackend { .. } => StatusCode::Internal, + Error::InsertEvents { .. } => StatusCode::Internal, } } diff --git a/src/common/frontend/src/error.rs b/src/common/frontend/src/error.rs index 9961ed1879e..5eab6b6dc6e 100644 --- a/src/common/frontend/src/error.rs +++ b/src/common/frontend/src/error.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use common_error::ext::{BoxedError, ErrorExt, RetryHint}; +use common_error::ext::{ErrorExt, RetryHint}; use common_error::status_code::StatusCode; use common_macro::stack_trace_debug; use snafu::{Location, Snafu}; @@ -21,13 +21,6 @@ use snafu::{Location, Snafu}; #[snafu(visibility(pub))] #[stack_trace_debug] pub enum Error { - #[snafu(display("External error"))] - External { - #[snafu(implicit)] - location: Location, - source: BoxedError, - }, - #[snafu(display("Failed to list nodes from metasrv"))] Meta { source: Box, @@ -64,7 +57,6 @@ impl ErrorExt for Error { fn status_code(&self) -> StatusCode { use Error::*; match self { - External { source, .. } => source.status_code(), Meta { source, .. } => source.status_code(), ParseProcessId { .. } => StatusCode::InvalidArguments, InvokeFrontend { .. } => StatusCode::Unexpected, @@ -80,7 +72,6 @@ impl ErrorExt for Error { use Error::*; match self { - External { source, .. } => source.retry_hint(), Meta { source, .. } => source.retry_hint(), CreateChannel { source, .. } => source.retry_hint(), _ => RetryHint::NonRetryable, diff --git a/src/common/grpc/src/error.rs b/src/common/grpc/src/error.rs index 26cef0902cf..f005727ac90 100644 --- a/src/common/grpc/src/error.rs +++ b/src/common/grpc/src/error.rs @@ -27,9 +27,6 @@ pub type Result = std::result::Result; #[snafu(visibility(pub))] #[stack_trace_debug] pub enum Error { - #[snafu(display("Invalid client tls config, {}", msg))] - InvalidTlsConfig { msg: String }, - #[snafu(display("Invalid config file path"))] InvalidConfigFilePath { #[snafu(source)] @@ -46,20 +43,6 @@ pub enum Error { location: Location, }, - #[snafu(display( - "Write type mismatch, column name: {}, expected: {}, actual: {}", - column_name, - expected, - actual - ))] - TypeMismatch { - column_name: String, - expected: String, - actual: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to create gRPC channel from '{addr}'"))] CreateChannel { addr: String, @@ -114,10 +97,8 @@ pub enum Error { impl ErrorExt for Error { fn status_code(&self) -> StatusCode { match self { - Error::InvalidTlsConfig { .. } - | Error::InvalidConfigFilePath { .. } + Error::InvalidConfigFilePath { .. } | Error::FileWatch { .. } - | Error::TypeMismatch { .. } | Error::InvalidFlightData { .. } | Error::NotSupported { .. } => StatusCode::InvalidArguments, diff --git a/src/common/meta/src/error.rs b/src/common/meta/src/error.rs index 2052c27bb06..6ecbaed9fb0 100644 --- a/src/common/meta/src/error.rs +++ b/src/common/meta/src/error.rs @@ -282,14 +282,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to decode protobuf"))] - DecodeProto { - #[snafu(implicit)] - location: Location, - #[snafu(source)] - error: prost::DecodeError, - }, - #[snafu(display("Failed to decode packed file references"))] DecodePackedFileRefs { #[snafu(implicit)] @@ -896,14 +888,6 @@ pub enum Error { location: Location, }, - #[cfg(feature = "pg_kvbackend")] - #[snafu(display("Invalid TLS configuration: {}", reason))] - InvalidTlsConfig { - reason: String, - #[snafu(implicit)] - location: Location, - }, - #[cfg(feature = "mysql_kvbackend")] #[snafu(display("Failed to execute via MySql, sql: {}", sql))] MySqlExecution { @@ -1414,7 +1398,6 @@ impl ErrorExt for Error { | DecodeJson { .. } | PayloadNotExist { .. } | ConvertRawKey { .. } - | DecodeProto { .. } | DecodePackedFileRefs { .. } | InvalidPackedFileRefs { .. } | BuildTableMeta { .. } @@ -1519,8 +1502,7 @@ impl ErrorExt for Error { | GetPostgresConnection { .. } | GetPostgresClient { .. } | PostgresTransaction { .. } - | PostgresTlsConfig { .. } - | InvalidTlsConfig { .. } => StatusCode::Internal, + | PostgresTlsConfig { .. } => StatusCode::Internal, #[cfg(feature = "mysql_kvbackend")] MySqlExecution { .. } | CreateMySqlPool { .. } diff --git a/src/common/query/src/error.rs b/src/common/query/src/error.rs index f5f880e8ced..12daf3a44a4 100644 --- a/src/common/query/src/error.rs +++ b/src/common/query/src/error.rs @@ -83,13 +83,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to convert DataFusion's recordbatch stream"))] - ConvertDfRecordBatchStream { - #[snafu(implicit)] - location: Location, - source: common_recordbatch::error::Error, - }, - #[snafu(display("Failed to cast array to {:?}", typ))] TypeCast { #[snafu(source)] @@ -107,13 +100,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Query engine fail to cast value"))] - ToScalarValue { - #[snafu(implicit)] - location: Location, - source: DataTypeError, - }, - #[snafu(display("Failed to get scalar vector"))] GetScalarVector { #[snafu(implicit)] @@ -248,7 +234,6 @@ impl ErrorExt for Error { match self { Error::StorageWrite { source, .. } => source.status_code(), Error::InvalidInputState { .. } - | Error::ToScalarValue { .. } | Error::GetScalarVector { .. } | Error::ArrowCompute { .. } | Error::FlownodeNotFound { .. } => StatusCode::EngineExecuteQuery, @@ -275,8 +260,6 @@ impl ErrorExt for Error { // server failure: callers omit the initial snapshot or reset the remote predicate. Error::DynFilterUnsupported { .. } => StatusCode::Unsupported, - Error::ConvertDfRecordBatchStream { source, .. } => source.status_code(), - Error::DecodePlan { source, .. } | Error::Execute { source, .. } | Error::ProcedureService { source, .. } diff --git a/src/common/substrait/src/error.rs b/src/common/substrait/src/error.rs index fa7947385bf..2ce1e129ff7 100644 --- a/src/common/substrait/src/error.rs +++ b/src/common/substrait/src/error.rs @@ -14,7 +14,7 @@ use std::any::Any; -use common_error::ext::{BoxedError, ErrorExt}; +use common_error::ext::ErrorExt; use common_error::status_code::StatusCode; use common_macro::stack_trace_debug; use prost::{DecodeError, EncodeError}; @@ -40,13 +40,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Internal error"))] - Internal { - #[snafu(implicit)] - location: Location, - source: BoxedError, - }, - #[snafu(display("Failed to encode DataFusion plan"))] EncodeDfPlan { #[snafu(source)] @@ -70,7 +63,6 @@ impl ErrorExt for Error { fn status_code(&self) -> StatusCode { match self { Error::EncodeRel { .. } | Error::DecodeRel { .. } => StatusCode::InvalidArguments, - Error::Internal { .. } => StatusCode::Internal, Error::EncodeDfPlan { .. } | Error::DecodeDfPlan { .. } => StatusCode::Unexpected, } } diff --git a/src/datanode/Cargo.toml b/src/datanode/Cargo.toml index 5bae783df1e..ae458d5e504 100644 --- a/src/datanode/Cargo.toml +++ b/src/datanode/Cargo.toml @@ -64,7 +64,6 @@ prost.workspace = true query.workspace = true rand.workspace = true relational-engine.workspace = true -reqwest.workspace = true serde.workspace = true serde_json.workspace = true servers.workspace = true diff --git a/src/datanode/src/error.rs b/src/datanode/src/error.rs index 2a560393ad7..64f9d20e600 100644 --- a/src/datanode/src/error.rs +++ b/src/datanode/src/error.rs @@ -23,7 +23,6 @@ use common_macro::stack_trace_debug; use common_runtime::JoinError; use snafu::{Location, Snafu}; use store_api::storage::RegionId; -use table::error::Error as TableError; use tokio::time::error::Elapsed; /// Business error of datanode. @@ -93,27 +92,6 @@ pub enum Error { source: common_query::error::Error, }, - #[snafu(display("Schema not found: {}", name))] - SchemaNotFound { - name: String, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Missing timestamp column in request"))] - MissingTimestampColumn { - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Failed to delete value from table: {}", table_name))] - Delete { - table_name: String, - #[snafu(implicit)] - location: Location, - source: TableError, - }, - #[snafu(display("Failed to start server"))] StartServer { #[snafu(implicit)] @@ -135,13 +113,6 @@ pub enum Error { error: std::io::Error, }, - #[snafu(display("Failed to remove directory {}", dir))] - RemoveDir { - dir: String, - #[snafu(source)] - error: std::io::Error, - }, - #[snafu(display("Failed to open log store"))] OpenLogStore { #[snafu(implicit)] @@ -156,23 +127,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Invalid SQL, error: {}", msg))] - InvalidSql { msg: String }, - - #[snafu(display("Illegal primary keys definition: {}", msg))] - IllegalPrimaryKeysDef { - msg: String, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Schema {} already exists", name))] - SchemaExists { - name: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to initialize meta client"))] MetaClientInit { #[snafu(implicit)] @@ -193,14 +147,6 @@ pub enum Error { source: BoxedError, }, - #[snafu(display("Failed to build http client"))] - BuildHttpClient { - #[snafu(implicit)] - location: Location, - #[snafu(source)] - error: reqwest::Error, - }, - #[snafu(display("Missing required field: {}", name))] MissingRequiredField { name: String, @@ -208,16 +154,6 @@ pub enum Error { location: Location, }, - #[snafu(display( - "No valid default value can be built automatically, column: {}", - column, - ))] - ColumnNoneDefaultValue { - column: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to shutdown server"))] ShutdownServer { #[snafu(implicit)] @@ -234,12 +170,6 @@ pub enum Error { source: BoxedError, }, - #[snafu(display("Payload not exist"))] - PayloadNotExist { - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Unexpected, violated: {}", violated))] Unexpected { violated: String, @@ -515,16 +445,8 @@ impl ErrorExt for Error { DecodeLogicalPlan { source, .. } => source.status_code(), - Delete { source, .. } => source.status_code(), - InvalidQueryContext { .. } - | InvalidSql { .. } - | IllegalPrimaryKeysDef { .. } - | MissingTimestampColumn { .. } - | SchemaNotFound { .. } - | SchemaExists { .. } | MissingNodeId { .. } - | ColumnNoneDefaultValue { .. } | MissingRequiredField { .. } | RegionEngineNotFound { .. } | GcConfigMismatch { .. } @@ -535,19 +457,15 @@ impl ErrorExt for Error { | ObjectStoreWalNotStandalone { .. } | BuildDatanode { .. } => StatusCode::InvalidArguments, - PayloadNotExist { .. } - | Unexpected { .. } - | SerializeWalOptions { .. } - | WatchAsyncTaskChange { .. } - | BuildHttpClient { .. } => StatusCode::Unexpected, + Unexpected { .. } | SerializeWalOptions { .. } | WatchAsyncTaskChange { .. } => { + StatusCode::Unexpected + } AsyncTaskExecute { source, .. } => source.status_code(), - CreateDir { .. } - | RemoveDir { .. } - | ShutdownInstance { .. } - | DataFusion { .. } - | RuntimeJoin { .. } => StatusCode::Internal, + CreateDir { .. } | ShutdownInstance { .. } | DataFusion { .. } | RuntimeJoin { .. } => { + StatusCode::Internal + } RegionNotFound { .. } => StatusCode::RegionNotFound, RegionNotReady { .. } => StatusCode::RegionNotReady, @@ -602,7 +520,6 @@ impl ErrorExt for Error { source.retry_hint() } DecodeLogicalPlan { source, .. } => source.retry_hint(), - Delete { source, .. } => source.retry_hint(), AsyncTaskExecute { source, .. } => source.retry_hint(), StartServer { source, .. } | ShutdownServer { source, .. } => source.retry_hint(), OpenLogStore { source, .. } => source.retry_hint(), diff --git a/src/file-engine/src/error.rs b/src/file-engine/src/error.rs index f40adfe65f4..f29854cd17a 100644 --- a/src/file-engine/src/error.rs +++ b/src/file-engine/src/error.rs @@ -17,7 +17,6 @@ use std::any::Any; use common_error::ext::{ErrorExt, RetryHint}; use common_error::status_code::StatusCode; use common_macro::stack_trace_debug; -use datafusion::arrow::error::ArrowError; use datafusion::error::DataFusionError; use object_store::error::retry_hint_from_opendal_error; use serde_json::error::Error as JsonError; @@ -137,14 +136,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to project schema"))] - ProjectArrowSchema { - #[snafu(source)] - error: ArrowError, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to project schema"))] ProjectSchema { source: datatypes::error::Error, @@ -186,14 +177,6 @@ pub enum Error { #[snafu(implicit)] location: Location, }, - - #[snafu(display("Failed to create default value for column: {}", column))] - CreateDefault { - column: String, - source: datatypes::error::Error, - #[snafu(implicit)] - location: Location, - }, } pub type Result = std::result::Result; @@ -203,13 +186,11 @@ impl ErrorExt for Error { use Error::*; match self { - ProjectArrowSchema { .. } - | ProjectSchema { .. } + ProjectSchema { .. } | MissingRequiredField { .. } | Unsupported { .. } | InvalidMetadata { .. } - | ProjectionOutOfBounds { .. } - | CreateDefault { .. } => StatusCode::InvalidArguments, + | ProjectionOutOfBounds { .. } => StatusCode::InvalidArguments, RegionNotFound { .. } => StatusCode::RegionNotFound, diff --git a/src/flow/src/error.rs b/src/flow/src/error.rs index 4b1209a4dbf..429e2d8bab0 100644 --- a/src/flow/src/error.rs +++ b/src/flow/src/error.rs @@ -239,13 +239,6 @@ pub enum Error { source: servers::error::Error, }, - #[snafu(display("Failed to initialize meta client"))] - MetaClientInit { - #[snafu(implicit)] - location: Location, - source: meta_client::error::Error, - }, - #[snafu(display("Failed to parse address {}", addr))] ParseAddr { addr: String, @@ -253,13 +246,6 @@ pub enum Error { error: std::net::AddrParseError, }, - #[snafu(display("Failed to get cache from cache registry: {}", name))] - CacheRequired { - #[snafu(implicit)] - location: Location, - name: String, - }, - #[snafu(display("Invalid request: {context}"))] InvalidRequest { context: String, @@ -341,11 +327,10 @@ impl ErrorExt for Error { | Self::IllegalCheckTaskState { .. } => StatusCode::Unexpected, Self::Unsupported { .. } => StatusCode::Unsupported, Self::External { source, .. } => source.status_code(), - Self::Internal { .. } | Self::CacheRequired { .. } => StatusCode::Internal, + Self::Internal { .. } => StatusCode::Internal, Self::StartServer { source, .. } | Self::ShutdownServer { source, .. } => { source.status_code() } - Self::MetaClientInit { source, .. } => source.status_code(), Self::InvalidQuery { .. } | Self::InvalidRequest { .. } @@ -381,7 +366,6 @@ impl ErrorExt for Error { Self::StartServer { source, .. } | Self::ShutdownServer { source, .. } => { source.retry_hint() } - Self::MetaClientInit { source, .. } => source.retry_hint(), Self::InvalidRequest { source, .. } => source.retry_hint(), Self::SubstraitEncodeLogicalPlan { source, .. } => source.retry_hint(), Self::ConvertColumnSchema { source, .. } => source.retry_hint(), diff --git a/src/flow/src/expr/error.rs b/src/flow/src/expr/error.rs index ac5319314aa..a51e395588d 100644 --- a/src/flow/src/expr/error.rs +++ b/src/flow/src/expr/error.rs @@ -31,22 +31,6 @@ use snafu::{Location, Snafu}; #[snafu(visibility(pub))] #[stack_trace_debug] pub enum EvalError { - #[snafu(display("Type mismatch: expected {expected}, actual {actual}"))] - TypeMismatch { - expected: ConcreteDataType, - actual: ConcreteDataType, - #[snafu(implicit)] - location: Location, - }, - - /// can't nest datatypes error because EvalError need to be store in map and serialization - #[snafu(display("Fail to unpack from value to given type: {msg}"))] - TryFromValue { - msg: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Fail to cast value of type {from} to given type {to}"))] CastValue { from: ConcreteDataType, @@ -78,12 +62,6 @@ pub enum EvalError { location: Location, }, - #[snafu(display("Overflowed during evaluation"))] - Overflow { - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Arrow error: {error:?}, context: {context}"))] Arrow { #[snafu(source)] @@ -114,10 +92,7 @@ impl ErrorExt for EvalError { fn status_code(&self) -> StatusCode { use EvalError::*; match self { - TypeMismatch { .. } - | TryFromValue { .. } - | InvalidArgument { .. } - | Overflow { .. } => StatusCode::InvalidArguments, + InvalidArgument { .. } => StatusCode::InvalidArguments, CastValue { source, .. } | DataType { source, .. } => source.status_code(), diff --git a/src/frontend/src/error.rs b/src/frontend/src/error.rs index bfad651c494..60f02539036 100644 --- a/src/frontend/src/error.rs +++ b/src/frontend/src/error.rs @@ -14,7 +14,6 @@ use std::any::Any; -use common_datasource::file_format::Format; use common_error::define_into_tonic_status; use common_error::ext::{BoxedError, ErrorExt, RetryHint}; use common_error::status_code::StatusCode; @@ -29,13 +28,6 @@ use store_api::storage::RegionId; #[snafu(visibility(pub))] #[stack_trace_debug] pub enum Error { - #[snafu(display("Failed to invalidate table cache"))] - InvalidateTableCache { - #[snafu(implicit)] - location: Location, - source: common_meta::error::Error, - }, - #[snafu(display("Failed to handle heartbeat response"))] HandleHeartbeatResponse { #[snafu(implicit)] @@ -99,20 +91,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Invalid InsertRequest, reason: {}", reason))] - InvalidInsertRequest { - reason: String, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Invalid DeleteRequest, reason: {}", reason))] - InvalidDeleteRequest { - reason: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Table not found: {}", table_name))] TableNotFound { table_name: String }, @@ -143,13 +121,6 @@ pub enum Error { source: partition::error::Error, }, - #[snafu(display("Schema {} already exists", name))] - SchemaExists { - name: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Table occurs error"))] Table { #[snafu(implicit)] @@ -266,28 +237,6 @@ pub enum Error { source: query::error::Error, }, - #[snafu(display("Illegal primary keys definition: {}", msg))] - IllegalPrimaryKeysDef { - msg: String, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Failed to insert value into table: {}", table_name))] - Insert { - table_name: String, - #[snafu(implicit)] - location: Location, - source: table::error::Error, - }, - - #[snafu(display("Unsupported format: {:?}", format))] - UnsupportedFormat { - #[snafu(implicit)] - location: Location, - format: Format, - }, - #[snafu(display("Failed to pass permission check"))] Permission { source: auth::error::Error, @@ -295,16 +244,6 @@ pub enum Error { location: Location, }, - #[snafu(display( - "No valid default value can be built automatically, column: {}", - column, - ))] - ColumnNoneDefaultValue { - column: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Table operation error"))] TableOperation { source: operator::error::Error, @@ -402,16 +341,10 @@ impl ErrorExt for Error { Error::TomlFormat { .. } | Error::ParseAddr { .. } | Error::InvalidSql { .. } - | Error::InvalidInsertRequest { .. } - | Error::InvalidDeleteRequest { .. } - | Error::IllegalPrimaryKeysDef { .. } - | Error::SchemaExists { .. } | Error::ColumnNotFound { .. } | Error::AmbiguousValueColumn { .. } | Error::InvalidPromRemoteReadSchema { .. } - | Error::UnsupportedFormat { .. } | Error::IllegalAuthConfig { .. } - | Error::ColumnNoneDefaultValue { .. } | Error::IncompleteGrpcRequest { .. } | Error::InvalidTlsConfig { .. } | Error::InvalidPromqlRollupCacheConfig { .. } @@ -441,9 +374,7 @@ impl ErrorExt for Error { Error::ParseSql { source, .. } => source.status_code(), - Error::InvalidateTableCache { source, .. } => source.status_code(), - - Error::Table { source, .. } | Error::Insert { source, .. } => source.status_code(), + Error::Table { source, .. } => source.status_code(), Error::RequestQuery { source, .. } => source.status_code(), @@ -484,9 +415,9 @@ impl ErrorExt for Error { fn retry_hint(&self) -> RetryHint { match self { - Error::InvalidateTableCache { source, .. } - | Error::HandleHeartbeatResponse { source, .. } - | Error::RequestQuery { source, .. } => source.retry_hint(), + Error::HandleHeartbeatResponse { source, .. } | Error::RequestQuery { source, .. } => { + source.retry_hint() + } Error::External { source, .. } | Error::SqlExecIntercepted { source, .. } @@ -509,7 +440,6 @@ impl ErrorExt for Error { | Error::ExecLogicalPlan { source, .. } | Error::DescribeStatement { source, .. } => source.retry_hint(), Error::PrometheusLabelValuesQueryPlan { source, .. } => source.retry_hint(), - Error::Insert { source, .. } => source.retry_hint(), Error::Permission { source, .. } => source.retry_hint(), Error::TableOperation { source, .. } => source.retry_hint(), Error::IllegalAuthConfig { source, .. } => source.retry_hint(), diff --git a/src/log-store/src/error.rs b/src/log-store/src/error.rs index 8da6f8b71bb..97902bb3158 100644 --- a/src/log-store/src/error.rs +++ b/src/log-store/src/error.rs @@ -182,16 +182,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to produce records to Kafka, topic: {}, size: {}", topic, size))] - ProduceRecord { - topic: String, - size: usize, - #[snafu(implicit)] - location: Location, - #[snafu(source)] - error: rskafka::client::producer::Error, - }, - #[snafu(display("Failed to produce batch records to Kafka"))] BatchProduce { #[snafu(implicit)] @@ -218,12 +208,6 @@ pub enum Error { error: rskafka::client::error::Error, }, - #[snafu(display("Failed to do a cast"))] - Cast { - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to encode object into json"))] EncodeJson { #[snafu(implicit)] @@ -552,7 +536,6 @@ impl ErrorExt for Error { | Join { .. } | IllegalState { .. } | NoMaxValue { .. } - | Cast { .. } | EncodeJson { .. } | DecodeJson { .. } | IllegalSequence { .. } @@ -587,14 +570,6 @@ impl ErrorExt for Error { StatusCode::StorageUnavailable } // Kafka producer related errors - ProduceRecord { error, .. } => match error { - rskafka::client::producer::Error::Client(error) => { - rskafka_client_error_to_status_code(error) - } - rskafka::client::producer::Error::Aggregator(_) - | rskafka::client::producer::Error::FlushError(_) - | rskafka::client::producer::Error::TooLarge => StatusCode::Internal, - }, BuildClient { error, .. } | BuildPartitionClient { error, .. } | BatchProduce { error, .. } @@ -618,14 +593,6 @@ impl ErrorExt for Error { | UnconfirmedWalEpochStart { .. } | ObjectStoreWalFailing { .. } => RetryHint::Retryable, ObjectStoreWalLeaseExpired { .. } => RetryHint::RetryAfterRouteRefresh, - ProduceRecord { error, .. } => match error { - rskafka::client::producer::Error::Client(error) => { - rskafka_client_error_to_retry_hint(error) - } - rskafka::client::producer::Error::Aggregator(_) - | rskafka::client::producer::Error::FlushError(_) - | rskafka::client::producer::Error::TooLarge => RetryHint::NonRetryable, - }, BuildClient { error, .. } | BuildPartitionClient { error, .. } | BatchProduce { error, .. } diff --git a/src/meta-srv/Cargo.toml b/src/meta-srv/Cargo.toml index 1344430384e..70f3c51965d 100644 --- a/src/meta-srv/Cargo.toml +++ b/src/meta-srv/Cargo.toml @@ -6,7 +6,7 @@ license.workspace = true [features] mock = [] -pg_kvbackend = ["dep:tokio-postgres", "common-meta/pg_kvbackend", "dep:deadpool-postgres", "dep:deadpool"] +pg_kvbackend = ["dep:tokio-postgres", "common-meta/pg_kvbackend", "dep:deadpool-postgres"] mysql_kvbackend = ["dep:sqlx", "common-meta/mysql_kvbackend"] testing = ["common-wal/testing"] enterprise = ["common-meta/enterprise"] @@ -43,7 +43,6 @@ common-wal.workspace = true common-workload.workspace = true dashmap.workspace = true datatypes.workspace = true -deadpool = { workspace = true, optional = true } deadpool-postgres = { workspace = true, optional = true } derive_builder.workspace = true either.workspace = true diff --git a/src/meta-srv/src/error.rs b/src/meta-srv/src/error.rs index 6ab4b936cf8..8cd39f6e19a 100644 --- a/src/meta-srv/src/error.rs +++ b/src/meta-srv/src/error.rs @@ -18,7 +18,6 @@ use common_error::status_code::StatusCode; use common_macro::stack_trace_debug; use common_meta::DatanodeId; use common_procedure::ProcedureId; -use common_runtime::JoinError; use common_wal::kafka::rskafka_client_error_to_retry_hint; use snafu::{Location, Snafu}; use store_api::storage::RegionId; @@ -216,45 +215,6 @@ pub enum Error { source: common_meta::error::Error, }, - #[snafu(display("Failed to invalidate table cache"))] - InvalidateTableCache { - #[snafu(implicit)] - location: Location, - source: common_meta::error::Error, - }, - - #[snafu(display("Failed to list catalogs"))] - ListCatalogs { - #[snafu(implicit)] - location: Location, - source: BoxedError, - }, - - #[snafu(display("Failed to list {}'s schemas", catalog))] - ListSchemas { - #[snafu(implicit)] - location: Location, - catalog: String, - source: BoxedError, - }, - - #[snafu(display("Failed to list {}.{}'s tables", catalog, schema))] - ListTables { - #[snafu(implicit)] - location: Location, - catalog: String, - schema: String, - source: BoxedError, - }, - - #[snafu(display("Failed to join a future"))] - Join { - #[snafu(implicit)] - location: Location, - #[snafu(source)] - error: JoinError, - }, - #[snafu(display( "Failed to request {}, required: {}, but only {} available", select_target, @@ -289,14 +249,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to execute via Etcd"))] - EtcdFailed { - #[snafu(source)] - error: etcd_client::Error, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to connect to Etcd"))] ConnectEtcd { #[snafu(source)] @@ -305,15 +257,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to read file: {}", path))] - FileIo { - #[snafu(source)] - error: std::io::Error, - #[snafu(implicit)] - location: Location, - path: String, - }, - #[snafu(display("Failed to bind address {}", addr))] TcpBind { addr: String, @@ -352,13 +295,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Invalid datanode stat key: {}", key))] - InvalidStatKey { - key: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Invalid inactive region key: {}", key))] InvalidInactiveRegionKey { key: String, @@ -480,15 +416,6 @@ pub enum Error { location: Location, }, - #[cfg(feature = "mysql_kvbackend")] - #[snafu(display("Failed to decode sql value"))] - DecodeSqlValue { - #[snafu(source)] - error: sqlx::error::Error, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to find table route for {table_id}"))] TableRouteNotFound { table_id: TableId, @@ -524,18 +451,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Leader lease expired"))] - LeaderLeaseExpired { - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Leader lease changed during election"))] - LeaderLeaseChanged { - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Table {} not found", name))] TableNotFound { name: String, @@ -613,14 +528,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Invalid utf-8 value"))] - InvalidUtf8Value { - #[snafu(source)] - error: std::string::FromUtf8Error, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Missing required parameter, param: {:?}", param))] MissingRequiredParameter { param: String }, @@ -673,20 +580,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Schema already exists, name: {schema_name}"))] - SchemaAlreadyExists { - schema_name: String, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Table already exists: {table_name}"))] - TableAlreadyExists { - table_name: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Pusher not found: {pusher_id}"))] PusherNotFound { pusher_id: String, @@ -924,34 +817,6 @@ pub enum Error { source: Box, }, - #[cfg(feature = "pg_kvbackend")] - #[snafu(display("Failed to execute via postgres, sql: {}", sql))] - PostgresExecution { - #[snafu(source)] - error: tokio_postgres::Error, - sql: String, - #[snafu(implicit)] - location: Location, - }, - - #[cfg(feature = "pg_kvbackend")] - #[snafu(display("Failed to get Postgres client"))] - GetPostgresClient { - #[snafu(implicit)] - location: Location, - #[snafu(source)] - error: deadpool::managed::PoolError, - }, - - #[cfg(any(feature = "pg_kvbackend", feature = "mysql_kvbackend"))] - #[snafu(display("Sql execution timeout, sql: {}, duration: {:?}", sql, duration))] - SqlExecutionTimeout { - #[snafu(implicit)] - location: Location, - sql: String, - duration: std::time::Duration, - }, - #[cfg(feature = "pg_kvbackend")] #[snafu(display("Failed to create connection pool for Postgres"))] CreatePostgresPool { @@ -961,24 +826,6 @@ pub enum Error { location: Location, }, - #[cfg(feature = "pg_kvbackend")] - #[snafu(display("Failed to get connection from Postgres pool: {}", reason))] - GetPostgresConnection { - reason: String, - #[snafu(implicit)] - location: Location, - }, - - #[cfg(feature = "mysql_kvbackend")] - #[snafu(display("Failed to execute via mysql, sql: {}", sql))] - MySqlExecution { - #[snafu(source)] - error: sqlx::Error, - #[snafu(implicit)] - location: Location, - sql: String, - }, - #[cfg(feature = "mysql_kvbackend")] #[snafu(display("Failed to create mysql pool"))] CreateMySqlPool { @@ -988,15 +835,6 @@ pub enum Error { location: Location, }, - #[cfg(feature = "mysql_kvbackend")] - #[snafu(display("Failed to acquire mysql client from pool"))] - AcquireMySqlClient { - #[snafu(source)] - error: sqlx::Error, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Handler not found: {}", name))] HandlerNotFound { name: String, @@ -1212,16 +1050,12 @@ define_into_tonic_status!(Error); impl ErrorExt for Error { fn status_code(&self) -> StatusCode { match self { - Error::EtcdFailed { .. } - | Error::ConnectEtcd { .. } - | Error::FileIo { .. } + Error::ConnectEtcd { .. } | Error::TcpBind { .. } | Error::SerializeConfig { .. } | Error::SerializeToJson { .. } | Error::DeserializeFromJson { .. } | Error::NoLeader { .. } - | Error::LeaderLeaseExpired { .. } - | Error::LeaderLeaseChanged { .. } | Error::CreateChannel { .. } | Error::BatchGet { .. } | Error::Range { .. } @@ -1234,7 +1068,6 @@ impl ErrorExt for Error { | Error::MailboxReceiver { .. } | Error::StartGrpc { .. } | Error::PublishMessage { .. } - | Error::Join { .. } | Error::ChooseItems { .. } | Error::FlowStateHandler { .. } | Error::BuildWalProvider { .. } @@ -1258,14 +1091,10 @@ impl ErrorExt for Error { Error::Unsupported { .. } => StatusCode::Unsupported, - Error::SchemaAlreadyExists { .. } => StatusCode::DatabaseAlreadyExists, - - Error::TableAlreadyExists { .. } => StatusCode::TableAlreadyExists, Error::EmptyKey { .. } | Error::MissingRequiredParameter { .. } | Error::MissingRequestHeader { .. } | Error::InvalidLeaseKey { .. } - | Error::InvalidStatKey { .. } | Error::InvalidInactiveRegionKey { .. } | Error::InvalidNodeSchedulingKey { .. } | Error::ParseNum { .. } @@ -1290,7 +1119,6 @@ impl ErrorExt for Error { | Error::TableRouteNotFound { .. } | Error::TableInfoNotFound { .. } | Error::DatanodeTableNotFound { .. } - | Error::InvalidUtf8Value { .. } | Error::UnexpectedInstructionReply { .. } | Error::Unexpected { .. } | Error::RegionOperatingRace { .. } @@ -1305,7 +1133,6 @@ impl ErrorExt for Error { | Error::InvalidClusterInfoFormat { source, .. } | Error::InvalidDatanodeStatFormat { source, .. } | Error::InvalidNodeInfoFormat { source, .. } => source.status_code(), - Error::InvalidateTableCache { source, .. } => source.status_code(), Error::SubmitProcedure { source, .. } | Error::WaitProcedure { source, .. } | Error::QueryProcedure { source, .. } => source.status_code(), @@ -1315,9 +1142,6 @@ impl ErrorExt for Error { Error::StartProcedureManager { source, .. } | Error::StopProcedureManager { source, .. } => source.status_code(), - Error::ListCatalogs { source, .. } - | Error::ListSchemas { source, .. } - | Error::ListTables { source, .. } => source.status_code(), Error::StartTelemetryTask { source, .. } => source.status_code(), Error::NextSequence { source, .. } @@ -1358,18 +1182,9 @@ impl ErrorExt for Error { Error::NoEnoughAvailableNode { .. } => StatusCode::RuntimeResourcesExhausted, #[cfg(feature = "pg_kvbackend")] - Error::CreatePostgresPool { .. } - | Error::GetPostgresClient { .. } - | Error::GetPostgresConnection { .. } - | Error::PostgresExecution { .. } => StatusCode::Internal, + Error::CreatePostgresPool { .. } => StatusCode::Internal, #[cfg(feature = "mysql_kvbackend")] - Error::MySqlExecution { .. } - | Error::CreateMySqlPool { .. } - | Error::ParseMySqlUrl { .. } - | Error::DecodeSqlValue { .. } - | Error::AcquireMySqlClient { .. } => StatusCode::Internal, - #[cfg(any(feature = "pg_kvbackend", feature = "mysql_kvbackend"))] - Error::SqlExecutionTimeout { .. } => StatusCode::Internal, + Error::CreateMySqlPool { .. } | Error::ParseMySqlUrl { .. } => StatusCode::Internal, } } @@ -1385,30 +1200,16 @@ impl ErrorExt for Error { | Error::MailboxTimeout { .. } | Error::NoEnoughAvailableNode { .. } | Error::NoLeader { .. } - | Error::LeaderLeaseExpired { .. } - | Error::LeaderLeaseChanged { .. } | Error::PeerUnavailable { .. } => RetryHint::Retryable, - Error::ConnectEtcd { error, .. } | Error::EtcdFailed { error, .. } => { + Error::ConnectEtcd { error, .. } => { common_meta::error::retry_hint_from_etcd_error(error) } - #[cfg(feature = "pg_kvbackend")] - Error::PostgresExecution { error, .. } => { - common_meta::error::retry_hint_from_postgres_error(error) - } - #[cfg(feature = "pg_kvbackend")] - Error::GetPostgresClient { error, .. } => { - common_meta::error::retry_hint_from_postgres_pool_error(error) - } #[cfg(feature = "mysql_kvbackend")] - Error::MySqlExecution { error, .. } - | Error::CreateMySqlPool { error, .. } - | Error::AcquireMySqlClient { error, .. } => { + Error::CreateMySqlPool { error, .. } => { common_meta::error::retry_hint_from_sqlx_error(error) } - #[cfg(any(feature = "pg_kvbackend", feature = "mysql_kvbackend"))] - Error::SqlExecutionTimeout { .. } => RetryHint::Retryable, Error::ListActiveFrontends { source, .. } | Error::ListActiveDatanodes { source, .. } @@ -1421,7 +1222,6 @@ impl ErrorExt for Error { | Error::PeekSequence { source, .. } | Error::SubmitDdlTask { source, .. } | Error::SubmitReconcileProcedure { source, .. } - | Error::InvalidateTableCache { source, .. } | Error::ConvertProtoData { source, .. } | Error::TableMetadataManager { source, .. } | Error::RuntimeSwitchManager { source, .. } @@ -1443,11 +1243,9 @@ impl ErrorExt for Error { | Error::AllocateWalOptions { source, .. } | Error::RepartitionGcRequirement { source, .. } => source.retry_hint(), - Error::Other { source, .. } - | Error::ListCatalogs { source, .. } - | Error::ListSchemas { source, .. } - | Error::ListTables { source, .. } - | Error::DowngradeLeader { source, .. } => source.retry_hint(), + Error::Other { source, .. } | Error::DowngradeLeader { source, .. } => { + source.retry_hint() + } Error::SubmitProcedure { source, .. } | Error::WaitProcedure { source, .. } diff --git a/src/mito2/src/error.rs b/src/mito2/src/error.rs index 1187af8d116..c06f04fca43 100644 --- a/src/mito2/src/error.rs +++ b/src/mito2/src/error.rs @@ -1160,12 +1160,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Encode null value"))] - IndexEncodeNull { - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to encode memtable to Parquet bytes"))] EncodeMemtable { #[snafu(source)] @@ -1759,7 +1753,6 @@ impl ErrorExt for Error { | CreateDefault { .. } | InvalidParquet { .. } | OperateAbortedIndex { .. } - | IndexEncodeNull { .. } | NoCheckpoint { .. } | NoManifests { .. } | FilesLost { .. } diff --git a/src/operator/src/error.rs b/src/operator/src/error.rs index 0b4b731cb38..6b6d23d268d 100644 --- a/src/operator/src/error.rs +++ b/src/operator/src/error.rs @@ -514,14 +514,6 @@ pub enum Error { error: regex::Error, }, - #[snafu(display("Failed to insert value into table: {}", table_name))] - Insert { - table_name: String, - #[snafu(implicit)] - location: Location, - source: table::error::Error, - }, - #[snafu(display("Unsupported format: {:?}", format))] UnsupportedFormat { #[snafu(implicit)] @@ -891,13 +883,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to decode arrow flight data"))] - DecodeFlightData { - source: common_grpc::error::Error, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to perform arrow compute"))] ComputeArrow { #[snafu(source)] @@ -1100,7 +1085,7 @@ impl ErrorExt for Error { Error::ParseFileFormat { source, .. } | Error::InferSchema { source, .. } => { source.status_code() } - Error::Table { source, .. } | Error::Insert { source, .. } => source.status_code(), + Error::Table { source, .. } => source.status_code(), Error::ConvertColumnDefaultConstraint { source, .. } | Error::IntoVectors { source, .. } => source.status_code(), Error::RequestInserts { source, .. } | Error::FindViewInfo { source, .. } => { @@ -1171,7 +1156,6 @@ impl ErrorExt for Error { Error::BuildRecordBatch { source, .. } => source.status_code(), Error::UpgradeCatalogManagerRef { .. } => StatusCode::Internal, Error::ColumnOptions { source, .. } => source.status_code(), - Error::DecodeFlightData { source, .. } => source.status_code(), Error::ComputeArrow { .. } => StatusCode::Internal, Error::InvalidTimeIndexType { .. } | Error::InvalidTimezone { .. } => { StatusCode::InvalidArguments @@ -1251,9 +1235,9 @@ impl ErrorExt for Error { | Error::InvalidColumnDef { source, .. } | Error::ColumnOptions { source, .. } => source.retry_hint(), - Error::Table { source, .. } - | Error::Insert { source, .. } - | Error::MissingTimeIndexColumn { source, .. } => source.retry_hint(), + Error::Table { source, .. } | Error::MissingTimeIndexColumn { source, .. } => { + source.retry_hint() + } Error::Cast { source, .. } => source.retry_hint(), Error::ExecuteAdminFunction { error, .. } => admin_external_error(error) @@ -1265,7 +1249,6 @@ impl ErrorExt for Error { Error::External { source, .. } => source.retry_hint(), Error::BatchFlush { source, .. } => source.retry_hint(), Error::BuildRecordBatch { source, .. } => source.retry_hint(), - Error::DecodeFlightData { source, .. } => source.retry_hint(), Error::SqlCommon { source, .. } => source.retry_hint(), Error::ConvertSchema { source, .. } => source.retry_hint(), Error::WriteStreamToFile { source, .. } => source.retry_hint(), diff --git a/src/partition/src/error.rs b/src/partition/src/error.rs index 243dd6ccc0c..44148b04444 100644 --- a/src/partition/src/error.rs +++ b/src/partition/src/error.rs @@ -17,7 +17,6 @@ use std::any::Any; use common_error::ext::{ErrorExt, RetryHint}; use common_error::status_code::StatusCode; use common_macro::stack_trace_debug; -use datafusion_common::ScalarValue; use datatypes::arrow; use datatypes::prelude::Value; use snafu::{Location, Snafu}; @@ -51,25 +50,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to get meta info from cache, error: {}", err_msg))] - GetCache { - err_msg: String, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display( - "Failed to find region routes for table {}, region id: {}", - table_id, - region_id - ))] - FindRegionRoutes { - table_id: TableId, - region_id: u64, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to serialize value to json"))] SerializeJson { #[snafu(source)] @@ -94,13 +74,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Invalid InsertRequest, reason: {}", reason))] - InvalidInsertRequest { - reason: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Invalid partition input, reason: {}", reason))] InvalidPartitionInput { reason: String, @@ -108,21 +81,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Invalid DeleteRequest, reason: {}", reason))] - InvalidDeleteRequest { - reason: String, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Failed to convert DataFusion's ScalarValue: {:?}", value))] - ConvertScalarValue { - value: ScalarValue, - #[snafu(implicit)] - location: Location, - source: datatypes::error::Error, - }, - #[snafu(display("Failed to find leader of table id {} region {}", table_id, region_id))] FindLeader { table_id: TableId, @@ -131,14 +89,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Unexpected table route type: {}", err_msg))] - UnexpectedLogicalRouteTable { - #[snafu(implicit)] - location: Location, - err_msg: String, - source: common_meta::error::Error, - }, - #[snafu(display("Invalid partition expr: {:?}", expr))] InvalidExpr { expr: PartitionExpr, @@ -261,7 +211,6 @@ pub enum Error { impl ErrorExt for Error { fn status_code(&self) -> StatusCode { match self { - Error::GetCache { .. } => StatusCode::StorageUnavailable, Error::FindLeader { .. } => StatusCode::TableUnavailable, Error::InvalidExpr { .. } @@ -271,20 +220,16 @@ impl ErrorExt for Error { | Error::CheckpointNotCovered { .. } | Error::CheckpointOverlapped { .. } => StatusCode::InvalidArguments, - Error::RegionKeysSize { .. } - | Error::InvalidInsertRequest { .. } - | Error::InvalidPartitionInput { .. } - | Error::InvalidDeleteRequest { .. } => StatusCode::InvalidArguments, + Error::RegionKeysSize { .. } | Error::InvalidPartitionInput { .. } => { + StatusCode::InvalidArguments + } - Error::ConvertScalarValue { .. } - | Error::SerializeJson { .. } - | Error::DeserializeJson { .. } => StatusCode::Internal, + Error::SerializeJson { .. } | Error::DeserializeJson { .. } => StatusCode::Internal, - Error::Unexpected { .. } | Error::FindRegionRoutes { .. } => StatusCode::Unexpected, + Error::Unexpected { .. } => StatusCode::Unexpected, Error::TableRouteNotFound { .. } => StatusCode::TableNotFound, Error::TableRouteManager { source, .. } => source.status_code(), Error::GetPartitionInfo { source, .. } => source.status_code(), - Error::UnexpectedLogicalRouteTable { source, .. } => source.status_code(), Error::ConvertToVector { source, .. } => source.status_code(), Error::EvaluateRecordBatch { .. } => StatusCode::Internal, Error::ComputeArrowKernel { .. } => StatusCode::Internal, @@ -303,10 +248,10 @@ impl ErrorExt for Error { fn retry_hint(&self) -> RetryHint { match self { - Error::GetCache { .. } | Error::FindLeader { .. } => RetryHint::Retryable, - Error::TableRouteManager { source, .. } - | Error::GetPartitionInfo { source, .. } - | Error::UnexpectedLogicalRouteTable { source, .. } => source.retry_hint(), + Error::FindLeader { .. } => RetryHint::Retryable, + Error::TableRouteManager { source, .. } | Error::GetPartitionInfo { source, .. } => { + source.retry_hint() + } Error::ConvertToVector { source, .. } => source.retry_hint(), _ => RetryHint::NonRetryable, } diff --git a/src/query/src/error.rs b/src/query/src/error.rs index de7fcbaec17..6738ed3e909 100644 --- a/src/query/src/error.rs +++ b/src/query/src/error.rs @@ -357,13 +357,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to convert value for region pruning"))] - ConvertValue { - source: datatypes::error::Error, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to convert float seconds to duration, raw: {}", raw))] TryIntoDuration { raw: String, @@ -424,7 +417,6 @@ impl ErrorExt for Error { | UnsupportedVariable { .. } | ColumnSchemaNoDefault { .. } | CteColumnSchemaMismatch { .. } - | ConvertValue { .. } | TryIntoDuration { .. } | InvalidQueryContextExtension { .. } | ConflictingSnapshotSequence { .. } => StatusCode::InvalidArguments, diff --git a/src/servers/Cargo.toml b/src/servers/Cargo.toml index 55b6f56e00d..ce7c957acb5 100644 --- a/src/servers/Cargo.toml +++ b/src/servers/Cargo.toml @@ -88,7 +88,6 @@ meter-macros.workspace = true metric-engine.workspace = true mime_guess = "2.0" mysql_common = "0.38" -notify.workspace = true object-pool = "0.5" once_cell.workspace = true # Wait for https://github.com/databendlabs/opensrv/pull/81 diff --git a/src/servers/src/error.rs b/src/servers/src/error.rs index 2e8f4cbefdc..da20fcda19d 100644 --- a/src/servers/src/error.rs +++ b/src/servers/src/error.rs @@ -20,7 +20,6 @@ use axum::http::StatusCode as HttpStatusCode; use axum::response::{IntoResponse, Response}; use axum::{Json, http}; use base64::DecodeError; -use common_base::readable_size::ReadableSize; use common_error::define_into_tonic_status; use common_error::ext::{BoxedError, ErrorExt, RetryHint}; use common_error::status_code::StatusCode; @@ -95,12 +94,6 @@ pub enum Error { source: common_recordbatch::error::Error, }, - #[snafu(display("Failed to start HTTP server"))] - StartHttp { - #[snafu(source)] - error: hyper::Error, - }, - #[snafu(display("Failed to start gRPC server"))] StartGrpc { #[snafu(source)] @@ -187,18 +180,6 @@ pub enum Error { #[snafu(display("Invalid OTLP metric input: {}", reason))] InvalidOtlpMetricInput { reason: String }, - #[snafu(display( - "Too many concurrent large requests, limit: {}, request size: {}", - ReadableSize(*limit as u64), - ReadableSize(*request_size as u64) - ))] - TooManyConcurrentRequests { - limit: usize, - request_size: usize, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Unsupported operation: {}", operation))] UnsupportedOperation { operation: String }, @@ -404,14 +385,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Invalid utf-8 value"))] - InvalidUtf8Value { - #[snafu(source)] - error: FromUtf8Error, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Invalid http header value"))] InvalidHeaderValue { #[snafu(source)] @@ -612,21 +585,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Invalid table name"))] - InvalidTableName { - #[snafu(source)] - error: tonic::metadata::errors::ToStrError, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Failed to initialize a watcher for file {}", path))] - FileWatch { - path: String, - #[snafu(source)] - error: notify::Error, - }, - #[snafu(display("Timestamp overflow: {}", error))] TimestampOverflow { error: String, @@ -746,12 +704,10 @@ impl ErrorExt for Error { | BatcherChannelClosed | InternalIo { .. } | TokioIo { .. } - | StartHttp { .. } | StartGrpc { .. } | TcpBind { .. } | BuildHttpResponse { .. } - | Arrow { .. } - | FileWatch { .. } => StatusCode::Internal, + | Arrow { .. } => StatusCode::Internal, AddressBind { .. } | AlreadyStarted { .. } @@ -804,7 +760,6 @@ impl ErrorExt for Error { | UnsupportedContentType { .. } | TimestampOverflow { .. } | UnsupportedJsonDataTypeForTag { .. } - | InvalidTableName { .. } | PrepareStatementNotFound { .. } | FailedToParseQuery { .. } | InvalidElasticsearchInput { .. } @@ -832,9 +787,7 @@ impl ErrorExt for Error { #[cfg(feature = "mem-prof")] DumpProfileData { source, .. } => source.status_code(), - InvalidUtf8Value { .. } | InvalidHeaderValue { .. } => StatusCode::InvalidArguments, - - TooManyConcurrentRequests { .. } => StatusCode::RuntimeResourcesExhausted, + InvalidHeaderValue { .. } => StatusCode::InvalidArguments, ParsePromQL { source, .. } => source.status_code(), Other { source, .. } => source.status_code(), @@ -910,7 +863,7 @@ impl ErrorExt for Error { MemoryLimitExceeded { source, .. } => source.retry_hint(), CollectRecordbatch { source, .. } => source.retry_hint(), - TooManyConcurrentRequests { .. } | WriteRejected { .. } => RetryHint::Retryable, + WriteRejected { .. } => RetryHint::Retryable, _ => RetryHint::NonRetryable, } diff --git a/src/sql/src/error.rs b/src/sql/src/error.rs index 2cbc4adc896..afbc8117568 100644 --- a/src/sql/src/error.rs +++ b/src/sql/src/error.rs @@ -129,20 +129,6 @@ pub enum Error { location: Location, }, - #[snafu(display( - "Column {} expect type: {:?}, actual: {:?}", - column_name, - expect, - actual, - ))] - ColumnTypeMismatch { - column_name: String, - expect: ConcreteDataType, - actual: ConcreteDataType, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Invalid database name: {}", name))] InvalidDatabaseName { name: String, @@ -378,7 +364,6 @@ impl ErrorExt for Error { | InvalidDatabaseName { .. } | InvalidDatabaseOption { .. } | InvalidDatabaseOptionValue { .. } - | ColumnTypeMismatch { .. } | InvalidTableName { .. } | InvalidFlowName { .. } | InvalidFlowQuery { .. } diff --git a/src/table/Cargo.toml b/src/table/Cargo.toml index aa0f85d905a..53e4dd5fe5d 100644 --- a/src/table/Cargo.toml +++ b/src/table/Cargo.toml @@ -22,7 +22,6 @@ common-error.workspace = true common-macro.workspace = true common-query.workspace = true common-recordbatch.workspace = true -common-sql.workspace = true common-telemetry.workspace = true common-time.workspace = true datafusion.workspace = true diff --git a/src/table/src/error.rs b/src/table/src/error.rs index 9705ab3f9a2..75530d7413b 100644 --- a/src/table/src/error.rs +++ b/src/table/src/error.rs @@ -121,9 +121,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to operate table"))] - TableOperation { source: BoxedError }, - #[snafu(display("Unsupported operation: {}", operation))] Unsupported { operation: String }, @@ -218,13 +215,6 @@ pub enum Error { #[snafu(implicit)] location: Location, }, - - #[snafu(display("Sql common error"))] - SqlCommon { - source: common_sql::error::Error, - #[snafu(implicit)] - location: Location, - }, } impl ErrorExt for Error { @@ -241,11 +231,9 @@ impl ErrorExt for Error { Error::CastDefaultValue { source, .. } => source.status_code(), Error::TablesRecordBatch { .. } => StatusCode::Unexpected, Error::ColumnExists { .. } => StatusCode::TableColumnExists, - Error::SqlCommon { source, .. } => source.status_code(), Error::SchemaBuild { source, .. } | Error::SetFulltextOptions { source, .. } => { source.status_code() } - Error::TableOperation { source } => source.status_code(), Error::InvalidColumnOption { .. } => StatusCode::InvalidArguments, Error::ColumnNotExists { .. } => StatusCode::TableColumnNotFound, Error::Unsupported { .. } => StatusCode::Unsupported,