Files
scylladb/readers/queue.hh
Botond Dénes 07510c07a0 readers/mutation_readers: queue_reader_handle_v2::push_end_of_stream() raise _ex if set
Instead of raising std::runtime_error("Dangling queue_reader_handle_v2")
unconditionally. push() already raises _ex if set, best to be
consistent.
Unconditionally raising std::runtime_error can cause an error to be
logged, when aborting an operation involving a queue reader.
Although the original exception passed to
queue_reader_handle_v2::abort() is most likely handled by higher level
code (not logged), the generic std::runtime_error raised is not and
therefore is logged.

Fixes: #23550

Closes scylladb/scylladb#23554
2025-04-03 10:39:56 +03:00

60 lines
1.7 KiB
C++

/*
* Copyright (C) 2022-present ScyllaDB
*/
/*
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
*/
#pragma once
#include "readers/mutation_reader.hh"
class queue_reader_v2;
/// Calls to different methods cannot overlap!
/// The handle can be used only while the reader is still alive. Once
/// `push_end_of_stream()` is called, the reader and the handle can be destroyed
/// in any order. The reader can be destroyed at any time.
class queue_reader_handle_v2 {
friend std::pair<mutation_reader, queue_reader_handle_v2> make_queue_reader_v2(schema_ptr, reader_permit);
friend class queue_reader_v2;
private:
queue_reader_v2* _reader = nullptr;
std::exception_ptr _ex;
private:
explicit queue_reader_handle_v2(queue_reader_v2& reader) noexcept;
void abandon() noexcept;
[[nodiscard]] std::exception_ptr check_abort() const noexcept;
public:
queue_reader_handle_v2(queue_reader_handle_v2&& o) noexcept;
~queue_reader_handle_v2();
queue_reader_handle_v2& operator=(queue_reader_handle_v2&& o);
future<> push(mutation_fragment_v2 mf);
/// Terminate the queue.
///
/// The reader will be set to EOS. The handle cannot be used anymore.
void push_end_of_stream();
/// Aborts the queue.
///
/// All future operations on the handle or the reader will raise `ep`.
void abort(std::exception_ptr ep);
/// Checks if the queue is already terminated with either a success or failure (abort)
bool is_terminated() const;
/// Get the stored exception, if any
std::exception_ptr get_exception() const noexcept;
};
std::pair<mutation_reader, queue_reader_handle_v2> make_queue_reader_v2(schema_ptr s, reader_permit permit);