---
title: "Sonic: RocksDB backups and search fixes in Rust | VulCode"
description: "Fixes to the Sonic search backend in Rust: backups from an open RocksDB store, FST buckets in backups, leaked client slots and configurable typo correction."
url: "https://vulcode.com/en/opensource/contributions/sonic"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

valeriansaliou/sonic

# Sonic

A lightweight full-text search backend in Rust, an alternative to Elasticsearch that runs in a few megabytes of RAM.

[See the repository](https://github.com/valeriansaliou/sonic) [All contributions](https://vulcode.com/en/opensource/contributions)

- **Language**: Rust
- **GitHub stars**: 21,387
- **Merged changes**: 6
- **Project site**: [crates.io](https://crates.io/crates/sonic-server)

## What we changed

TRIGGER backup works while stores are in use and saves FST buckets again, a read error no longer leaves a client slot taken, and typo correction can be tuned in the config. The docs also state the name length limit and the unit of the write buffer.

### What this work shows

- RocksDB backups

- Error handling in TCP server threads

- Typo correction over an FST index

- Integration tests in Rust

What was broken

### The backup failed with the store open

After a PUSH the RocksDB database stays open in the pool, and TRIGGER backup tried to open it a second time and hit the held LOCK file. On a fresh server the backup also failed because the store directories did not exist yet.

How we fixed it

### A backup from the open instance

When the store is in the pool, the backup is taken from that instance after flushing its buffers to disk. A missing directory is skipped instead of failing, and the trigger_backup test, previously ignored, now runs and covers both cases.

[#430](https://github.com/valeriansaliou/sonic/pull/430)

What was broken

### The FST backup reported success and saved nothing

In the bucket loop, FstStorePool::dump_action checked the collection entry instead of the bucket entry. TRIGGER backup answered OK but wrote no FST file, so a restore brought nothing back.

How we fixed it

### The right entry and a backup test

The loop now reads the file type and name from the bucket entry. We added a test that backs up a consolidated FST index, restores it into a new instance and checks that the stored words come back.

[#432](https://github.com/valeriansaliou/sonic/pull/432)

What was broken

### A dropped connection kept its client slot

When a client stayed silent until the read timeout or hung up, the channel thread ended in a "closing channel" panic. The connected clients counter was never decremented on that path, so each such closure left a slot taken while the log filled with panic messages.

How we fixed it

### Leaving the loop instead of panicking

A read error or a buffer overflow now ends the channel with a plain error that goes to the log, and the client counter is decremented on every exit from the function. A regression test waits for the timeout and checks that the counter shows only the current connection.

[#403](https://github.com/valeriansaliou/sonic/pull/403)

What was broken

### Typo correction could not be tuned

The number of corrected typos depended on word length through thresholds hard-coded in the source. Typo correction can slow QUERY down noticeably and return odd results, and there was no way to change or disable it.

How we fixed it

### The typo_factor_word_lengths option

We added the search.typo_factor_word_lengths option with a default of [4, 7, 10], which keeps the previous behaviour. It applies to both QUERY and SUGGEST, an empty list [] turns correction off, and tests cover custom thresholds and the disabled case.

[#434](https://github.com/valeriansaliou/sonic/pull/434)

What was broken

### A hidden limit on name length

StoreItemPart::from_str accepts collection, bucket and object names of 1 to 128 ASCII characters, but PROTOCOL.md never said so. A client with a longer name or non-ASCII characters got a rejection the docs did not explain.

How we fixed it

### The limit and its errors in the protocol spec

We added the limit to the general rules and to the parameter descriptions in PROTOCOL.md, together with the InvalidCollection, InvalidBucket and InvalidObject errors the server returns.

[#431](https://github.com/valeriansaliou/sonic/pull/431)

What was broken

### The write buffer docs read like a rule

The write_buffer_size docs said the size in KiB should be a multiple of 1024. It read like a requirement, while the code simply multiplies the value by 1024 and the sentence only meant giving the size in whole MiB.

How we fixed it

### A clear MiB conversion

We reworded the entry: the value is in KiB, and to give the size in MiB you multiply it by 1024, for example 128 * 1024 = 131072 for 128 MiB.

[#418](https://github.com/valeriansaliou/sonic/pull/418)

## Merged changes 6

- [#434 feat: Make typo factor configurable Merged 30 October 2026](https://github.com/valeriansaliou/sonic/pull/434)

- [#432 fix(core): Back up and restore FST buckets again Merged 5 October 2026](https://github.com/valeriansaliou/sonic/pull/432)

- [#431 docs: Document the 128 characters limit on collection, bucket and object names Merged 5 October 2026](https://github.com/valeriansaliou/sonic/pull/431)

- [#430 fix(core): Make `TRIGGER backup` work while stores are in use Merged 5 October 2026](https://github.com/valeriansaliou/sonic/pull/430)

- [#418 docs: clarify write_buffer_size Merged 24 September 2026](https://github.com/valeriansaliou/sonic/pull/418)

- [#403 Stop leaking a client slot when a channel read fails Merged 15 September 2026](https://github.com/valeriansaliou/sonic/pull/403)

## What it taught us

A backup taken while the server runs must capture a consistent state from the open database instead of opening it a second time. We close every fix with a test that reproduces the failure, because without one the FST backup kept reporting success while saving nothing.

[More about this technology: Rust](https://vulcode.com/en/technologies/rust)

## Other projects we write code for

- [**Zed** Rust · 95,562 stars A fast code editor in Rust from the creators of Atom and Tree-sitter, with live multiplayer editing.](https://vulcode.com/en/opensource/contributions/zed)

- [**uv** Rust · 92,647 stars An extremely fast Python package and project manager written in Rust. It creates projects, installs dependencies and manages virtual environments.](https://vulcode.com/en/opensource/contributions/uv)

- [**ripgrep** Rust · 70,186 stars A command line tool that recursively searches directories for a regex pattern while respecting your .gitignore. Written in Rust.](https://vulcode.com/en/opensource/contributions/ripgrep)

- [**Alacritty** Rust · 66,271 stars A cross-platform terminal emulator rendered with OpenGL, written in Rust and configured with a TOML file.](https://vulcode.com/en/opensource/contributions/alacritty)

- [**Gleam** Rust · 22,083 stars A friendly programming language for building type-safe, scalable systems. Its compiler is written in Rust.](https://vulcode.com/en/opensource/contributions/gleam)

- [**Pagefind** Rust · 5,575 stars A Rust search engine for static sites that indexes the built site and only sends the needed parts of the index to the browser.](https://vulcode.com/en/opensource/contributions/pagefind)

## Describe your project.

A free quote comes back within an hour during working hours.

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
