Skip to content
Snippets Groups Projects
Commit 5f728fee authored by Steven Murray's avatar Steven Murray
Browse files

SqliteCatalogue::getNextArchiveFileId() now serializes it access to the database

parent 3948021c
No related branches found
No related tags found
No related merge requests found
......@@ -98,6 +98,10 @@ common::dataStructures::ArchiveFile SqliteCatalogue::deleteArchiveFile(const std
//------------------------------------------------------------------------------
uint64_t SqliteCatalogue::getNextArchiveFileId(rdbms::PooledConn &conn) {
try {
// The SQLite implemenation of getNextArchiveFileId() serializes access to
// the SQLite database in order to avoid busy errors
std::lock_guard<std::mutex> m_lock(m_mutex);
rdbms::AutoRollback autoRollback(conn);
conn.executeNonQuery("UPDATE ARCHIVE_FILE_ID SET ID = ID + 1", rdbms::Stmt::AutocommitMode::OFF);
......
......@@ -72,6 +72,10 @@ protected:
* because different database technologies propose different solution to the
* problem of generating ever increasing numeric identifiers.
*
* PLEASE NOTE the SQLite implemenation of getNextArchiveFileId() takes a lock
* on m_mutex in order to serialize access to the SQLite database. This has
* been done in an attempt to avoid SQLite busy errors.
*
* @param conn The database connection.
* @return A unique archive ID that can be used by a new archive file within
* the catalogue.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment