From 8143f9aa6b77835a6c924562d029756ec3958638 Mon Sep 17 00:00:00 2001 From: dimitr Date: Fri, 15 Nov 2013 15:40:31 +0000 Subject: [PATCH] Fixed CORE-4267: Server crashes while sweeping the database. --- src/jrd/irq.h | 1 + src/jrd/met.epp | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/jrd/irq.h b/src/jrd/irq.h index e6901f9bfe..7b3b8b61de 100644 --- a/src/jrd/irq.h +++ b/src/jrd/irq.h @@ -164,6 +164,7 @@ enum irq_type_t irq_grant14, // process grant option (exceptions) irq_grant15, // process grant option (generators) irq_grant16, // process grant option (domains) + irq_l_curr_format, // lookup table's current format irq_linger, // get database linger value diff --git a/src/jrd/met.epp b/src/jrd/met.epp index e2e1412ac5..13ec1781bf 100644 --- a/src/jrd/met.epp +++ b/src/jrd/met.epp @@ -1006,8 +1006,30 @@ Format* MET_current(thread_db* tdbb, jrd_rel* relation) return relation->rel_current_format; SET_TDBB(tdbb); + Jrd::Attachment* attachment = tdbb->getAttachment(); - return relation->rel_current_format = MET_format(tdbb, relation, relation->rel_current_fmt); + if (!(relation->rel_flags & REL_scanned)) + { + AutoCacheRequest request(tdbb, irq_l_curr_format, IRQ_REQUESTS); + + FOR(REQUEST_HANDLE request) + REL IN RDB$RELATIONS WITH REL.RDB$RELATION_ID EQ relation->rel_id + { + relation->rel_current_fmt = REL.RDB$FORMAT; + } + END_FOR + } + + // Usually, format numbers start with one and they are present in RDB$FORMATS. + // However, system tables have zero as their initial format and they don't have + // any related records in RDB$FORMATS, instead their rel_formats[0] is initialized + // directly (see ini.epp). Every other case of zero format number found for an already + // scanned table must be catched here and investigated. + fb_assert(relation->rel_current_fmt || relation->isSystem()); + + relation->rel_current_format = MET_format(tdbb, relation, relation->rel_current_fmt); + + return relation->rel_current_format; }