diff --git a/CHANGELOG.md b/CHANGELOG.md index e4bcd0c1..7af4cf76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 8.18.4 (unreleased) +### Implementation changes and bug fixes +- [PR #1644](https://github.com/rqlite/rqlite/pull/1644): Remove an unnecessary memcpy during Snapshotting. + ## 8.18.3 (January 29th 2024) ### Implementation changes and bug fixes - [PR #1638](https://github.com/rqlite/rqlite/pull/1638): More Snapshotting metrics. diff --git a/store/store.go b/store/store.go index 96ec3a3b..df5e8a88 100644 --- a/store/store.go +++ b/store/store.go @@ -1949,15 +1949,13 @@ func (s *Store) fsmSnapshot() (fSnap raft.FSMSnapshot, retErr error) { if err != nil { return nil, err } - walWr, err := wal.NewWriter(scanner) + walFD.Close() // We need it closed for the next step. + compactedBytes, err := scanner.Bytes() if err != nil { return nil, err } - if _, err := walWr.WriteTo(compactedBuf); err != nil { - return nil, err - } - walFD.Close() // We need it closed for the next step. stats.Get(snapshotCreateWALCompactDuration).(*expvar.Int).Set(time.Since(compactStartTime).Milliseconds()) + compactedBuf = bytes.NewBuffer(compactedBytes) // Now that we're written a (compacted) copy of the WAL to the Snapshot, // we can truncate the WAL. We use truncate mode so that the next WAL