diff --git a/Cargo.lock b/Cargo.lock index 8fd4e50b5e139..d158be22c0a52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5955,6 +5955,7 @@ dependencies = [ "risingwave_sqlparser", "tempfile", "thiserror", + "thiserror-ext", "tokio-openssl", "tokio-postgres", "tracing", @@ -9488,9 +9489,9 @@ dependencies = [ [[package]] name = "sqllogictest" -version = "0.17.2" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ea1056caa9180e7e5727eed1a377d96c9f4615303fa82d2f4c202c64736dee" +checksum = "e67e8d8e7f43fc5d4c35be73549ea22ed1d712dcf39656a243144677297da5ec" dependencies = [ "async-trait", "educe", @@ -9984,9 +9985,9 @@ dependencies = [ [[package]] name = "thiserror-ext" -version = "0.0.1" +version = "0.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f28a4a7351f496662affc257826b85dd2a613406ce3cc2f07b849685e166d8c" +checksum = "764a8c5e60a634fe2173e20038dc4d11195559b4099c61fc60e489e813268a68" dependencies = [ "thiserror", "thiserror-ext-derive", @@ -9994,9 +9995,9 @@ dependencies = [ [[package]] name = "thiserror-ext-derive" -version = "0.0.1" +version = "0.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67621f6d39449754da63668ddd2423ad0c81c27434c16090f8805ad1db59b621" +checksum = "5741c7e65941d49975050cfc4d010e2786404a5e1cc130baa12132bfcf8efda4" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 884b09edd7bda..ae1a3e2cdd70d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -121,7 +121,7 @@ arrow-buffer = "48" arrow-flight = "48" arrow-select = "48" arrow-ord = "48" -thiserror-ext = "0.0.1" +thiserror-ext = "0.0.5" tikv-jemalloc-ctl = { git = "https://github.com/risingwavelabs/jemallocator.git", rev = "64a2d9" } tikv-jemallocator = { git = "https://github.com/risingwavelabs/jemallocator.git", features = [ "profiling", diff --git a/Makefile.toml b/Makefile.toml index 6620972028653..e2df275de0c4b 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -1333,7 +1333,7 @@ echo "All processes has exited." [tasks.slt] category = "RiseDev - SQLLogicTest" -install_crate = { version = "0.17.2", crate_name = "sqllogictest-bin", binary = "sqllogictest", test_arg = [ +install_crate = { version = "0.18.0", crate_name = "sqllogictest-bin", binary = "sqllogictest", test_arg = [ "--help", ], install_command = "binstall" } dependencies = ["check-risedev-env-file"] diff --git a/ci/Dockerfile b/ci/Dockerfile index dc75af612598e..427e6d68dc116 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -48,7 +48,7 @@ ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash RUN cargo binstall -y --no-symlinks cargo-llvm-cov cargo-nextest cargo-hakari cargo-sort cargo-cache cargo-audit \ cargo-make@0.36.10 \ - sqllogictest-bin@0.17.2 \ + sqllogictest-bin@0.18.0 \ && cargo install sccache \ && cargo cache -a \ && rm -rf "/root/.cargo/registry/index" \ diff --git a/ci/build-ci-image.sh b/ci/build-ci-image.sh index 723fe00a76518..22f486aefdcfa 100755 --- a/ci/build-ci-image.sh +++ b/ci/build-ci-image.sh @@ -9,7 +9,7 @@ cd "$DIR" cat ../rust-toolchain # shellcheck disable=SC2155 -export BUILD_ENV_VERSION=v20231101 +export BUILD_ENV_VERSION=v20231109 export BUILD_TAG="public.ecr.aws/x5u3w5h6/rw-build-env:${BUILD_ENV_VERSION}" diff --git a/ci/docker-compose.yml b/ci/docker-compose.yml index 41ce645f567be..c6289789d5e67 100644 --- a/ci/docker-compose.yml +++ b/ci/docker-compose.yml @@ -71,7 +71,7 @@ services: retries: 5 source-test-env: - image: public.ecr.aws/x5u3w5h6/rw-build-env:v20231101 + image: public.ecr.aws/x5u3w5h6/rw-build-env:v20231109 depends_on: - mysql - db @@ -81,7 +81,7 @@ services: - ..:/risingwave sink-test-env: - image: public.ecr.aws/x5u3w5h6/rw-build-env:v20231101 + image: public.ecr.aws/x5u3w5h6/rw-build-env:v20231109 depends_on: - mysql - db @@ -93,12 +93,12 @@ services: - ..:/risingwave rw-build-env: - image: public.ecr.aws/x5u3w5h6/rw-build-env:v20231101 + image: public.ecr.aws/x5u3w5h6/rw-build-env:v20231109 volumes: - ..:/risingwave ci-flamegraph-env: - image: public.ecr.aws/x5u3w5h6/rw-build-env:v20231101 + image: public.ecr.aws/x5u3w5h6/rw-build-env:v20231109 # NOTE(kwannoel): This is used in order to permit # syscalls for `nperf` (perf_event_open), # so it can do CPU profiling. @@ -109,7 +109,7 @@ services: - ..:/risingwave regress-test-env: - image: public.ecr.aws/x5u3w5h6/rw-build-env:v20231101 + image: public.ecr.aws/x5u3w5h6/rw-build-env:v20231109 depends_on: db: condition: service_healthy diff --git a/ci/scripts/run-e2e-test.sh b/ci/scripts/run-e2e-test.sh index 8fb29ec5bd1a2..360c9837e08f7 100755 --- a/ci/scripts/run-e2e-test.sh +++ b/ci/scripts/run-e2e-test.sh @@ -103,6 +103,14 @@ sqllogictest -p 4566 -d dev './e2e_test/generated/**/*.slt' --junit "generated-$ echo "--- Kill cluster" cluster_stop +echo "--- e2e, $mode, error ui" +RUST_LOG="info,risingwave_stream=info,risingwave_batch=info,risingwave_storage=info" \ +cluster_start +sqllogictest -p 4566 -d dev './e2e_test/error_ui/**/*.slt' + +echo "--- Kill cluster" +cluster_stop + echo "--- e2e, $mode, extended query" RUST_LOG="info,risingwave_stream=info,risingwave_batch=info,risingwave_storage=info" \ cluster_start diff --git a/e2e_test/batch/aggregate/sum.slt.part b/e2e_test/batch/aggregate/sum.slt.part index 825b684975986..1bb04023e04ab 100644 --- a/e2e_test/batch/aggregate/sum.slt.part +++ b/e2e_test/batch/aggregate/sum.slt.part @@ -77,8 +77,8 @@ select sum(d) from t; statement ok insert into t values (9000000000000000000000000000); -statement error Expr error: Numeric out of range +statement error Numeric out of range select sum(d) from t; statement ok -drop table t; \ No newline at end of file +drop table t; diff --git a/e2e_test/batch/basic/dml.slt.part b/e2e_test/batch/basic/dml.slt.part index 281eabf709c2f..a5a260169784c 100644 --- a/e2e_test/batch/basic/dml.slt.part +++ b/e2e_test/batch/basic/dml.slt.part @@ -121,7 +121,7 @@ select * from t order by v1; 1 1 aa 3 2 bb -statement error QueryError: Bind error: update modifying the PK column is unsupported +statement error update modifying the PK column is unsupported update t set (v3, v2) = (v3||v3, v1+v2); statement ok diff --git a/e2e_test/batch/functions/pow.slt.part b/e2e_test/batch/functions/pow.slt.part index 152cb65be0ea8..7ea01e2e1233f 100644 --- a/e2e_test/batch/functions/pow.slt.part +++ b/e2e_test/batch/functions/pow.slt.part @@ -46,11 +46,11 @@ select pow(100000, 0); statement error underflow select pow(100000, -200000000000000); -statement error QueryError: Expr error: Numeric out of range +statement error Numeric out of range select pow(100000, 200000000000000); -statement error QueryError: Expr error: Numeric out of range +statement error Numeric out of range select pow(-100000, 200000000000001); query R @@ -101,11 +101,11 @@ select 100000 ^ 0; statement error underflow select 100000 ^ -200000000000000; -statement error QueryError: Expr error: Numeric out of range +statement error Numeric out of range select 100000 ^ 200000000000000; -statement error QueryError: Expr error: Numeric out of range +statement error Numeric out of range select -100000 ^ 200000000000001; query RRRR @@ -231,10 +231,10 @@ select exp(2::smallint) ---- 7.38905609893065 -statement error QueryError: Expr error: Numeric out of range: overflow +statement error Numeric out of range: overflow select exp(10000000); -statement error QueryError: Expr error: Numeric out of range: underflow +statement error Numeric out of range: underflow select exp(-10000000); query TRR diff --git a/e2e_test/ddl/invalid_operation.slt b/e2e_test/ddl/invalid_operation.slt index f66aed1d3dc9a..df3f58eaf0354 100644 --- a/e2e_test/ddl/invalid_operation.slt +++ b/e2e_test/ddl/invalid_operation.slt @@ -253,7 +253,6 @@ SELECT * from msrc limit 0; # FIXME: improve the error message query error not found SELECT * from sink limit 0; ----- query I SELECT * from v limit 0; @@ -264,7 +263,7 @@ SELECT * from v limit 0; statement ok insert into t values (1); -statement error QueryError: Bind error: update modifying the PK column is unsupported +statement error update modifying the PK column is unsupported update t set v = 2; statement ok diff --git a/e2e_test/ddl/table/generated_columns.slt.part b/e2e_test/ddl/table/generated_columns.slt.part index feea107fe9ac1..0ba892b994865 100644 --- a/e2e_test/ddl/table/generated_columns.slt.part +++ b/e2e_test/ddl/table/generated_columns.slt.part @@ -14,7 +14,7 @@ select * from t1; 0 1 2 2.02 1 2 3 3.02 -statement error QueryError: Bind error: update modifying the generated column is unsupported +statement error update modifying the generated column is unsupported update t1 set v1 = 1; statement ok @@ -140,7 +140,7 @@ statement ok drop source t4; # create a table with generated column now -statement error QueryError: Bind error: failed to bind expression: now() +statement error failed to bind expression: now() CREATE TABLE t (v INT, t timestamptz as now()) WITH ( connector = 'datagen', fields.v.kind = 'sequence', @@ -151,9 +151,9 @@ CREATE TABLE t (v INT, t timestamptz as now()) WITH ( ) FORMAT PLAIN ENCODE JSON; # create a table with impure generated column as pk. -statement error QueryError: Bind error: Generated columns with impure expressions should not be part of the primary key. Here column "v2" is defined as part of the primary key. +statement error Generated columns with impure expressions should not be part of the primary key. Here column "v2" is defined as part of the primary key. CREATE TABLE t ( v1 INT, v2 timestamptz AS proctime(), PRIMARY KEY (v1, v2) -); \ No newline at end of file +); diff --git a/e2e_test/error_ui/README.md b/e2e_test/error_ui/README.md new file mode 100644 index 0000000000000..0aa51e5a9ee74 --- /dev/null +++ b/e2e_test/error_ui/README.md @@ -0,0 +1,12 @@ +# User Interface Test for Error Reporting + +The test cases in this directory act as snapshot tests for the error reporting, to ensure that the UI does not change unexpectedly. + +When you find the tests in this directory failing... + +- First, ensure that the changes to the error messages are expected and make them look better. +- Then, update the test cases by running: + ```bash + ./risedev slt './e2e_test/error_ui/**/*.slt' --override + ``` + Please note that the minimum required version of `sqllogictest` is 0.18 or higher. diff --git a/e2e_test/error_ui/main.slt b/e2e_test/error_ui/main.slt new file mode 100644 index 0000000000000..9a3df01ebd978 --- /dev/null +++ b/e2e_test/error_ui/main.slt @@ -0,0 +1,41 @@ +statement error +create function int_42() returns int as int_42 using link 'localhost:8815'; +---- +db error: ERROR: QueryError + +Caused by these errors (recent errors listed first): + 1: failed to connect to UDF service + 2: transport error + 3: error trying to connect + 4: invalid URL, scheme is missing + + +statement error +alter system set not_exist_key to value; +---- +db error: ERROR: QueryError + +Caused by this error: + 1: internal error: SystemParams error: unrecognized system param "not_exist_key" + + +query error +select v1 + v2 = v3; +---- +db error: ERROR: QueryError + +Caused by this error: + 1: Bind error: failed to bind expression: v1 + v2 = v3 + +Caused by: + Item not found: Invalid column: v1 + + +query error +select 1/0; +---- +db error: ERROR: QueryError + +Caused by these errors (recent errors listed first): + 1: Expr error + 2: Division by zero diff --git a/e2e_test/sink/append_only_sink.slt b/e2e_test/sink/append_only_sink.slt index 405ca132ae0a9..23bd1706465e3 100644 --- a/e2e_test/sink/append_only_sink.slt +++ b/e2e_test/sink/append_only_sink.slt @@ -22,7 +22,7 @@ create sink invalid_sink_type from t with (connector = 'blackhole', type = 'inva statement error `force_append_only` must be true or false create sink invalid_force_append_only from t with (connector = 'blackhole', force_append_only = 'invalid'); -statement error db error: ERROR: QueryError: Sink error: config error: unsupported sink type invalid +statement error unsupported sink type invalid create sink invalid_connector from t with (connector = 'invalid'); statement ok diff --git a/e2e_test/sink/kafka/avro.slt b/e2e_test/sink/kafka/avro.slt index a30d8b70fd4ba..88909135b9e53 100644 --- a/e2e_test/sink/kafka/avro.slt +++ b/e2e_test/sink/kafka/avro.slt @@ -71,7 +71,7 @@ create sink sink_err from into_kafka with ( format upsert encode avro ( schema.registry = 'http://message_queue:8081'); -statement error encode extra_column error: field not in avro +statement error field not in avro create sink sink_err as select 1 as extra_column, * from into_kafka with ( connector = 'kafka', topic = 'test-rw-sink-upsert-avro', diff --git a/e2e_test/sink/kafka/protobuf.slt b/e2e_test/sink/kafka/protobuf.slt index c6ccb2ac24416..9510c6e7fbf8b 100644 --- a/e2e_test/sink/kafka/protobuf.slt +++ b/e2e_test/sink/kafka/protobuf.slt @@ -76,7 +76,7 @@ format plain encode protobuf ( schema.location = 'file:///risingwave/proto-recursiv', message = 'recursive.AllTypes'); -statement error encode extra_column error: field not in proto +statement error field not in proto create sink sink_err as select 1 as extra_column with ( connector = 'kafka', topic = 'test-rw-sink-append-only-protobuf', diff --git a/e2e_test/source/basic/datagen.slt b/e2e_test/source/basic/datagen.slt index 14cbffb6b589b..dcda3718e49d5 100644 --- a/e2e_test/source/basic/datagen.slt +++ b/e2e_test/source/basic/datagen.slt @@ -182,9 +182,9 @@ statement ok drop table s1; # Do NOT allow With clause to contain a comma only. -statement error QueryError: sql parser error: Expected identifier.* +statement error Expected identifier.* create table s1 (v1 int) with (,) FORMAT PLAIN ENCODE JSON; # Do NOT allow an empty With clause. -statement error QueryError: sql parser error: Expected identifier.* +statement error Expected identifier.* create table s1 (v1 int) with () FORMAT PLAIN ENCODE JSON; diff --git a/e2e_test/source/basic/ddl.slt b/e2e_test/source/basic/ddl.slt index c6c1c0590d558..1bac32d5d512a 100644 --- a/e2e_test/source/basic/ddl.slt +++ b/e2e_test/source/basic/ddl.slt @@ -18,7 +18,7 @@ create source invalid_startup_mode ( ) FORMAT PLAIN ENCODE JSON; # TODO: Better to refine the error message. -statement error internal error: invalid digit found in string +statement error invalid digit found in string create source invalid_startup_timestamp ( column1 varchar ) with ( @@ -28,7 +28,7 @@ create source invalid_startup_timestamp ( properties.bootstrap.server = 'message_queue:29092' ) FORMAT PLAIN ENCODE JSON; -statement error db error: ERROR: QueryError: Protocol error: Schema definition is required, either from SQL or schema registry. +statement error Schema definition is required, either from SQL or schema registry. create source invalid_schema_definition with ( connector = 'kafka', diff --git a/e2e_test/source/basic/old_row_format_syntax/datagen.slt b/e2e_test/source/basic/old_row_format_syntax/datagen.slt index 629bc63728e74..267ae8eff4c66 100644 --- a/e2e_test/source/basic/old_row_format_syntax/datagen.slt +++ b/e2e_test/source/basic/old_row_format_syntax/datagen.slt @@ -182,9 +182,9 @@ statement ok drop table s1; # Do NOT allow With clause to contain a comma only. -statement error QueryError: sql parser error: Expected identifier.* +statement error Expected identifier.* create table s1 (v1 int) with (,) ROW FORMAT JSON; # Do NOT allow an empty With clause. -statement error QueryError: sql parser error: Expected identifier.* +statement error Expected identifier.* create table s1 (v1 int) with () ROW FORMAT JSON; diff --git a/e2e_test/source/basic/old_row_format_syntax/ddl.slt b/e2e_test/source/basic/old_row_format_syntax/ddl.slt index 6d1290463beeb..2ec7239e61d2c 100644 --- a/e2e_test/source/basic/old_row_format_syntax/ddl.slt +++ b/e2e_test/source/basic/old_row_format_syntax/ddl.slt @@ -18,7 +18,7 @@ create source invalid_startup_mode ( ) ROW FORMAT JSON; # TODO: Better to refine the error message. -statement error internal error: invalid digit found in string +statement error invalid digit found in string create source invalid_startup_timestamp ( column1 varchar ) with ( @@ -28,7 +28,7 @@ create source invalid_startup_timestamp ( properties.bootstrap.server = 'message_queue:29092' ) ROW FORMAT JSON; -statement error db error: ERROR: QueryError: Protocol error: Schema definition is required, either from SQL or schema registry. +statement error Schema definition is required, either from SQL or schema registry. create source invalid_schema_definition with ( connector = 'kafka', diff --git a/e2e_test/streaming/watermark.slt b/e2e_test/streaming/watermark.slt index d1a29b88188cf..5d8f189dfd965 100644 --- a/e2e_test/streaming/watermark.slt +++ b/e2e_test/streaming/watermark.slt @@ -55,7 +55,7 @@ statement ok drop table t; # create a watermark with different return type from column -statement error QueryError: Bind error: The return value type of the watermark expression must be identical to the watermark column data type. Current data type of watermark return value: `timestamp with time zone`, column `integer` +statement error The return value type of the watermark expression must be identical to the watermark column data type. Current data type of watermark return value: `timestamp with time zone`, column `integer` CREATE TABLE t ( v INT, WATERMARK FOR v AS to_timestamp(v) - INTERVAL '5' SECOND diff --git a/src/tests/simulation/Cargo.toml b/src/tests/simulation/Cargo.toml index f5b9d48eb0d20..15ae2e667ff6c 100644 --- a/src/tests/simulation/Cargo.toml +++ b/src/tests/simulation/Cargo.toml @@ -46,7 +46,7 @@ risingwave_sqlsmith = { workspace = true } serde = "1.0.188" serde_derive = "1.0.188" serde_json = "1.0.107" -sqllogictest = "0.17.2" +sqllogictest = "0.18" tempfile = "3" tikv-jemallocator = { workspace = true } tokio = { version = "0.2.24", package = "madsim-tokio" } diff --git a/src/utils/pgwire/Cargo.toml b/src/utils/pgwire/Cargo.toml index c7b6faf3c885d..c62def532c362 100644 --- a/src/utils/pgwire/Cargo.toml +++ b/src/utils/pgwire/Cargo.toml @@ -26,6 +26,7 @@ panic-message = "0.3" risingwave_common = { workspace = true } risingwave_sqlparser = { workspace = true } thiserror = "1" +thiserror-ext = { workspace = true } tokio = { version = "0.2", package = "madsim-tokio", features = ["rt", "macros"] } tokio-openssl = "0.6.3" tracing = "0.1" diff --git a/src/utils/pgwire/src/error.rs b/src/utils/pgwire/src/error.rs index ce3e3d05bef7d..c591d2f5a15ae 100644 --- a/src/utils/pgwire/src/error.rs +++ b/src/utils/pgwire/src/error.rs @@ -44,8 +44,9 @@ pub enum PsqlError { #[error(transparent)] Internal(BoxedError), - #[error("Panicked when processing: {0}.\n -This is a bug. We would appreciate a bug report at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Fbug&template=bug_report.yml.")] + #[error("Panicked when processing: {0} +This is a bug. We would appreciate a bug report at: + https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Fbug&template=bug_report.yml")] Panic(String), #[error("Unable to set up an ssl connection")] diff --git a/src/utils/pgwire/src/pg_message.rs b/src/utils/pgwire/src/pg_message.rs index b28d09116f94f..c38182db198f2 100644 --- a/src/utils/pgwire/src/pg_message.rs +++ b/src/utils/pgwire/src/pg_message.rs @@ -628,12 +628,14 @@ impl<'a> BeMessage<'a> { } BeMessage::ErrorResponse(error) => { + use thiserror_ext::AsReport; // For all the errors set Severity to Error and error code to // 'internal error'. // 'E' signalizes ErrorResponse messages buf.put_u8(b'E'); - let msg = error.to_string(); + // Format the error as a pretty report. + let msg = format!("{:#}", error.as_ref().as_report()); write_err_or_notice(buf, &ErrorOrNoticeMessage::internal_error(&msg))?; }