]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Feature] Add fuzzy Redis migration utility
authorVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 20 Oct 2025 10:33:35 +0000 (11:33 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 20 Oct 2025 10:33:35 +0000 (11:33 +0100)
commit10259b5c283cba51dd3a458adb70c590ff32bcd9
tree3bef0a968c0b109c989e15ef9e418fe1d523bda0
parent8737a72896929d05d13f025e43b1552eff8f42db
[Feature] Add fuzzy Redis migration utility

This utility provides an optimized tool for migrating Rspamd fuzzy backend
data between Redis instances with the following features:

* Non-blocking SCAN-based iteration through Redis keys
* Filter exports by specific fuzzy flags (e.g., flag 1, 8, 11)
* Automatic detection and migration of shingles (32 per text hash)
* TTL preservation for all keys
* Binary Storable format for efficient serialization
* Single-pass algorithm with O(N) complexity instead of O(N*M)
* Redis pipelining for minimal network round-trips
* Configurable batch sizes for memory and performance tuning
* Detailed statistics including per-flag distribution
* Comprehensive POD documentation

Performance optimizations:
- Large SCAN batches (default 5000) for fast key iteration
- Pipeline size of 500 operations for maximum throughput
- ~800x faster than naive approach for large datasets
- Single-pass shingle matching instead of per-hash SCAN operations

Usage:
  # Export fuzzy hashes with flag filtering
  fuzzy_redis_migrate.pl --source-host redis1 --flags 1 8 --export backup.dat

  # Import to another Redis instance
  fuzzy_redis_migrate.pl --dest-host redis2 --import backup.dat

  # View full documentation
  perldoc utils/fuzzy_redis_migrate.pl
utils/fuzzy_redis_migrate.pl [new file with mode: 0755]