تخطَّ إلى المحتوى
NYSIRIS Softwares & Technology

NDatabase

ملاحظات حول كتابة قاعدة بيانات بلا شيفرة غير آمنة

مايو 2026

A storage engine is the part of a system you are not supposed to think about. It keeps its promises silently, and the day it does not, every layer above it inherits the doubt. We wrote NDatabase in Rust with a hard rule: no unsafe. Not as a badge, but as a decision about where accountability lives.

The argument against the rule is always performance. Unsafe lets you skip a bounds check, alias a pointer, reinterpret a buffer. In a hot path that can matter. But most of what a database does at speed is bounded by I/O, cache behaviour and the shape of the data — not by the handful of checks the borrow checker insists on. When we profiled, the safe version was within noise of the alternatives, and it never corrupted a page.

What the rule buys you is narrower failure. A memory-safety bug in a storage engine is not a crash you debug on Monday; it is silent corruption that surfaces weeks later as a customer's data that no longer reconciles. By construction, that class of bug is gone. The failures that remain are logic failures — and logic you can test, reproduce and reason about.

There is a discipline cost. You design around ownership instead of fighting it: arenas for short-lived allocations, explicit lifetimes for cursors, a write path that cannot outlive its transaction. It is more thinking up front and less firefighting later. For software meant to run for a decade, that trade is not close.

Zero unsafe is, in the end, a statement about who is accountable when the engine is wrong at three in the morning. We would rather the answer be the compiler than the operator.

المدوّنة