42 return table_lock_mgr;
47 static inline constexpr std::string_view
kind =
"schema";
60 return insert_data_lock_mgr;
65 static inline constexpr std::string_view
kind =
"insert";
85 static inline constexpr std::string_view
kind =
"data";
88 template <
typename LOCK_TYPE>
91 static_assert(std::is_same<LOCK_TYPE, ReadLock>::value ||
92 std::is_same<LOCK_TYPE, WriteLock>::value);
100 const std::string& table_name,
101 const bool populate_fragmenter) {
103 if (td_prelock != td_postlock) {
104 if (td_postlock ==
nullptr) {
116 " Changed whilst attempting to acquire table lock");
126 const std::string& table_name,
127 const bool populate_fragmenter =
true) {
128 VLOG(1) <<
"Acquiring Table Schema Read Lock for table: " << table_name;
137 const int table_id) {
139 if (!table_name.has_value()) {
142 " Cannot acquire read lock");
144 return acquireTableDescriptor(cat, table_name.value());
157 const std::string& table_name,
158 const bool populate_fragmenter =
true) {
159 VLOG(1) <<
"Acquiring Table Schema Write Lock for table: " << table_name;
168 const int table_id) {
170 if (!table_name.has_value()) {
173 " Cannot acquire write lock");
175 return acquireTableDescriptor(cat, table_name.value());
183 template <
typename LOCK_TYPE>
186 static_assert(std::is_same<LOCK_TYPE, ReadLock>::value ||
187 std::is_same<LOCK_TYPE, WriteLock>::value);
200 VLOG(1) <<
"Acquiring Table Data Write Lock for table: " << td->
tableName;
217 VLOG(1) <<
"Acquiring Table Data Read Lock for table: " << td->
tableName;
227 template <
typename LOCK_TYPE>
230 static_assert(std::is_same<LOCK_TYPE, ReadLock>::value ||
231 std::is_same<LOCK_TYPE, WriteLock>::value);
244 VLOG(1) <<
"Acquiring Table Insert Write Lock for table: " << td->
tableName;
261 VLOG(1) <<
"Acquiring Table Insert Read Lock for table: " << td->
tableName;
272 std::vector<std::unique_ptr<lockmgr::AbstractLockContainer<const TableDescriptor*>>>;
std::vector< int > ChunkKey
std::vector< std::unique_ptr< lockmgr::AbstractLockContainer< const TableDescriptor * >>> LockedTableDescriptors
Locks protecting a physical table object returned from the catalog. Table Metadata Locks prevent inco...
static TableSchemaLockMgr & instance()
static constexpr std::string_view kind
static auto acquireTableDescriptor(Catalog_Namespace::Catalog &cat, const std::string &table_name, const bool populate_fragmenter=true)
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 auto acquire(const int db_id, const TableDescriptor *td)
static auto acquireTableDescriptor(Catalog_Namespace::Catalog &cat, const int table_id)
static constexpr std::string_view kind
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.
const DBMetadata & getCurrentDB() const
static auto acquireTableDescriptor(Catalog_Namespace::Catalog &cat, const std::string &table_name, const bool populate_fragmenter=true)
static auto acquireTableDescriptor(Catalog_Namespace::Catalog &cat, const int table_id)
TableDataLockContainer(const TableDataLockContainer &)=delete
static WriteLock getWriteLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
static constexpr std::string_view kind
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...
static ReadLock getReadLockForTable(Catalog_Namespace::Catalog &cat, const std::string &table_name)