42 return table_lock_mgr;
59 return insert_data_lock_mgr;
85 template <
typename LOCK_TYPE>
88 static_assert(std::is_same<LOCK_TYPE, ReadLock>::value ||
89 std::is_same<LOCK_TYPE, WriteLock>::value);
97 const std::string& table_name,
98 const bool populate_fragmenter) {
100 if (td_prelock != td_postlock) {
101 if (td_postlock ==
nullptr) {
102 throw std::runtime_error(
"Table/View ID " + table_name +
" for catalog " +
110 throw std::runtime_error(
"Table/View ID " + table_name +
" for catalog " +
112 " changed whilst attempting to acquire table lock");
122 const std::string& table_name,
123 const bool populate_fragmenter =
true) {
124 VLOG(1) <<
"Acquiring Table Schema Read Lock for table: " << table_name;
133 const int table_id) {
135 if (!table_name.has_value()) {
136 throw std::runtime_error(
"Table/View ID " +
std::to_string(table_id) +
138 " does not exist. Cannot aquire read lock");
140 return acquireTableDescriptor(cat, table_name.value());
153 const std::string& table_name,
154 const bool populate_fragmenter =
true) {
155 VLOG(1) <<
"Acquiring Table Schema Write Lock for table: " << table_name;
164 const int table_id) {
166 if (!table_name.has_value()) {
167 throw std::runtime_error(
"Table/View ID " +
std::to_string(table_id) +
169 " does not exist. Cannot aquire write lock");
171 return acquireTableDescriptor(cat, table_name.value());
179 template <
typename LOCK_TYPE>
182 static_assert(std::is_same<LOCK_TYPE, ReadLock>::value ||
183 std::is_same<LOCK_TYPE, WriteLock>::value);
196 VLOG(1) <<
"Acquiring Table Data Write Lock for table: " << td->
tableName;
213 VLOG(1) <<
"Acquiring Table Data Read Lock for table: " << td->
tableName;
223 template <
typename LOCK_TYPE>
226 static_assert(std::is_same<LOCK_TYPE, ReadLock>::value ||
227 std::is_same<LOCK_TYPE, WriteLock>::value);
240 VLOG(1) <<
"Acquiring Table Insert Write Lock for table: " << td->
tableName;
257 VLOG(1) <<
"Acquiring Table Insert Read Lock for table: " << td->
tableName;
268 std::vector<std::unique_ptr<lockmgr::AbstractLockContainer<const TableDescriptor*>>>;
std::vector< int > ChunkKey
std::vector< std::unique_ptr< lockmgr::AbstractLockContainer< const TableDescriptor * >>> LockedTableDescriptors
static ReadLock getReadLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
Locks protecting a physical table object returned from the catalog. Table Metadata Locks prevent inco...
static TableSchemaLockMgr & instance()
class for a per-database catalog. also includes metadata for the current database and the current use...
Locks protecting table data. Read queries take a read lock, while write queries (update, delete) obtain a write lock. Note that insert queries do not currently take a write lock (to allow concurrent inserts). Instead, insert queries obtain a write lock on the table metadata to allow existing read queries to finish (and block new ones) before flushing the inserted data to disk.
TableInsertLockContainer(const TableInsertLockContainer &)=delete
static WriteLock getWriteLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
static auto acquire(const int db_id, const TableDescriptor *td)
static auto acquireTableDescriptor(const Catalog_Namespace::Catalog &cat, const int table_id)
static TableDataLockMgr & instance()
void validate_table_descriptor_after_lock(const TableDescriptor *td_prelock, const Catalog_Namespace::Catalog &cat, const std::string &table_name, const bool populate_fragmenter)
static auto acquire(const int db_id, const TableDescriptor *td)
This file contains the class specification and related data structures for Catalog.
static auto acquireTableDescriptor(const Catalog_Namespace::Catalog &cat, const int table_id)
static auto acquireTableDescriptor(const Catalog_Namespace::Catalog &cat, const std::string &table_name, const bool populate_fragmenter=true)
const DBMetadata & getCurrentDB() const
static auto acquireTableDescriptor(const Catalog_Namespace::Catalog &cat, const std::string &table_name, const bool populate_fragmenter=true)
TableDataLockContainer(const TableDataLockContainer &)=delete
std::optional< std::string > getTableName(int32_t table_id) const
TableSchemaLockContainer(const TableSchemaLockContainer &)=delete
static auto acquire(const int db_id, const TableDescriptor *td)
static InsertDataLockMgr & instance()
static auto acquire(const int db_id, const TableDescriptor *td)
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
Prevents simultaneous inserts into the same table. To allow concurrent Insert/Select queries...