Skip to content

Commit

Permalink
Fix prune_previous versions to no throw exception when there is an ex…
Browse files Browse the repository at this point in the history
…isting symbol with no active versions. Now it throws only if the symbol does not exist.
  • Loading branch information
Vasil Pashov authored and Vasil Pashov committed May 30, 2023
1 parent 3e67fa1 commit 9a346bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions cpp/arcticdb/util/error_code.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ inline std::unordered_map<ErrorCategory, const char*> get_error_category_names()
ERROR_CODE(4004, E_OPERATION_NOT_SUPPORTED_WITH_PICKLED_DATA) \
ERROR_CODE(5000, E_KEY_NOT_FOUND) \
ERROR_CODE(5001, E_DUPLICATE_KEY) \
ERROR_CODE(5002, E_SYMBOL_NOT_FOUND) \
ERROR_CODE(6000, E_UNSORTED_DATA) \
ERROR_CODE(7000, E_INVALID_USER_ARGUMENT)\
ERROR_CODE(8000, E_UNRECOGNISED_COLUMN_STATS_VERSION) \
Expand Down
11 changes: 8 additions & 3 deletions cpp/arcticdb/version/version_store_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,10 +933,15 @@ void PythonVersionStore::fix_symbol_trees(const std::vector<StreamId>& symbols)

void PythonVersionStore::prune_previous_versions(const StreamId& stream_id) {
ARCTICDB_RUNTIME_DEBUG(log::version(), "Command: prune_previous_versions stream_id={}", stream_id);
const auto entry = version_map()->check_reload(store(), stream_id, LoadParameter{LoadType::LOAD_UNDELETED},
true, false, __FUNCTION__);
const std::shared_ptr<VersionMapEntry>& entry = version_map()->check_reload(
store(),
stream_id,
LoadParameter{LoadType::LOAD_UNDELETED},
true,
false,
__FUNCTION__);
storage::check<ErrorCode::E_SYMBOL_NOT_FOUND>(!entry->empty(), "Symbol {} is not found", stream_id);
auto latest = entry->get_first_index(false);
util::check(latest.has_value(), "Cannot prune previous versions for non-existent symbol {}", stream_id);

auto prev_id = get_prev_version_in_entry(entry, latest->version_id());
if (!prev_id) {
Expand Down

0 comments on commit 9a346bd

Please sign in to comment.