mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-25 11:00:35 +00:00
This PR fixes the bug of certain calls to the `mintimeuuid()` CQL function which large negative timestamps could crash Scylla. It turns out we already had protections in place against very positive timestamps, but very negative timestamps could still cause bugs.
The actual fix in this series is just a few lines, but the bigger effort was improving the test coverage in this area. I added tests for the "date" type (the original reproducer for this bug used totimestamp() which takes a date parameter), and also reproducers for this bug directly, without totimestamp() function, and one with that function.
Finally this PR also replaces the assert() which made this molehill-of-a-bug into a mountain, by a throw.
Fixes #17035
Closes scylladb/scylladb#17073
* github.com:scylladb/scylladb:
utils: replace assert() by on_internal_error()
utils: add on_internal_error with common logger
utils: add a timeuuid minimum, like we had maximum
test/cql-pytest: tests for "date" type
(cherry picked from commit 2a4b991772)
34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
/*
|
|
* Copyright (C) 2024-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
// Seastar's on_internal_error() is a replacement for assert(). Instead of
|
|
// crashing like assert(), on_internal_error() logs a message with a
|
|
// backtrace and throws an exception (and optionally also crashes - this can
|
|
// be useful for testing). However, Seastar's function is inconvenient because
|
|
// it requires specifying a logger. This makes it hard to call it from source
|
|
// files which don't already have a logger, or in code in a header file.
|
|
//
|
|
// So here we provide Scylla's version of on_internal_error() which uses a
|
|
// single logger for all internal errors - with no need to specify a logger
|
|
// object to each call.
|
|
|
|
#pragma once
|
|
|
|
#include <string_view>
|
|
|
|
namespace utils {
|
|
|
|
/// Report an internal error
|
|
///
|
|
/// Depending on the value passed to seastar::set_abort_on_internal_error(),
|
|
/// this will either abort or throw a std::runtime_error.
|
|
/// In both cases an error will be logged, containing \p reason and the
|
|
/// current backtrace.
|
|
[[noreturn]] void on_internal_error(std::string_view reason);
|
|
|
|
} |