Skip to content

Do not expose internal error codes to client #5010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions db/osqlcomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -7547,8 +7547,9 @@ int osql_process_packet(struct ireq *iq, uuid_t uuid, void *trans, char **pmsg,

if (rc != 0) {
if (rc != RC_INTERNAL_RETRY) {
errstat_cat_strf(&iq->errstat,
" unable to update record rc = %d", rc);
errstat_cat_strf(&iq->errstat," unable to update record");
logmsg(LOGMSG_ERROR, "%s:%d Failed to update record. Internal error code is %d\n",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need this for diagnosing an issue if we send 'generic internal error' to the client

__func__, __LINE__, rc);
}
if (gbl_enable_osql_logging)
logmsg(LOGMSG_DEBUG,
Expand Down
2 changes: 1 addition & 1 deletion db/sqlglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -5243,7 +5243,7 @@ int sqlite3BtreeCommit(Btree *pBt)
if (clnt->early_retry == EARLY_ERR_VERIFY) {
clnt->osql.xerr.errval = ERR_BLOCK_FAILED + ERR_VERIFY;
errstat_cat_str(&(clnt->osql.xerr),
"unable to update record rc = 4");
"unable to update record");
} else if (clnt->early_retry == EARLY_ERR_SELECTV) {
clnt->osql.xerr.errval = ERR_CONSTR;
errstat_cat_str(&(clnt->osql.xerr),
Expand Down
2 changes: 1 addition & 1 deletion db/sqlinterfaces.c
Original file line number Diff line number Diff line change
Expand Up @@ -2182,7 +2182,7 @@ static int do_commitrollback(struct sqlthdstate *thd, struct sqlclntstate *clnt,
if (clnt->early_retry == EARLY_ERR_VERIFY) {
clnt->osql.xerr.errval = ERR_BLOCK_FAILED + ERR_VERIFY;
errstat_cat_str(&(clnt->osql.xerr),
"unable to update record rc = 4");
"unable to update record");
} else if (clnt->early_retry == EARLY_ERR_SELECTV) {
clnt->osql.xerr.errval = ERR_CONSTR;
errstat_cat_str(&(clnt->osql.xerr),
Expand Down
2 changes: 1 addition & 1 deletion db/sqloffload.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ static int rese_commit(struct sqlclntstate *clnt, struct sql_thread *thd,
} else {
clnt->osql.xerr.errval = ERR_BLOCK_FAILED + ERR_VERIFY;
errstat_cat_str(&(clnt->osql.xerr),
"unable to update record rc = 4");
"unable to update record");
}
rc = SQLITE_ABORT;
} else if (clnt->early_retry == EARLY_ERR_SELECTV) {
Expand Down
2 changes: 1 addition & 1 deletion tests/ddl_no_csc2.test/t09_check.expected
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ constraints
[CREATE TABLE t1(i INT, CHECK (i > (SELECT MAX(i))))] failed with rc 240 malformed database schema (t1) - subqueries prohibited in CHECK constraints
(test='4. Test for updates')
(rows inserted=1)
[UPDATE t1 SET i = 10 WHERE i = 1] failed with rc 403 CHECK constraint violation CHECK constraint failed for '$CONSTRAINT_3DCCE6D2' unable to update record rc = 320
[UPDATE t1 SET i = 10 WHERE i = 1] failed with rc 403 CHECK constraint violation CHECK constraint failed for '$CONSTRAINT_3DCCE6D2' unable to update record
(i=1)
(test='5. Test for some obscure expressions')
[INSERT INTO t1 VALUES(1)] failed with rc 403 CHECK constraint violation CHECK constraint failed for '$CONSTRAINT_50FF6780' unable to add record rc = 320
Expand Down
2 changes: 1 addition & 1 deletion tests/dupewrite.test/t02.req.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[EXEC PROCEDURE test_dupe_insert_3()] failed with rc -3 [n = q:fetch()...]:7: statement must be read-only
[EXEC PROCEDURE test_dupe_update_2()] failed with rc -3 [db:exec(sql):emit()...]:3: statement must be read-only
[EXEC PROCEDURE test_dupe_update_3()] failed with rc -3 [n = q:fetch()...]:7: statement must be read-only
[EXEC PROCEDURE test_dupe_update_4()] failed with rc -8 find old record failed unable to update record rc = 4
[EXEC PROCEDURE test_dupe_update_4()] failed with rc -8 find old record failed unable to update record
[EXEC PROCEDURE test_dupe_delete_2()] failed with rc -3 [db:exec(sql):emit()...]:3: statement must be read-only
[EXEC PROCEDURE test_dupe_delete_3()] failed with rc -3 [n = q:fetch()...]:7: statement must be read-only
[EXEC PROCEDURE test_dupe_delete_4()] failed with rc -8 Table 'dupe4' find old record failed unable to delete genid =XXXXXX rc=4
2 changes: 1 addition & 1 deletion tests/sc_addfield.test/runit
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ do_verify t1

function do_alter_and_update (){
#updates fail (deadlock?):
#[update t1 set c=c+10000 where 1] failed with rc 304 unable to update record rc = 199
#[update t1 set c=c+10000 where 1] failed with rc 304 unable to update record
cdb2sql ${CDB2_OPTIONS} $dbnm default "alter table t1 { `cat t1_1.csc2 ` }"
assertcnt t1 3000
do_verify t1
Expand Down
2 changes: 1 addition & 1 deletion tests/serialstep.test/s14_01.req.exp.alt2
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ done
done
(rows updated=1)
done
[commit] failed with rc 2 find old record failed unable to update record rc = 4
[commit] failed with rc 2 find old record failed unable to update record
done
2 changes: 1 addition & 1 deletion tests/serialstep.test/s2_01.req.exp.alt2
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ done
(id=99, name='ytu', age=8, address=NULL, state='DB', zip=NULL)
done
done
[commit] failed with rc 2 find old record failed unable to update record rc = 4
[commit] failed with rc 2 find old record failed unable to update record
done
done
done
2 changes: 1 addition & 1 deletion tests/tools/linearizable/jepsen/src/comdb2/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
"Given an error string, identifies whether the error is safely retriable."
[e]
(or (re-find #"not serializable" e)
(re-find #"unable to update record rc = 4" e)
(re-find #"unable to update record" e)
(re-find #"selectv constraints" e)
(re-find #"Maximum number of retries done." e)))

Expand Down
2 changes: 1 addition & 1 deletion tests/upsert.test/t00_upsert.expected
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
[INSERT INTO t1 VALUES(11)] failed with rc 299 add key constraint duplicate key '$KEY_877B2989' on table 't1' index 0
(rows inserted=1)
(i=11)
[INSERT INTO t1 VALUES(11) ON CONFLICT(i) DO UPDATE SET i = 1] failed with rc 403 CHECK constraint violation CHECK constraint failed for '$CONSTRAINT_A91B9811' unable to update record rc = 320
[INSERT INTO t1 VALUES(11) ON CONFLICT(i) DO UPDATE SET i = 1] failed with rc 403 CHECK constraint violation CHECK constraint failed for '$CONSTRAINT_A91B9811' unable to update record
(i=11)
(rows inserted=0)
(i=12)
Expand Down
4 changes: 2 additions & 2 deletions tests/verify_error.test/t2_01.req.exp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ done
1 [truncate test2]
done
1 [commit]
[commit] failed with rc 2 find old record failed unable to update record rc = 4
[commit] failed with rc 2 find old record failed unable to update record
done
1 [select * from test1]
(i=1, j=4)
Expand All @@ -51,7 +51,7 @@ done
(rows updated=1)
done
1 [commit]
[commit] failed with rc 2 find old record failed unable to update record rc = 4
[commit] failed with rc 2 find old record failed unable to update record
done
1 [select * from test1]
(i=1, j=4)
Expand Down
8 changes: 4 additions & 4 deletions tests/yast.test/check.test
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ do_test check-1.12 {
catchsql {
UPDATE t1 SET x=7 WHERE x==2
}
} {1 {CHECK constraint violation CHECK constraint failed for '$CONSTRAINT_3BE1A9E5' unable to update record rc = 320}}
} {1 {CHECK constraint violation CHECK constraint failed for '$CONSTRAINT_3BE1A9E5' unable to update record}}
do_test check-1.13 {
execsql {
SELECT * FROM t1;
Expand All @@ -95,7 +95,7 @@ do_test check-1.14 {
catchsql {
UPDATE t1 SET x=5 WHERE x==2
}
} {1 {CHECK constraint violation CHECK constraint failed for '$CONSTRAINT_3BE1A9E5' unable to update record rc = 320}}
} {1 {CHECK constraint violation CHECK constraint failed for '$CONSTRAINT_3BE1A9E5' unable to update record}}
do_test check-1.15 {
execsql {
SELECT * FROM t1;
Expand Down Expand Up @@ -271,7 +271,7 @@ do_test check-4.6 {
catchsql {
UPDATE t4 SET x=0, y=1;
}
} {1 {CHECK constraint violation CHECK constraint failed for '$CONSTRAINT_4026B7C3' unable to update record rc = 320}}
} {1 {CHECK constraint violation CHECK constraint failed for '$CONSTRAINT_4026B7C3' unable to update record}}
do_test check-4.7 {
execsql {
SELECT * FROM t4;
Expand All @@ -294,7 +294,7 @@ do_test check-4.9 {
catchsql {
UPDATE t4 SET x=0, y=2;
}
} {1 {CHECK constraint violation CHECK constraint failed for '$CONSTRAINT_4026B7C3' unable to update record rc = 320}}
} {1 {CHECK constraint violation CHECK constraint failed for '$CONSTRAINT_4026B7C3' unable to update record}}
ifcapable vacuum {
do_test check_4.10 {
catchsql {
Expand Down