From 815a6783ff78b25926087af7a1b778582d78f848 Mon Sep 17 00:00:00 2001 From: rayx Date: Wed, 10 Jun 2026 21:00:22 +0800 Subject: [PATCH] refactor: disable diskann index create on open (#479) --- src/db/index/common/schema.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/db/index/common/schema.cc b/src/db/index/common/schema.cc index 8886a6b..9471eee 100644 --- a/src/db/index/common/schema.cc +++ b/src/db/index/common/schema.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include "ailego/internal/cpu_features.h" #include "db/common/constants.h" #include "db/common/typedef.h" @@ -172,6 +173,33 @@ Status FieldSchema::validate() const { } } + if (index_params_->type() == IndexType::DISKANN) { + // Probe the DiskAnn runtime eagerly at creation time so unsupported + // platforms (non Linux x86_64), missing libaio, or a missing plugin + // .so fail fast with a clear message instead of surfacing later during + // optimize(). This reuses the same gate DiskAnnIndex applies on first + // use (zvec::LoadDiskAnnPlugin, wrapped by EnsureDiskAnnRuntimeReady). + // All validate() call sites are creation-time only, so triggering the + // plugin load here is safe (and idempotent/cached). + const int rc = ::zvec::LoadDiskAnnPlugin(); + switch (rc) { + case kDiskAnnPluginOk: + break; + case kDiskAnnPluginUnsupportedPlatform: + return Status::NotSupported( + "DiskAnn is not supported on this platform (Linux x86_64 " + "only)"); + case kDiskAnnPluginLibAioMissing: + return Status::NotSupported( + "DiskAnn requires libaio at runtime, but it was not found on " + "this host. Install it (e.g. 'apt-get install libaio1', or " + "'libaio1t64' on Ubuntu 24.04+) and retry."); + default: + return Status::NotSupported( + "DiskAnn runtime could not be initialized on this host"); + } + } + if (vector_index_params->quantize_type() != QuantizeType::UNDEFINED) { auto iter = quantize_type_map.find(data_type_);