提交 522c7c09 编写于 作者: H Heikki Linnakangas

Use ereport() rather than elog(), for "expected" ERRORs.

Use ereport(), with a proper error code, for errors that are "expected" to
happen sometimes, like missing configuration files, or network failure.

That's nicer in general, but the reason I bumped into this is that internal
error messages include a source file name and line number in GPDB, and if
those error messages are included in the expected output of regression
tests, those tests will fail any time you do change the file, so that the
elog() moves around and the line number changes.
上级 288dde95
......@@ -462,9 +462,11 @@ check_response(URL_CURL_FILE *file, int *rc, char **response_string)
*/
pg_usleep(1000000);
elog(ERROR, "http response code %ld from gpfdist (%s): %s",
response_code, file->common.url,
file->http_response ? file->http_response : "?");
ereport(ERROR,
(errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("http response code %ld from gpfdist (%s): %s",
response_code, file->common.url,
file->http_response ? file->http_response : "?")));
}
}
......@@ -582,8 +584,10 @@ gp_curl_easy_perform_backoff_and_check_response(URL_CURL_FILE *file)
break;
default:
elog(ERROR, "error while getting response from gpfdist on %s (code %d, msg %s)",
file->curl_url, response_code, response_string);
ereport(ERROR,
(errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("error while getting response from gpfdist on %s (code %d, msg %s)",
file->curl_url, response_code, response_string)));
}
if (response_string)
pfree(response_string);
......@@ -592,8 +596,10 @@ gp_curl_easy_perform_backoff_and_check_response(URL_CURL_FILE *file)
if (wait_time > MAX_TRY_WAIT_TIME || timeout_count >= 2)
{
elog(ERROR, "error when writing data to gpfdist %s, quit after %d tries",
file->curl_url, retry_count+1);
ereport(ERROR,
(errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("error when writing data to gpfdist %s, quit after %d tries",
file->curl_url, retry_count+1)));
}
else
{
......@@ -692,7 +698,9 @@ fill_buffer(URL_CURL_FILE *curl, int want)
curl->in.bot, curl->in.top, want, maxfd, nfds, e, curl->still_running,
curl->for_write, curl->error, curl->eof, curl->block.datalen);
get_gpfdist_status(curl);
elog(ERROR, "segment has not received data from gpfdist for long time, cancelling the query.");
ereport(ERROR,
(errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("segment has not received data from gpfdist for long time, cancelling the query.")));
break;
}
}
......@@ -1207,7 +1215,10 @@ url_curl_fopen(char *url, bool forwrite, extvar_t *ev, CopyState pstate)
snprintf(extssl_cer_full, MAXPGPATH, "%s/%s", DataDir, extssl_cert);
if (!is_file_exists(extssl_cer_full))
elog(ERROR, "file %s doesn't exists", extssl_cer_full);
ereport(ERROR,
(errcode(errcode_for_file_access()),
errmsg("could not open certificate file \"%s\": %m",
extssl_cer_full)));
CURL_EASY_SETOPT(file->curl->handle, CURLOPT_SSLCERT, extssl_cer_full);
}
......@@ -1225,19 +1236,25 @@ url_curl_fopen(char *url, bool forwrite, extvar_t *ev, CopyState pstate)
snprintf(extssl_key_full, MAXPGPATH, "%s/%s", DataDir, extssl_key);
if (!is_file_exists(extssl_key_full))
elog(ERROR, "file %s doesn't exists", extssl_cer_full);
ereport(ERROR,
(errcode(errcode_for_file_access()),
errmsg("could not open private key file \"%s\": %m",
extssl_key_full)));
CURL_EASY_SETOPT(file->curl->handle, CURLOPT_SSLKEY, extssl_key_full);
}
/* set the file with the certs vaildating the server */
/* set the file with the CA certificates, for validating the server */
if (extssl_ca != NULL)
{
memset(extssl_cas_full, 0, MAXPGPATH);
snprintf(extssl_cas_full, MAXPGPATH, "%s/%s", DataDir, extssl_ca);
if (!is_file_exists(extssl_cas_full))
elog(ERROR, "file %s doesn't exists", extssl_cer_full);
ereport(ERROR,
(errcode(errcode_for_file_access()),
errmsg("could not open private key file \"%s\": %m",
extssl_cer_full)));
CURL_EASY_SETOPT(file->curl->handle, CURLOPT_CAINFO, extssl_cas_full);
}
......@@ -1461,16 +1478,14 @@ gp_proto1_read(char *buf, int bufsz, URL_CURL_FILE *file, CopyState pstate, char
n = file->in.top - file->in.bot;
if (n == 0)
{
elog(ERROR, "gpfdist error: server closed connection.\n");
return -1;
}
ereport(ERROR,
(errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("gpfdist error: server closed connection.")));
if (n < 5)
{
elog(ERROR, "gpfdist error: incomplete packet - packet len %d\n", n);
return -1;
}
ereport(ERROR,
(errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("gpfdist error: incomplete packet - packet len %d", n)));
/* read type */
type = file->in.ptr[file->in.bot++];
......@@ -1502,7 +1517,9 @@ gp_proto1_read(char *buf, int bufsz, URL_CURL_FILE *file, CopyState pstate, char
*/
char x = file->in.ptr[file->in.bot + n - 1];
file->in.ptr[file->in.bot + n - 1] = 0;
elog(ERROR, "gpfdist error - %s%c", &file->in.ptr[file->in.bot], x);
ereport(ERROR,
(errcode(ERRCODE_DATA_EXCEPTION),
errmsg("gpfdist error - %s%c", &file->in.ptr[file->in.bot], x)));
}
elog(ERROR, "gpfdist error: please check gpfdist log messages.");
......@@ -1605,11 +1622,13 @@ gp_proto1_read(char *buf, int bufsz, URL_CURL_FILE *file, CopyState pstate, char
{
file->error = 1;
if(!file->still_running)
elog(ERROR, "gpfdist server closed connection. \nThis is not a "
"GPDB defect. \nThe root cause is an overload of the ETL host or "
"a temporary network glitch between the database and the ETL host "
"causing the connection between the gpfdist and database to disconnect.\n");
if (!file->still_running)
ereport(ERROR,
(errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("gpfdist server closed connection."),
errhint("This is not a GPDB defect. \nThe root cause is an overload of the ETL host or "
"a temporary network glitch between the database and the ETL host "
"causing the connection between the gpfdist and database to disconnect.")));
}
if (n > bufsz)
......
......@@ -628,13 +628,13 @@ create external table bad_location1 (a int4, b text)
location ('gpfdist://@hostname@:7070/exttab1/non_existent_dir/*' )
format 'csv';
select count(*) from bad_location1;
ERROR: http response code 404 from gpfdist (gpfdist://@hostname@:7070/exttab1/non_existent_dir/*): HTTP/1.0 404 file not found (url_curl.c:467)
ERROR: http response code 404 from gpfdist (gpfdist://@hostname@:7070/exttab1/non_existent_dir/*): HTTP/1.0 404 file not found
drop external table bad_location1;
create external table bad_location2 (a int4, b text)
location ('gpfdist://@hostname@:7070/exttab1/non_existent_file.txt' )
format 'csv';
select count(*) from bad_location2;
ERROR: http response code 404 from gpfdist (gpfdist://@hostname@:7070/exttab1/non_existent_file.txt): HTTP/1.0 404 file not found (url_curl.c:467)
ERROR: http response code 404 from gpfdist (gpfdist://@hostname@:7070/exttab1/non_existent_file.txt): HTTP/1.0 404 file not found
drop external table bad_location2;
--
-- WET tests
......
......@@ -411,7 +411,7 @@ FORMAT 'text'
)
;
SELECT count(*) FROM ext_lineitem;
ERROR: http response code 404 from gpfdist (gpfdist://@hostname@:7070/gpfdist2/invalid_filename.txt): HTTP/1.0 404 file not found (url_curl.c:467) (seg0 slice1 172.17.0.4:25432 pid=36415)
ERROR: http response code 404 from gpfdist (gpfdist://@hostname@:7070/gpfdist2/invalid_filename.txt): HTTP/1.0 404 file not found (seg0 slice1 172.17.0.4:25432 pid=36415)
DROP EXTERNAL TABLE ext_lineitem;
-- test 12
CREATE EXTERNAL TABLE ext_lineitem (
......@@ -548,7 +548,7 @@ FORMAT 'text'
)
;
SELECT DISTINCT L_ORDERKEY FROM ext_lineitem WHERE L_ORDERKEY > 10 GROUP BY L_ORDERKEY ORDER BY L_ORDERKEY LIMIT 10 OFFSET 2;
ERROR: http response code 404 from gpfdist (gpfdist://@hostname@:7070/gpfdist2/data/lineitem.tbl): HTTP/1.0 404 file not found (url_curl.c:467) (seg0 slice1 172.17.0.4:25432 pid=36454)
ERROR: http response code 404 from gpfdist (gpfdist://@hostname@:7070/gpfdist2/data/lineitem.tbl): HTTP/1.0 404 file not found (seg0 slice1 172.17.0.4:25432 pid=36454)
DROP EXTERNAL TABLE ext_lineitem;
-- test 16
CREATE EXTERNAL TABLE ext_lineitem (
......@@ -958,7 +958,7 @@ FORMAT 'text'
)
;
SELECT count(*) FROM ext_test;
ERROR: gpfdist error - line too long in file @abs_srcdir@/data/gpfdist2/longline.txt near (0 bytes) (url_curl.c:1505) (seg1 slice1 172.17.0.4:25433 pid=36416)
ERROR: gpfdist error - line too long in file @abs_srcdir@/data/gpfdist2/longline.txt near (0 bytes) (seg1 slice1 172.17.0.4:25433 pid=36416)
DETAIL: External table ext_test, file gpfdist://@hostname@:7070/gpfdist2/longline.txt
DROP EXTERNAL TABLE ext_test;
CREATE EXTERNAL TABLE ext_test1 (
......@@ -975,7 +975,7 @@ FORMAT 'csv'
)
;
SELECT count(*) FROM ext_test1;
ERROR: gpfdist error - line too long in file @abs_srcdir@/data/gpfdist2/longline.csv near (0 bytes) (url_curl.c:1505) (seg0 slice1 172.17.0.4:25432 pid=36415)
ERROR: gpfdist error - line too long in file @abs_srcdir@/data/gpfdist2/longline.csv near (0 bytes) (seg0 slice1 172.17.0.4:25432 pid=36415)
DETAIL: External table ext_test1, file gpfdist://@hostname@:7070/gpfdist2/longline.csv
DROP EXTERNAL TABLE ext_test1;
CREATE EXTERNAL TABLE ext_lineitem (
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册