From 1e8d10a18d7d60eb13ed85f02558abaf632b5425 Mon Sep 17 00:00:00 2001 From: Ivo Dilov Date: Fri, 27 Sep 2024 15:22:20 +0300 Subject: [PATCH] Better error message for non-increasing index. Attempting to write a non-increasing index version is most likely due to parallel writes to the same symbol. We now indicate that in the error message. Also introduces a new storage error type for parallel writes. --- cpp/arcticdb/util/error_code.hpp | 3 ++- cpp/arcticdb/version/test/test_version_map.cpp | 8 ++++---- cpp/arcticdb/version/version_map.hpp | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cpp/arcticdb/util/error_code.hpp b/cpp/arcticdb/util/error_code.hpp index 47b1253bbc..6d8bef5441 100644 --- a/cpp/arcticdb/util/error_code.hpp +++ b/cpp/arcticdb/util/error_code.hpp @@ -86,7 +86,8 @@ inline std::unordered_map get_error_category_names() ERROR_CODE(5021, E_S3_RETRYABLE) \ ERROR_CODE(5030, E_UNEXPECTED_AZURE_ERROR) \ ERROR_CODE(5050, E_MONGO_BULK_OP_NO_REPLY) \ - ERROR_CODE(5051, E_UNEXPECTED_MONGO_ERROR) \ + ERROR_CODE(5051, E_UNEXPECTED_MONGO_ERROR) \ + ERROR_CODE(5090, E_PARALLEL_WRITES_TO_SYMBOL) \ ERROR_CODE(6000, E_UNSORTED_DATA) \ ERROR_CODE(7000, E_INVALID_USER_ARGUMENT) \ ERROR_CODE(7001, E_INVALID_DECIMAL_STRING) \ diff --git a/cpp/arcticdb/version/test/test_version_map.cpp b/cpp/arcticdb/version/test/test_version_map.cpp index 4a12695561..f160efd973 100644 --- a/cpp/arcticdb/version/test/test_version_map.cpp +++ b/cpp/arcticdb/version/test/test_version_map.cpp @@ -385,7 +385,7 @@ TEST(VersionMap, FixRefKey) { EXPECT_THROW({ // We should raise if we try to write a non-increasing index key version_map->write_version(store, key4, key3); - }, InternalException); + }, StorageException); store->remove_key_sync(RefKey{id, KeyType::VERSION_REF}, storage::RemoveOpts{}); ASSERT_FALSE(version_map->check_ref_key(store, id)); @@ -414,15 +414,15 @@ TEST(VersionMap, FixRefKeyTombstones) { auto key2 = atom_key_with_version(id, 0, 1696590624387628801); EXPECT_THROW({ version_map->write_version(store, key2, key1); - }, InternalException); + }, StorageException); auto key3 = atom_key_with_version(id, 0, 1696590624532320286); EXPECT_THROW({ version_map->write_version(store, key3, key2); - }, InternalException); + }, StorageException); auto key4 = atom_key_with_version(id, 0, 1696590624554476875); EXPECT_THROW({ version_map->write_version(store, key4, key3); - }, InternalException); + }, StorageException); auto key5 = atom_key_with_version(id, 1, 1696590624590123209); version_map->write_version(store, key5, key4); auto entry = version_map->check_reload(store, id, LoadStrategy{LoadType::LATEST, LoadObjective::INCLUDE_DELETED}, __FUNCTION__); diff --git a/cpp/arcticdb/version/version_map.hpp b/cpp/arcticdb/version/version_map.hpp index cb9a15786c..b8c0ca62d0 100644 --- a/cpp/arcticdb/version/version_map.hpp +++ b/cpp/arcticdb/version/version_map.hpp @@ -507,8 +507,8 @@ class VersionMapImpl { if (validate_) entry->validate(); - util::check(key.type() != KeyType::TABLE_INDEX || !entry->head_.has_value() || key.version_id() > entry->head_->version_id(), - "Trying to write a non-increasing TABLE_INDEX key. New version: {}, Last version: {}", + storage::check(key.type() != KeyType::TABLE_INDEX || !entry->head_.has_value() || key.version_id() > entry->head_->version_id(), + "Trying to write a non-increasing TABLE_INDEX key. New version: {}, Last version: {}. This is most likely due to parallel writes to the same symbol, which is not supported.", key.version_id(), entry->head_ ? entry->head_->version_id() : VariantId{""}); auto journal_key = to_atom(std::move(journal_single_key(store, key, entry->head_))); write_to_entry(entry, key, journal_key);