Skip to content

Commit d812f94

Browse files
jgates108fritzm
authored andcommitted
UserQueryFactory mutex change.
1 parent 45e9a89 commit d812f94

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/ccontrol/UserQueryFactory.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,20 @@ UserQuery::Ptr UserQueryFactory::newUserQuery(std::string const& aQuery, std::st
298298
}
299299
auto stmt = parser->getSelectStmt();
300300

301+
/// &&& not entirely sure what the _mutex was protecting _clientToQuery and _idToQuery aren't touched
302+
/// &&& Not sure what internal elements of UserQueryFactory need protection?
303+
/// &&& None of its members look like they need protection.
304+
/// &&& Is there an order of operations to things happening in the database?
305+
std::unique_lock<std::mutex> uLock(_factoryMtx); //&&&
306+
301307
// handle special database/table names
302308
if (_stmtRefersToProcessListTable(stmt, defaultDb)) {
303309
return _makeUserQueryProcessList(stmt, _userQuerySharedResources, userQueryId, resultDb, aQuery,
304-
async);
310+
async);
305311
}
306312
if (_stmtRefersQueriesTable(stmt, defaultDb)) {
307313
return _makeUserQueryQueries(stmt, _userQuerySharedResources, userQueryId, resultDb, aQuery,
308-
async);
314+
async);
309315
}
310316

311317
/// Determine if a SelectStmt is a simple COUNT(*) query and can be run as an optimized query.
@@ -337,6 +343,7 @@ UserQuery::Ptr UserQueryFactory::newUserQuery(std::string const& aQuery, std::st
337343
auto qs = std::make_shared<qproc::QuerySession>(_userQuerySharedResources->css,
338344
_userQuerySharedResources->databaseModels, defaultDb,
339345
_userQuerySharedResources->interactiveChunkLimit);
346+
uLock.unlock(); // &&& unlock the mutex before going back to expensive operations.
340347
try {
341348
qs->analyzeQuery(query, stmt);
342349
} catch (...) {

src/ccontrol/UserQueryFactory.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,11 @@ class UserQueryFactory : private boost::noncopyable {
103103
boost::asio::io_service _asioIoService;
104104
std::unique_ptr<boost::asio::io_service::work> _asioWork;
105105
std::unique_ptr<std::thread> _asioTimerThread;
106+
107+
std::mutex _factoryMtx; // &&& is this needed
106108
};
107109

110+
108111
} // namespace lsst::qserv::ccontrol
109112

110113
#endif // LSST_QSERV_CCONTROL_USERQUERYFACTORY_H

0 commit comments

Comments
 (0)