From 1618080632981c51b495483966ec3064f8e24356 Mon Sep 17 00:00:00 2001 From: Ian Shim Date: Fri, 6 Sep 2024 17:22:35 +0900 Subject: [PATCH] keep encoded blob result until terminal --- disperser/batcher/batcher.go | 2 ++ disperser/batcher/batcher_test.go | 4 ++-- disperser/batcher/encoding_streamer.go | 2 -- disperser/batcher/encoding_streamer_test.go | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/disperser/batcher/batcher.go b/disperser/batcher/batcher.go index cec50b06e2..6981de50c3 100644 --- a/disperser/batcher/batcher.go +++ b/disperser/batcher/batcher.go @@ -312,10 +312,12 @@ func (b *Batcher) updateConfirmationInfo( if status == disperser.Confirmed { if _, updateConfirmationInfoErr = b.Queue.MarkBlobConfirmed(ctx, metadata, confirmationInfo); updateConfirmationInfoErr == nil { + b.EncodingStreamer.RemoveEncodedBlob(metadata) b.Metrics.UpdateCompletedBlob(int(metadata.RequestMetadata.BlobSize), disperser.Confirmed) } } else if status == disperser.InsufficientSignatures { if _, updateConfirmationInfoErr = b.Queue.MarkBlobInsufficientSignatures(ctx, metadata, confirmationInfo); updateConfirmationInfoErr == nil { + b.EncodingStreamer.RemoveEncodedBlob(metadata) b.Metrics.UpdateCompletedBlob(int(metadata.RequestMetadata.BlobSize), disperser.InsufficientSignatures) } } else { diff --git a/disperser/batcher/batcher_test.go b/disperser/batcher/batcher_test.go index 0a2e8d91a7..1e5fb4f6bc 100644 --- a/disperser/batcher/batcher_test.go +++ b/disperser/batcher/batcher_test.go @@ -448,8 +448,8 @@ func TestBlobRetry(t *testing.T) { assert.NoError(t, err) assert.Equal(t, disperser.Dispersing, meta.BlobStatus) encodedResult, err = components.encodingStreamer.EncodedBlobstore.GetEncodingResult(blobKey, 0) - assert.ErrorContains(t, err, "no such key") - assert.Nil(t, encodedResult) + assert.NoError(t, err) + assert.NotNil(t, encodedResult) err = components.encodingStreamer.RequestEncoding(ctx, out) assert.NoError(t, err) diff --git a/disperser/batcher/encoding_streamer.go b/disperser/batcher/encoding_streamer.go index 0dcd1b4823..6a26eca79f 100644 --- a/disperser/batcher/encoding_streamer.go +++ b/disperser/batcher/encoding_streamer.go @@ -769,8 +769,6 @@ func (e *EncodingStreamer) transitionBlobToDispersing(ctx context.Context, metad e.logger.Error("error marking blob as dispersing", "err", err, "blobKey", blobKey.String()) return err } - // remove encoded blob from storage so we don't disperse it again - e.RemoveEncodedBlob(metadata) return nil } diff --git a/disperser/batcher/encoding_streamer_test.go b/disperser/batcher/encoding_streamer_test.go index 5d9337f4b6..b231b68279 100644 --- a/disperser/batcher/encoding_streamer_test.go +++ b/disperser/batcher/encoding_streamer_test.go @@ -655,11 +655,11 @@ func TestGetBatch(t *testing.T) { assert.Equal(t, disperser.Dispersing, metadata2.BlobStatus) assert.Nil(t, err) res, err := encodingStreamer.EncodedBlobstore.GetEncodingResult(metadataKey1, core.QuorumID(0)) - assert.Nil(t, res) - assert.ErrorContains(t, err, "GetEncodedBlob: no such key") + assert.NoError(t, err) + assert.NotNil(t, res) res, err = encodingStreamer.EncodedBlobstore.GetEncodingResult(metadataKey1, core.QuorumID(1)) - assert.Nil(t, res) - assert.ErrorContains(t, err, "GetEncodedBlob: no such key") + assert.NoError(t, err) + assert.NotNil(t, res) res, err = encodingStreamer.EncodedBlobstore.GetEncodingResult(metadataKey2, core.QuorumID(0)) assert.Nil(t, res) assert.ErrorContains(t, err, "GetEncodedBlob: no such key")