Table of Contents

Class RocksDbCallbacks

Namespace
RocksDbNet
Assembly
RocksDb.Net.dll

Process-wide reporting for exceptions that escape managed RocksDb callbacks.

public static class RocksDbCallbacks
Inheritance
RocksDbCallbacks
Inherited Members

Remarks

A managed exception must never propagate into native code: the runtime treats that as unrecoverable and terminates the process. Every callback this library installs therefore catches exceptions at the native boundary and reports them here instead.

Subscribe to UnhandledException to log or surface these. Without a subscriber the exception is not observable, which is why non-fatal callbacks also fall back to a defined no-op behaviour rather than failing silently in a way that changes data.

Events

UnhandledException

Raised when a managed callback invoked by RocksDb throws.

public static event EventHandler<CallbackExceptionEventArgs>? UnhandledException

Event Type

EventHandler<CallbackExceptionEventArgs>

Remarks

The sender identifies what threw, so that several installed callbacks can be told apart. The callback name alone cannot do that: two compaction filters both report under Filter.

For callbacks installed as a subclass it is that instance, such as the CompactionFilter or EventListener. For the two installed as a plain delegate, SetTableFilter(Func<TablePropertiesView, bool>) and the CreateBackupOptions callbacks, it is the delegate itself, since that is what the callback holds. Compare with ReferenceEquals(object, object) against whichever you registered.

It is null only when the source cannot be identified, which happens when resolving it is itself what failed.

Handlers run on the thread that raised the exception, which is a RocksDb background thread for flush, compaction and backup callbacks, so handlers must be thread-safe. A handler that throws is ignored, to avoid replacing the original failure with a second one.