blockfile: Catch unchecked exceptions thrown from value deserializers

Previously, we detected null results but did not catch exceptions
thrown by the value deserializers, caused by database corruption,
deserialization bugs, or input validation or serialization errors.
This prevented the database repair code from running, rendering
the remainder of the skip span inaccessible, and no entries displayed
in susidns.

With this change, corrupted entries that throw unchecked exceptions
are removed from the skip span.
This commit is contained in:
zzz
2025-04-24 13:15:04 -04:00
parent 10c249ff6e
commit 6fa725b755

View File

@ -330,8 +330,21 @@ public class BSkipSpan<K extends Comparable<? super K>, V> extends SkipSpan<K, V
break;
}
// System.out.println("i=" + i + ", Page " + curPage + ", offset " + pageCounter[0] + " ksz " + ksz + " vsz " + vsz);
this.keys[i] = this.keySer.construct(k);
this.vals[i] = this.valSer.construct(v);
try {
this.keys[i] = this.keySer.construct(k);
this.vals[i] = this.valSer.construct(v);
} catch (Exception e) {
// It's important to catch unchecked exceptions here,
// so we can repair corruption below.
// Ideally, the value deserializers should not throw
// unchecked exceptions, and always return null, but
// Destination can throw some IllegalArgumentExceptions.
if (this.keys[i] != null)
bf.log.error("Error loading key " + this.keys[i], e);
else
bf.log.error("Error loading entry " + i, e);
}
// Drop bad entry without throwing exception
if (this.keys[i] == null || this.vals[i] == null) {
bf.log.error("Null deserialized data in entry " + i + " page " + curPage +