@@ -7,10 +7,11 @@ package metamorphic
7
7
import (
8
8
"bytes"
9
9
"context"
10
- "crypto/rand"
10
+ cryptorand "crypto/rand"
11
11
"encoding/binary"
12
12
"fmt"
13
13
"io"
14
+ "math/rand/v2"
14
15
"path"
15
16
"path/filepath"
16
17
"slices"
@@ -1053,7 +1054,7 @@ func (o *ingestExternalFilesOp) run(t *Test, h historyRecorder) {
1053
1054
meta := t .getExternalObj (obj .externalObjID )
1054
1055
external [i ] = pebble.ExternalFile {
1055
1056
Locator : "external" ,
1056
- ObjName : externalObjName ( obj . externalObjID ) ,
1057
+ ObjName : meta . objName ,
1057
1058
Size : meta .sstMeta .Size ,
1058
1059
StartKey : obj .bounds .Start ,
1059
1060
EndKey : obj .bounds .End ,
@@ -1199,8 +1200,8 @@ func (o *newIterOp) run(t *Test, h historyRecorder) {
1199
1200
// Trash the bounds to ensure that Pebble doesn't rely on the stability of
1200
1201
// the user-provided bounds.
1201
1202
if opts != nil {
1202
- rand .Read (opts .LowerBound [:])
1203
- rand .Read (opts .UpperBound [:])
1203
+ cryptorand .Read (opts .LowerBound [:])
1204
+ cryptorand .Read (opts .UpperBound [:])
1204
1205
}
1205
1206
h .Recordf ("%s // %v" , o .formattedString (t .testOpts .KeyFormat ), i .Error ())
1206
1207
}
@@ -1318,8 +1319,8 @@ func (o *iterSetBoundsOp) run(t *Test, h historyRecorder) {
1318
1319
1319
1320
// Trash the bounds to ensure that Pebble doesn't rely on the stability of
1320
1321
// the user-provided bounds.
1321
- rand .Read (lower [:])
1322
- rand .Read (upper [:])
1322
+ cryptorand .Read (lower [:])
1323
+ cryptorand .Read (upper [:])
1323
1324
1324
1325
h .Recordf ("%s // %v" , o .formattedString (t .testOpts .KeyFormat ), i .Error ())
1325
1326
}
@@ -1363,8 +1364,8 @@ func (o *iterSetOptionsOp) run(t *Test, h historyRecorder) {
1363
1364
1364
1365
// Trash the bounds to ensure that Pebble doesn't rely on the stability of
1365
1366
// the user-provided bounds.
1366
- rand .Read (opts .LowerBound [:])
1367
- rand .Read (opts .UpperBound [:])
1367
+ cryptorand .Read (opts .LowerBound [:])
1368
+ cryptorand .Read (opts .UpperBound [:])
1368
1369
1369
1370
h .Recordf ("%s // %v" , o .formattedString (t .testOpts .KeyFormat ), i .Error ())
1370
1371
}
@@ -1872,18 +1873,20 @@ type newExternalObjOp struct {
1872
1873
externalObjID objID
1873
1874
}
1874
1875
1875
- func externalObjName (externalObjID objID ) string {
1876
- if externalObjID .tag () != externalObjTag {
1877
- panic (fmt .Sprintf ("invalid externalObjID %s" , externalObjID ))
1878
- }
1879
- return fmt .Sprintf ("external-for-ingest-%d.sst" , externalObjID .slot ())
1880
- }
1881
-
1882
1876
func (o * newExternalObjOp ) run (t * Test , h historyRecorder ) {
1883
1877
b := t .getBatch (o .batchID )
1884
1878
t .clearObj (o .batchID )
1885
1879
1886
- writeCloser , err := t .externalStorage .CreateObject (externalObjName (o .externalObjID ))
1880
+ if o .externalObjID .tag () != externalObjTag {
1881
+ panic (fmt .Sprintf ("invalid externalObjID %s" , o .externalObjID ))
1882
+ }
1883
+ // We add a unique number to the object name to avoid collisions with existing
1884
+ // external objects (when using an initial starting state).
1885
+ //
1886
+ // Note that the number is not based on the seed, in case we run using the
1887
+ // same seed that was used in a previous run with the same store.
1888
+ objName := fmt .Sprintf ("external-for-ingest-%d-%d.sst" , o .externalObjID .slot (), rand .Uint64 ())
1889
+ writeCloser , err := t .externalStorage .CreateObject (objName )
1887
1890
if err != nil {
1888
1891
panic (err )
1889
1892
}
@@ -1908,6 +1911,7 @@ func (o *newExternalObjOp) run(t *Test, h historyRecorder) {
1908
1911
panic ("metamorphic test internal error: external object empty" )
1909
1912
}
1910
1913
t .setExternalObj (o .externalObjID , externalObjMeta {
1914
+ objName : objName ,
1911
1915
sstMeta : sstMeta ,
1912
1916
})
1913
1917
h .Recordf ("%s" , o .formattedString (t .testOpts .KeyFormat ))
0 commit comments