[#1024] blobovnicza: Copy data on iterate

DB value is only valid while the tx is alive.
But handler may to run something in other goroutine.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-03-05 16:08:49 +03:00
parent 57466594fb
commit e3d9dd6ee8

View file

@ -1,6 +1,7 @@
package blobovnicza package blobovnicza
import ( import (
"bytes"
"context" "context"
"fmt" "fmt"
"math" "math"
@ -158,7 +159,7 @@ func (b *Blobovnicza) Iterate(ctx context.Context, prm IteratePrm) (IterateRes,
} }
if !prm.withoutData { if !prm.withoutData {
elem.data = v elem.data = bytes.Clone(v)
} }
return prm.handler(elem) return prm.handler(elem)