foyer-rs / foyer

Hybrid in-memory and disk cache in Rust
https://foyer.rs
Apache License 2.0
281 stars 20 forks source link

bug: insert value size is zero #338

Closed xiaguan closed 6 months ago

xiaguan commented 6 months ago

Reproduce commands(by fuzz)

        Input {
            capacity: 95,
            cache_type: S3Fifo,
            operations: [
                Insert(
                    0,
                    0,
                    0,
                ),
                Insert(
                    33,
                    33,
                    143,
                ),
            ],
        }
thread '<unnamed>' panicked at /home/susun/foyer/foyer-memory/src/eviction/s3fifo.rs:223:13:
assertion failed: self.is_empty()
MrCroxx commented 6 months ago

evict may return None even then cache is not empty.

https://github.com/MrCroxx/foyer/blob/main/foyer-memory/src/eviction/s3fifo.rs#L141-L182

If the small queue eviction will be skipped.

https://github.com/MrCroxx/foyer/blob/main/foyer-memory/src/eviction/s3fifo.rs#L161

And this line subtracts the wrong charges. 🥹 I'll fix the bugs.

MrCroxx commented 6 months ago

evict may return None even then cache is not empty.

https://github.com/MrCroxx/foyer/blob/main/foyer-memory/src/eviction/s3fifo.rs#L141-L182

If the small queue eviction will be skipped.

https://github.com/MrCroxx/foyer/blob/main/foyer-memory/src/eviction/s3fifo.rs#L161

And this line subtracts the wrong charges. 🥹 I'll fix the bugs.

360