Skip to content

Commit

Permalink
Streamlined processing state management of the contribution requests
Browse files Browse the repository at this point in the history
  • Loading branch information
iagaponenko committed Sep 6, 2024
1 parent 650f4dc commit 0313c52
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/replica/ingest/IngestRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,10 @@ void IngestRequest::_processStart() {
string const context = ::context_ + string(__func__) + " ";
replica::Lock const lock(_mtx, context);

if (_processing) {
if (_processing.exchange(true)) {
throw logic_error(context + "the contribution request " + to_string(_contrib.id) +
" is already being processed or has been processed.");
}
_processing = true;

bool const failed = true;
auto const databaseServices = serviceProvider()->databaseServices();
Expand Down
10 changes: 5 additions & 5 deletions src/replica/ingest/IngestRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,19 @@ class IngestRequest : public std::enable_shared_from_this<IngestRequest>, public
/// parameters of the request.
TransactionContribInfo _contrib;

// These variables are set after completing parameter validation
// These variables are set by the constructors after completing parameter validation.
std::unique_ptr<http::Url> _resource;
csv::Dialect _dialect;

/// The flag is set by method process(), and once it's set it's never
/// reset. The flag is used for coordinating state change with other methods
/// of the class. In particular, setting this flag would prevent executing
/// the request more than one time.
bool _processing = false;
std::atomic<bool> _processing{false};

// Setting the flag will interrupt request processing (if the one is
// still going on).
std::atomic<bool> _cancelled{false}; ///< Set by calling the public method cancel()
/// Set by calling the public method cancel(). Setting the flag will interrupt
/// request processing (if the one is still going on).
std::atomic<bool> _cancelled{false};
};

} // namespace lsst::qserv::replica
Expand Down

0 comments on commit 0313c52

Please sign in to comment.