From a79ff180dada030ad43e425e8d0fc42f5a2b6c99 Mon Sep 17 00:00:00 2001 From: dimitr Date: Wed, 27 Aug 2014 12:56:36 +0000 Subject: [PATCH] Added specific error code for read conflicts in RC NO_REC_VER mode. Added missing conflict counting. --- src/include/gen/codetext.h | 1 + src/include/gen/iberror.h | 6 ++++-- src/include/gen/msgs.h | 1 + src/include/gen/sql_code.h | 1 + src/include/gen/sql_state.h | 1 + src/jrd/vio.cpp | 13 ++++++++----- src/msgs/facilities2.sql | 2 +- src/msgs/messages2.sql | 1 + src/msgs/system_errors2.sql | 1 + 9 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/include/gen/codetext.h b/src/include/gen/codetext.h index 9c2c992c4a..7d44779704 100644 --- a/src/include/gen/codetext.h +++ b/src/include/gen/codetext.h @@ -797,6 +797,7 @@ static const struct { {"dup_attribute", 335545093}, {"dyn_no_priv", 335545094}, {"dsql_cant_grant_option", 335545095}, + {"read_conflict", 335545096}, {"gfix_db_name", 335740929}, {"gfix_invalid_sw", 335740930}, {"gfix_incmp_sw", 335740932}, diff --git a/src/include/gen/iberror.h b/src/include/gen/iberror.h index c40d543271..dc47774791 100644 --- a/src/include/gen/iberror.h +++ b/src/include/gen/iberror.h @@ -831,6 +831,7 @@ const ISC_STATUS isc_cursor_not_positioned = 335545092L; const ISC_STATUS isc_dup_attribute = 335545093L; const ISC_STATUS isc_dyn_no_priv = 335545094L; const ISC_STATUS isc_dsql_cant_grant_option = 335545095L; +const ISC_STATUS isc_read_conflict = 335545096L; const ISC_STATUS isc_gfix_db_name = 335740929L; const ISC_STATUS isc_gfix_invalid_sw = 335740930L; const ISC_STATUS isc_gfix_incmp_sw = 335740932L; @@ -1289,7 +1290,7 @@ const ISC_STATUS isc_trace_switch_user_only = 337182757L; const ISC_STATUS isc_trace_switch_param_miss = 337182758L; const ISC_STATUS isc_trace_param_act_notcompat = 337182759L; const ISC_STATUS isc_trace_mandatory_switch_miss = 337182760L; -const ISC_STATUS isc_err_max = 1233; +const ISC_STATUS isc_err_max = 1234; #else /* c definitions */ @@ -2090,6 +2091,7 @@ const ISC_STATUS isc_err_max = 1233; #define isc_dup_attribute 335545093L #define isc_dyn_no_priv 335545094L #define isc_dsql_cant_grant_option 335545095L +#define isc_read_conflict 335545096L #define isc_gfix_db_name 335740929L #define isc_gfix_invalid_sw 335740930L #define isc_gfix_incmp_sw 335740932L @@ -2548,7 +2550,7 @@ const ISC_STATUS isc_err_max = 1233; #define isc_trace_switch_param_miss 337182758L #define isc_trace_param_act_notcompat 337182759L #define isc_trace_mandatory_switch_miss 337182760L -#define isc_err_max 1233 +#define isc_err_max 1234 #endif diff --git a/src/include/gen/msgs.h b/src/include/gen/msgs.h index bac1e921b3..b8cbfeb51b 100644 --- a/src/include/gen/msgs.h +++ b/src/include/gen/msgs.h @@ -800,6 +800,7 @@ Data source : @4"}, /* eds_statement */ {335545093, "Duplicated user attribute @1"}, /* dup_attribute */ {335545094, "There is no privilege for this operation"}, /* dyn_no_priv */ {335545095, "Using GRANT OPTION on @1 not allowed"}, /* dsql_cant_grant_option */ + {335545096, "read conflicts with concurrent update"}, /* read_conflict */ {335740929, "data base file name (@1) already given"}, /* gfix_db_name */ {335740930, "invalid switch @1"}, /* gfix_invalid_sw */ {335740932, "incompatible switch combination"}, /* gfix_incmp_sw */ diff --git a/src/include/gen/sql_code.h b/src/include/gen/sql_code.h index ba3259e1f0..7a1008670d 100644 --- a/src/include/gen/sql_code.h +++ b/src/include/gen/sql_code.h @@ -796,6 +796,7 @@ static const struct { {335545093, -901}, /* 773 dup_attribute */ {335545094, -901}, /* 774 dyn_no_priv */ {335545095, -901}, /* 775 dsql_cant_grant_option */ + {335545096, -904}, /* 776 read_conflict */ {335740929, -901}, /* 1 gfix_db_name */ {335740930, -901}, /* 2 gfix_invalid_sw */ {335740932, -901}, /* 4 gfix_incmp_sw */ diff --git a/src/include/gen/sql_state.h b/src/include/gen/sql_state.h index 610bfecf7b..51523e2ee5 100644 --- a/src/include/gen/sql_state.h +++ b/src/include/gen/sql_state.h @@ -796,6 +796,7 @@ static const struct { {335545093, "42702"}, // 773 dup_attribute {335545094, "42000"}, // 774 dyn_no_priv {335545095, "42000"}, // 775 dsql_cant_grant_option + {335545096, "40001"}, // 776 read_conflict {335740929, "00000"}, // 1 gfix_db_name {335740930, "00000"}, // 2 gfix_invalid_sw {335740932, "00000"}, // 4 gfix_incmp_sw diff --git a/src/jrd/vio.cpp b/src/jrd/vio.cpp index 3cfefb9c9c..407df956c9 100644 --- a/src/jrd/vio.cpp +++ b/src/jrd/vio.cpp @@ -746,8 +746,7 @@ bool VIO_chase_record_version(thread_db* tdbb, record_param* rpb, if (!(transaction->tra_flags & TRA_ignore_limbo)) { CCH_RELEASE(tdbb, &rpb->getWindow(tdbb)); - ERR_post(Arg::Gds(isc_deadlock) << - Arg::Gds(isc_trainlim)); + ERR_post(Arg::Gds(isc_deadlock) << Arg::Gds(isc_trainlim)); } state = tra_limbo; @@ -768,8 +767,11 @@ bool VIO_chase_record_version(thread_db* tdbb, record_param* rpb, if (state == tra_active) { + tdbb->bumpRelStats(RuntimeStatistics::RECORD_CONFLICTS, relation->rel_id); + ERR_post(Arg::Gds(isc_deadlock) << - Arg::Gds(isc_concurrent_transaction) << Arg::Num(rpb->rpb_transaction_nr)); + Arg::Gds(isc_read_conflict) << + Arg::Gds(isc_concurrent_transaction) << Arg::Num(rpb->rpb_transaction_nr)); } // refetch the record and try again. The active transaction @@ -5405,6 +5407,8 @@ static int prepare_update( thread_db* tdbb, // We need to loop waiting in read committed transactions only if (!(transaction->tra_flags & TRA_read_committed)) { + tdbb->bumpRelStats(RuntimeStatistics::RECORD_CONFLICTS, relation->rel_id); + ERR_post(Arg::Gds(isc_deadlock) << Arg::Gds(isc_update_conflict) << Arg::Gds(isc_concurrent_transaction) << Arg::Num(update_conflict_trans)); @@ -5413,8 +5417,7 @@ static int prepare_update( thread_db* tdbb, return PREPARE_LOCKERR; case tra_limbo: - ERR_post(Arg::Gds(isc_deadlock) << - Arg::Gds(isc_trainlim)); + ERR_post(Arg::Gds(isc_deadlock) << Arg::Gds(isc_trainlim)); case tra_dead: break; diff --git a/src/msgs/facilities2.sql b/src/msgs/facilities2.sql index 853aa560d8..c5d9ad04ac 100644 --- a/src/msgs/facilities2.sql +++ b/src/msgs/facilities2.sql @@ -1,7 +1,7 @@ /* MAX_NUMBER is the next number to be used, always one more than the highest message number. */ set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUMBER) VALUES (?, ?, ?, ?); -- -('2014-07-12 23:48:00', 'JRD', 0, 776) +('2014-08-27 16:38:00', 'JRD', 0, 777) ('2012-01-23 20:10:30', 'QLI', 1, 532) ('2013-11-13 15:59:10', 'GFIX', 3, 122) ('1996-11-07 13:39:40', 'GPRE', 4, 1) diff --git a/src/msgs/messages2.sql b/src/msgs/messages2.sql index 2cffcf0674..d919008b51 100644 --- a/src/msgs/messages2.sql +++ b/src/msgs/messages2.sql @@ -883,6 +883,7 @@ Data source : @4', NULL, NULL) ('dup_attribute', 'UserManagement::execute', 'UserManagement.cpp', NULL, 0, 773, NULL, 'Duplicated user attribute @1', NULL, NULL); ('dyn_no_priv', NULL, 'scl.epp', NULL, 0, 774, NULL, 'There is no privilege for this operation', NULL, NULL); ('dsql_cant_grant_option', NULL, 'DdlNodes.epp', NULL, 0, 775, NULL, 'Using GRANT OPTION on @1 not allowed', NULL, NULL); +('read_conflict', NULL, NULL, 'vio.cpp', 0, 776, NULL, 'read conflicts with concurrent update', NULL, NULL); -- QLI (NULL, NULL, NULL, NULL, 1, 0, NULL, 'expected type', NULL, NULL); (NULL, NULL, NULL, NULL, 1, 1, NULL, 'bad block type', NULL, NULL); diff --git a/src/msgs/system_errors2.sql b/src/msgs/system_errors2.sql index 3112b20d05..c7af288cc0 100644 --- a/src/msgs/system_errors2.sql +++ b/src/msgs/system_errors2.sql @@ -782,6 +782,7 @@ set bulk_insert INSERT INTO SYSTEM_ERRORS (SQL_CODE, SQL_CLASS, SQL_SUBCLASS, FA (-901, '42', '702', 0, 773, 'dup_attribute', NULL, NULL); (-901, '42', '000', 0, 774, 'dyn_no_priv', NULL, NULL) (-901, '42', '000', 0, 775, 'dsql_cant_grant_option', NULL, NULL); +(-904, '40', '001', 0, 776, 'read_conflict', NULL, NULL); -- GFIX (-901, '00', '000', 3, 1, 'gfix_db_name', NULL, NULL) (-901, '00', '000', 3, 2, 'gfix_invalid_sw', NULL, NULL)