All contributions

valeriansaliou/sonic

Sonic

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

Language
Rust
GitHub stars
21,387
Merged changes
6
Project site
crates.io

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

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

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

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

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

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

Merged changes 6

  1. #434 feat: Make typo factor configurable Merged 30 October 2026
  2. #432 fix(core): Back up and restore FST buckets again Merged 5 October 2026
  3. #431 docs: Document the 128 characters limit on collection, bucket and object names Merged 5 October 2026
  4. #430 fix(core): Make `TRIGGER backup` work while stores are in use Merged 5 October 2026
  5. #418 docs: clarify write_buffer_size Merged 24 September 2026
  6. #403 Stop leaking a client slot when a channel read fails Merged 15 September 2026

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

Other projects we write code for

Describe your project.

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