test: verify DSpark device KV rollback

This commit is contained in:
Constantin committed 2026-11-03 13:56:46 -05:00
1 parent e14463b8eb
commit c96cfc9e7b
8 files changed
+418 -11

No files matched your search

+7
View File
@@ -2571,7 +2571,14 @@ int Scheduler::commit(StepResult& res) {
/* Not while a step issued ahead writes past `valid`; that step's commit rolls back to
* the end it reaches. */
if (a < e.n_spec && !(next_open_ && s.entry_next >= 0)) {
#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK
if (kv_rollback_test_hook_) kv_rollback_test_hook_(r.id, e.n_spec, a, valid, true);
#endif
int st = kv_->rollback(r.id, valid);
#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK
if (st >= 0 && kv_rollback_test_hook_)
kv_rollback_test_hook_(r.id, e.n_spec, a, valid, false);
#endif
if (st < 0) RAD_WARN("kv rollback for request %llu: %s",
(unsigned long long)r.id, rad_strerror(st));
}
+13
View File
@@ -19,6 +19,9 @@
#include "ngram.h"
#include <chrono>
#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK
#include <functional>
#endif
#include <memory>
#include <mutex>
#include <unordered_map>
@@ -495,6 +498,13 @@ public:
int64_t chunk_end(const Request& r, int64_t n_target) const;
private:
#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK
friend class Engine;
/* Test-build-only observer at the concrete rollback operation. */
void set_kv_rollback_test_hook(std::function<void(uint64_t, int, int, int64_t, bool)> hook) {
kv_rollback_test_hook_ = std::move(hook);
}
#endif
Program* prog_ = nullptr;
Config cfg_{};
ChunkGeometry geo_{};
@@ -512,6 +522,9 @@ private:
* step, so plan_chunk called directly answers for a span. */
bool span_now_ = true;
IKVManager* kv_ = nullptr;
#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK
std::function<void(uint64_t, int, int, int64_t, bool)> kv_rollback_test_hook_;
#endif
IPrefixCache* pc_ = nullptr;
/* Does a prefix-cache hit leave a hole in a block drafter's own KV? Only if some paged group