@@ -743,7 +743,6 @@ func TestStreamWriterIncremental(t *testing.T) {
743743 t .Run ("multiple incremental with older data first" , func (t * testing.T ) {
744744 runBadgerTest (t , nil , func (t * testing.T , db * DB ) {
745745 buf := z .NewBuffer (10 << 20 , "test" )
746- defer func () { require .NoError (t , buf .Release ()) }()
747746 KVToBuffer (& pb.KV {
748747 Key : []byte ("a1" ),
749748 Value : []byte ("val1" ),
@@ -755,7 +754,6 @@ func TestStreamWriterIncremental(t *testing.T) {
755754 require .NoError (t , sw .Flush (), "sw.Flush() failed" )
756755
757756 buf = z .NewBuffer (10 << 20 , "test" )
758- defer func () { require .NoError (t , buf .Release ()) }()
759757 KVToBuffer (& pb.KV {
760758 Key : []byte ("a2" ),
761759 Value : []byte ("val2" ),
@@ -766,6 +764,9 @@ func TestStreamWriterIncremental(t *testing.T) {
766764 require .NoError (t , sw .Write (buf ), "sw.Write() failed" )
767765 require .NoError (t , sw .Flush (), "sw.Flush() failed" )
768766
767+ // Single defer at the end to release the final buffer
768+ defer func () { require .NoError (t , buf .Release ()) }()
769+
769770 // This will move the maxTs to 10 (earlier, without the fix)
770771 require .NoError (t , db .Update (func (txn * Txn ) error {
771772 return txn .Set ([]byte ("a1" ), []byte ("val3" ))
0 commit comments