diff --git a/src/jrd/HazardPtr.h b/src/jrd/HazardPtr.h index 040980135c..b7f57baa97 100644 --- a/src/jrd/HazardPtr.h +++ b/src/jrd/HazardPtr.h @@ -559,6 +559,11 @@ public: } } + bool isReady() + { + return (flg == READY) || ((thd == Thread::getId()) && (flg == SCANNING)); + } + private: std::condition_variable cond; std::mutex mtx; @@ -628,6 +633,9 @@ public: listEntry->scanObject( [&](bool rld) { return scanCallback(tdbb, obj, rld, fl); }, fl); + + if ((!(fl & CacheFlag::NOSCAN)) && (!(listEntry->bar.isReady()))) + return nullptr; } return obj; } diff --git a/src/jrd/btr.cpp b/src/jrd/btr.cpp index 60d8b7ee17..3d7aa56649 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -415,6 +415,9 @@ void BTR_all(thread_db* tdbb, Cached::Relation* relation, IndexDescList& idxList for (MetaId i = 0; i < root->irt_count; i++) { + if (!relation->lookup_index(tdbb, i, CacheFlag::AUTOCREATE)) + continue; + index_desc idx; if (BTR_description(tdbb, relation, root, &idx, i)) idxList.add(idx); diff --git a/src/jrd/met.epp b/src/jrd/met.epp index 689a67cbb8..efdd67bb5c 100644 --- a/src/jrd/met.epp +++ b/src/jrd/met.epp @@ -3553,7 +3553,7 @@ bool jrd_rel::scan(thread_db* tdbb, ObjectBase::Flag flags) rel_current_format = NULL; dependencies = sys_triggers = false; - return true; + return getName().hasData(); } @@ -5286,9 +5286,8 @@ bool IndexVersion::scan(thread_db* tdbb, ObjectBase::Flag flags) if (idv_name.isEmpty()) { - fb_assert(false); - fatal_exception::raiseFmt("Index with id=%d for relation %s not found\n", - getId(), getPermanent()->getRelation()->c_name()); + idv_inactive = true; + return false; } perm->idp_name = idv_name;