|
From: <ale...@us...> - 2015-08-18 15:04:07
|
Revision: 62111
http://sourceforge.net/p/firebird/code/62111
Author: alexpeshkoff
Date: 2015-08-18 15:04:04 +0000 (Tue, 18 Aug 2015)
Log Message:
-----------
Fixed CORE-4899: GFIX -online: message "IProvider::attachDatabase failed when loading mapping cache" appears in Classic (only) if access uses remote protocol
Modified Paths:
--------------
firebird/trunk/lang_helpers/gds_codes.ftn
firebird/trunk/lang_helpers/gds_codes.pas
firebird/trunk/src/include/gen/codetext.h
firebird/trunk/src/include/gen/iberror.h
firebird/trunk/src/include/gen/msgs.h
firebird/trunk/src/include/gen/sql_code.h
firebird/trunk/src/include/gen/sql_state.h
firebird/trunk/src/jrd/Mapping.cpp
firebird/trunk/src/jrd/Mapping.h
firebird/trunk/src/jrd/jrd.cpp
firebird/trunk/src/jrd/scl.h
firebird/trunk/src/jrd/shut.cpp
firebird/trunk/src/msgs/facilities2.sql
firebird/trunk/src/msgs/messages2.sql
firebird/trunk/src/msgs/system_errors2.sql
Modified: firebird/trunk/lang_helpers/gds_codes.ftn
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.ftn 2015-08-18 14:57:50 UTC (rev 62110)
+++ firebird/trunk/lang_helpers/gds_codes.ftn 2015-08-18 15:04:04 UTC (rev 62111)
@@ -1620,6 +1620,8 @@
PARAMETER (GDS__domain_primary_key_notnull = 335545103)
INTEGER*4 GDS__invalid_attachment_charset
PARAMETER (GDS__invalid_attachment_charset = 335545104)
+ INTEGER*4 GDS__map_down
+ PARAMETER (GDS__map_down = 335545105)
INTEGER*4 GDS__gfix_db_name
PARAMETER (GDS__gfix_db_name = 335740929)
INTEGER*4 GDS__gfix_invalid_sw
Modified: firebird/trunk/lang_helpers/gds_codes.pas
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.pas 2015-08-18 14:57:50 UTC (rev 62110)
+++ firebird/trunk/lang_helpers/gds_codes.pas 2015-08-18 15:04:04 UTC (rev 62111)
@@ -817,6 +817,7 @@
gds_savepoint_backout_err = 335545102;
gds_domain_primary_key_notnull = 335545103;
gds_invalid_attachment_charset = 335545104;
+ gds_map_down = 335545105;
gds_gfix_db_name = 335740929;
gds_gfix_invalid_sw = 335740930;
gds_gfix_incmp_sw = 335740932;
Modified: firebird/trunk/src/include/gen/codetext.h
===================================================================
--- firebird/trunk/src/include/gen/codetext.h 2015-08-18 14:57:50 UTC (rev 62110)
+++ firebird/trunk/src/include/gen/codetext.h 2015-08-18 15:04:04 UTC (rev 62111)
@@ -806,6 +806,7 @@
{"savepoint_backout_err", 335545102},
{"domain_primary_key_notnull", 335545103},
{"invalid_attachment_charset", 335545104},
+ {"map_down", 335545105},
{"gfix_db_name", 335740929},
{"gfix_invalid_sw", 335740930},
{"gfix_incmp_sw", 335740932},
Modified: firebird/trunk/src/include/gen/iberror.h
===================================================================
--- firebird/trunk/src/include/gen/iberror.h 2015-08-18 14:57:50 UTC (rev 62110)
+++ firebird/trunk/src/include/gen/iberror.h 2015-08-18 15:04:04 UTC (rev 62111)
@@ -840,6 +840,7 @@
const ISC_STATUS isc_savepoint_backout_err = 335545102L;
const ISC_STATUS isc_domain_primary_key_notnull = 335545103L;
const ISC_STATUS isc_invalid_attachment_charset = 335545104L;
+const ISC_STATUS isc_map_down = 335545105L;
const ISC_STATUS isc_gfix_db_name = 335740929L;
const ISC_STATUS isc_gfix_invalid_sw = 335740930L;
const ISC_STATUS isc_gfix_incmp_sw = 335740932L;
@@ -1302,7 +1303,7 @@
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 = 1246;
+const ISC_STATUS isc_err_max = 1247;
#else /* c definitions */
@@ -2112,6 +2113,7 @@
#define isc_savepoint_backout_err 335545102L
#define isc_domain_primary_key_notnull 335545103L
#define isc_invalid_attachment_charset 335545104L
+#define isc_map_down 335545105L
#define isc_gfix_db_name 335740929L
#define isc_gfix_invalid_sw 335740930L
#define isc_gfix_incmp_sw 335740932L
@@ -2574,7 +2576,7 @@
#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 1246
+#define isc_err_max 1247
#endif
Modified: firebird/trunk/src/include/gen/msgs.h
===================================================================
--- firebird/trunk/src/include/gen/msgs.h 2015-08-18 14:57:50 UTC (rev 62110)
+++ firebird/trunk/src/include/gen/msgs.h 2015-08-18 15:04:04 UTC (rev 62111)
@@ -809,6 +809,7 @@
{335545102, "Error during savepoint backout - transaction invalidated"}, /* savepoint_backout_err */
{335545103, "Domain used in the PRIMARY KEY constraint of table @1 must be NOT NULL"}, /* domain_primary_key_notnull */
{335545104, "CHARACTER SET @1 cannot be used as a attachment character set"}, /* invalid_attachment_charset */
+ {335545105, "Some database(s) were shutdown when trying to read mapping data"}, /* map_down */
{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 */
Modified: firebird/trunk/src/include/gen/sql_code.h
===================================================================
--- firebird/trunk/src/include/gen/sql_code.h 2015-08-18 14:57:50 UTC (rev 62110)
+++ firebird/trunk/src/include/gen/sql_code.h 2015-08-18 15:04:04 UTC (rev 62111)
@@ -805,6 +805,7 @@
{335545102, -901}, /* 782 savepoint_backout_err */
{335545103, -291}, /* 783 domain_primary_key_notnull */
{335545104, -204}, /* 784 invalid_attachment_charset */
+ {335545105, -901}, /* 785 map_down */
{335740929, -901}, /* 1 gfix_db_name */
{335740930, -901}, /* 2 gfix_invalid_sw */
{335740932, -901}, /* 4 gfix_incmp_sw */
Modified: firebird/trunk/src/include/gen/sql_state.h
===================================================================
--- firebird/trunk/src/include/gen/sql_state.h 2015-08-18 14:57:50 UTC (rev 62110)
+++ firebird/trunk/src/include/gen/sql_state.h 2015-08-18 15:04:04 UTC (rev 62111)
@@ -805,6 +805,7 @@
{335545102, "HY000"}, // 782 savepoint_backout_err
{335545103, "42000"}, // 783 domain_primary_key_notnull
{335545104, "2C000"}, // 784 invalid_attachment_charset
+ {335545105, "08004"}, // 785 map_down
{335740929, "00000"}, // 1 gfix_db_name
{335740930, "00000"}, // 2 gfix_invalid_sw
{335740932, "00000"}, // 4 gfix_incmp_sw
Modified: firebird/trunk/src/jrd/Mapping.cpp
===================================================================
--- firebird/trunk/src/jrd/Mapping.cpp 2015-08-18 14:57:50 UTC (rev 62110)
+++ firebird/trunk/src/jrd/Mapping.cpp 2015-08-18 15:04:04 UTC (rev 62111)
@@ -234,12 +234,13 @@
{
public:
Cache(const NoCaseString& aliasDb, const NoCaseString& db)
- : alias(getPool(), aliasDb), name(getPool(), db), dataFlag(false)
+ : alias(getPool(), aliasDb), name(getPool(), db),
+ dataFlag(false), downFlag(false)
{
enableDuplicates();
}
- void populate(IAttachment *att)
+ void populate(IAttachment *att, bool isDown)
{
FbLocalStatus st;
@@ -251,6 +252,7 @@
if (!att)
{
dataFlag = true;
+ downFlag = isDown;
return;
}
@@ -325,6 +327,7 @@
tra = NULL;
dataFlag = true;
+ downFlag = false;
}
catch (const Exception&)
{
@@ -471,7 +474,7 @@
public:
SyncObject syncObject;
NoCaseString alias, name;
- bool dataFlag;
+ bool dataFlag, downFlag;
};
typedef GenericMap<Pair<Left<NoCaseString, Cache*> > > CacheTree;
@@ -855,7 +858,7 @@
namespace Jrd {
-void mapUser(string& name, string& trusted_role, Firebird::string* auth_method,
+bool mapUser(string& name, string& trusted_role, Firebird::string* auth_method,
AuthReader::AuthBlock* newAuthBlock, const AuthReader::AuthBlock& authBlock,
const char* alias, const char* db, const char* securityAlias,
ICryptKeyCallback* cryptCb)
@@ -877,13 +880,15 @@
}
}
- return;
+ return false;
}
// expand security database name (db is expected to be expanded, alias - original)
PathName secExpanded;
expandDatabaseName(securityAlias, secExpanded, NULL);
const char* securityDb = secExpanded.c_str();
+ bool secDown = false;
+ bool dbDown = false;
// Create new writer
AuthWriter newBlock;
@@ -935,10 +940,13 @@
embeddedSysdba.getBufferLength(), embeddedSysdba.getBuffer());
if (st->getState() & IStatus::STATE_ERRORS)
{
- if (!fb_utils::containsErrorCode(st->getErrors(), isc_io_error))
+ const ISC_STATUS* s = st->getErrors();
+ bool missing = fb_utils::containsErrorCode(s, isc_io_error);
+ secDown = fb_utils::containsErrorCode(s, isc_shutdown);
+ if (!(missing || secDown))
check("IProvider::attachDatabase", &st);
- // missing security DB is not a reason to fail mapping
+ // down/missing security DB is not a reason to fail mapping
iSec = NULL;
}
}
@@ -952,15 +960,18 @@
{
iDb = prov->attachDatabase(&st, alias,
embeddedSysdba.getBufferLength(), embeddedSysdba.getBuffer());
- }
- if (st->getState() & IStatus::STATE_ERRORS)
- {
- if (!fb_utils::containsErrorCode(st->getErrors(), isc_io_error))
- check("IProvider::attachDatabase", &st);
+ if (st->getState() & IStatus::STATE_ERRORS)
+ {
+ const ISC_STATUS* s = st->getErrors();
+ bool missing = fb_utils::containsErrorCode(s, isc_io_error);
+ dbDown = fb_utils::containsErrorCode(s, isc_shutdown);
+ if (!(missing || dbDown))
+ check("IProvider::attachDatabase", &st);
- // missing DB is not a reason to fail mapping
- iDb = NULL;
+ // down/missing DB is not a reason to fail mapping
+ iDb = NULL;
+ }
}
}
}
@@ -1006,13 +1017,18 @@
}
if (cDb)
- cDb->populate(iDb);
- cSec->populate(iSec);
+ cDb->populate(iDb, dbDown);
+ cSec->populate(iSec, secDown);
sSec.downgrade(SYNC_SHARED);
sDb.downgrade(SYNC_SHARED);
}
+ // use down flags from caches
+ if (cDb)
+ dbDown = cDb->downFlag;
+ secDown = cSec->downFlag;
+
// Caches are ready somehow - proceed with analysis
AuthReader auth(authBlock);
@@ -1102,7 +1118,13 @@
}
if (fName.found == Found::FND_NOTHING)
- (Arg::Gds(isc_sec_context) << alias).raise();
+ {
+ Arg::Gds v(isc_sec_context);
+ v << alias;
+ if (secDown || dbDown)
+ v << Arg::Gds(isc_map_down);
+ v.raise();
+ }
name = fName.value.ToString();
trusted_role = fRole.value.ToString();
@@ -1117,6 +1139,8 @@
MAP_DEBUG(fprintf(stderr, "Saved to newAuthBlock %u bytes\n",
static_cast<unsigned>(newAuthBlock->getCount())));
}
+
+ return secDown || dbDown;
}
void clearMap(const char* dbName)
Modified: firebird/trunk/src/jrd/Mapping.h
===================================================================
--- firebird/trunk/src/jrd/Mapping.h 2015-08-18 14:57:50 UTC (rev 62110)
+++ firebird/trunk/src/jrd/Mapping.h 2015-08-18 15:04:04 UTC (rev 62111)
@@ -37,7 +37,7 @@
namespace Jrd {
-void mapUser(Firebird::string& name, Firebird::string& trusted_role, Firebird::string* auth_method,
+bool mapUser(Firebird::string& name, Firebird::string& trusted_role, Firebird::string* auth_method,
Firebird::AuthReader::AuthBlock* newAuthBlock, const Firebird::AuthReader::AuthBlock& authBlock,
const char* alias, const char* db, const char* securityDb, Firebird::ICryptKeyCallback* cryptCb);
void clearMap(const char* dbName);
Modified: firebird/trunk/src/jrd/jrd.cpp
===================================================================
--- firebird/trunk/src/jrd/jrd.cpp 2015-08-18 14:57:50 UTC (rev 62110)
+++ firebird/trunk/src/jrd/jrd.cpp 2015-08-18 15:04:04 UTC (rev 62111)
@@ -731,7 +731,11 @@
{
if (!attachment->locksmith())
{
- ERR_post(Arg::Gds(isc_adm_task_denied));
+ UserId* u = attachment->att_user;
+ if (u->usr_flags & USR_mapdown)
+ ERR_post(Arg::Gds(isc_adm_task_denied) << Arg::Gds(isc_map_down));
+ else
+ ERR_post(Arg::Gds(isc_adm_task_denied));
}
}
@@ -1703,7 +1707,11 @@
if (!allow_access)
{
// Note we throw exception here when entering full-shutdown mode
- ERR_post(Arg::Gds(isc_shutdown) << Arg::Str(org_filename));
+ Arg::Gds v(isc_shutdown);
+ v << Arg::Str(org_filename);
+ if (attachment->att_user->usr_flags & USR_mapdown)
+ v << Arg::Gds(isc_map_down);
+ ERR_post(v);
}
}
@@ -7127,8 +7135,11 @@
}
else if (options.dpb_auth_block.hasData())
{
- mapUser(name, trusted_role, &auth_method, &user.usr_auth_block, options.dpb_auth_block,
- aliasName, dbName, (config ? (*config)->getSecurityDatabase() : NULL), cryptCb);
+ if (mapUser(name, trusted_role, &auth_method, &user.usr_auth_block, options.dpb_auth_block,
+ aliasName, dbName, (config ? (*config)->getSecurityDatabase() : NULL), cryptCb))
+ {
+ user.usr_flags |= USR_mapdown;
+ }
if (creating && config) // when config is NULL we are in error handler
{
Modified: firebird/trunk/src/jrd/scl.h
===================================================================
--- firebird/trunk/src/jrd/scl.h 2015-08-18 14:57:50 UTC (rev 62110)
+++ firebird/trunk/src/jrd/scl.h 2015-08-18 15:04:04 UTC (rev 62111)
@@ -85,6 +85,7 @@
const USHORT USR_locksmith = 1; // User has great karma
const USHORT USR_dba = 2; // User has DBA privileges
const USHORT USR_owner = 4; // User owns database
+const USHORT USR_mapdown = 8; // Mapping failed when getting context
class UserId
{
Modified: firebird/trunk/src/jrd/shut.cpp
===================================================================
--- firebird/trunk/src/jrd/shut.cpp 2015-08-18 14:57:50 UTC (rev 62110)
+++ firebird/trunk/src/jrd/shut.cpp 2015-08-18 15:04:04 UTC (rev 62111)
@@ -161,7 +161,10 @@
if (!attachment->locksmith())
{
- ERR_post(Arg::Gds(isc_no_priv) << "shutdown" << "database" << dbb->dbb_filename);
+ ERR_post_nothrow(Arg::Gds(isc_no_priv) << "shutdown" << "database" << dbb->dbb_filename);
+ if (attachment->att_user->usr_flags & USR_mapdown)
+ ERR_post_nothrow(Arg::Gds(isc_map_down));
+ ERR_punt();
}
const int shut_mode = flag & isc_dpb_shut_mode_mask;
@@ -340,7 +343,10 @@
if (!attachment->att_user->locksmith())
{
- ERR_post(Arg::Gds(isc_no_priv) << "bring online" << "database" << dbb->dbb_filename);
+ ERR_post_nothrow(Arg::Gds(isc_no_priv) << "bring online" << "database" << dbb->dbb_filename);
+ if (attachment->att_user->usr_flags & USR_mapdown)
+ ERR_post_nothrow(Arg::Gds(isc_map_down));
+ ERR_punt();
}
const int shut_mode = flag & isc_dpb_shut_mode_mask;
Modified: firebird/trunk/src/msgs/facilities2.sql
===================================================================
--- firebird/trunk/src/msgs/facilities2.sql 2015-08-18 14:57:50 UTC (rev 62110)
+++ firebird/trunk/src/msgs/facilities2.sql 2015-08-18 15:04:04 UTC (rev 62111)
@@ -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 (?, ?, ?, ?);
--
-('2015-07-12 18:05:00', 'JRD', 0, 785)
+('2015-08-17 20:53:01', 'JRD', 0, 786)
('2015-03-17 18:33:00', 'QLI', 1, 533)
('2015-01-07 18:01:51', 'GFIX', 3, 134)
('1996-11-07 13:39:40', 'GPRE', 4, 1)
Modified: firebird/trunk/src/msgs/messages2.sql
===================================================================
--- firebird/trunk/src/msgs/messages2.sql 2015-08-18 14:57:50 UTC (rev 62110)
+++ firebird/trunk/src/msgs/messages2.sql 2015-08-18 15:04:04 UTC (rev 62111)
@@ -892,6 +892,7 @@
('savepoint_backout_err', 'VIO_verb_cleanup', 'vio.cpp', NULL, 0, 782, NULL, 'Error during savepoint backout - transaction invalidated', NULL, NULL);
('domain_primary_key_notnull', NULL, 'DdlNodes.epp', NULL, 0, 783, NULL, 'Domain used in the PRIMARY KEY constraint of table @1 must be NOT NULL', NULL, NULL);
('invalid_attachment_charset', NULL, NULL, NULL, 0, 784, NULL, 'CHARACTER SET @1 cannot be used as a attachment character set', NULL, NULL);
+('map_down', NULL, 'Mapping.cpp', NULL, 0, 785, NULL, 'Some database(s) were shutdown when trying to read mapping data', 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);
Modified: firebird/trunk/src/msgs/system_errors2.sql
===================================================================
--- firebird/trunk/src/msgs/system_errors2.sql 2015-08-18 14:57:50 UTC (rev 62110)
+++ firebird/trunk/src/msgs/system_errors2.sql 2015-08-18 15:04:04 UTC (rev 62111)
@@ -791,6 +791,7 @@
(-901, 'HY', '000', 0, 782, 'savepoint_backout_err', NULL, NULL)
(-291, '42', '000', 0, 783, 'domain_primary_key_notnull', NULL, NULL)
(-204, '2C', '000', 0, 784, 'invalid_attachment_charset', NULL, NULL)
+(-901, '08', '004', 0, 785, 'map_down', NULL, NULL)
-- GFIX
(-901, '00', '000', 3, 1, 'gfix_db_name', NULL, NULL)
(-901, '00', '000', 3, 2, 'gfix_invalid_sw', NULL, NULL)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|