From e3d9dd6ee8134107926cf4cf58d41899b1eebf96 Mon Sep 17 00:00:00 2001
From: Dmitrii Stepanov <d.stepanov@yadro.com>
Date: Tue, 5 Mar 2024 16:08:49 +0300
Subject: [PATCH] [#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>
---
 pkg/local_object_storage/blobovnicza/iterate.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pkg/local_object_storage/blobovnicza/iterate.go b/pkg/local_object_storage/blobovnicza/iterate.go
index 32b0ccea7..b1cb91920 100644
--- a/pkg/local_object_storage/blobovnicza/iterate.go
+++ b/pkg/local_object_storage/blobovnicza/iterate.go
@@ -1,6 +1,7 @@
 package blobovnicza
 
 import (
+	"bytes"
 	"context"
 	"fmt"
 	"math"
@@ -158,7 +159,7 @@ func (b *Blobovnicza) Iterate(ctx context.Context, prm IteratePrm) (IterateRes,
 				}
 
 				if !prm.withoutData {
-					elem.data = v
+					elem.data = bytes.Clone(v)
 				}
 
 				return prm.handler(elem)