Update index & offset encoding
Previously, the index & offsets were encoded as 8-character hex strings, however, this limits the maximum value to a `uint32`. This is normally not an issue, however, indices could go over the maximum value of 4 billion over time and the offset could exceed this value for an especially large WAL update. For safety, these encodings have been updated to 16-character hex encodings.
This commit is contained in:
@@ -15,12 +15,12 @@ func TestParseSnapshotPath(t *testing.T) {
|
||||
index int
|
||||
err error
|
||||
}{
|
||||
{"00bc614e.snapshot.lz4", 12345678, nil},
|
||||
{"xxxxxxxx.snapshot.lz4", 0, fmt.Errorf("invalid snapshot path")},
|
||||
{"00bc614.snapshot.lz4", 0, fmt.Errorf("invalid snapshot path")},
|
||||
{"00bc614e.snapshot.lz", 0, fmt.Errorf("invalid snapshot path")},
|
||||
{"00bc614e.snapshot", 0, fmt.Errorf("invalid snapshot path")},
|
||||
{"00bc614e", 0, fmt.Errorf("invalid snapshot path")},
|
||||
{"0000000000bc614e.snapshot.lz4", 12345678, nil},
|
||||
{"xxxxxxxxxxxxxxxx.snapshot.lz4", 0, fmt.Errorf("invalid snapshot path")},
|
||||
{"0000000000bc614.snapshot.lz4", 0, fmt.Errorf("invalid snapshot path")},
|
||||
{"0000000000bc614e.snapshot.lz", 0, fmt.Errorf("invalid snapshot path")},
|
||||
{"0000000000bc614e.snapshot", 0, fmt.Errorf("invalid snapshot path")},
|
||||
{"0000000000bc614e", 0, fmt.Errorf("invalid snapshot path")},
|
||||
{"", 0, fmt.Errorf("invalid snapshot path")},
|
||||
} {
|
||||
t.Run("", func(t *testing.T) {
|
||||
@@ -41,20 +41,22 @@ func TestParseWALSegmentPath(t *testing.T) {
|
||||
offset int64
|
||||
err error
|
||||
}{
|
||||
{"00bc614e/000003e8.wal.lz4", 12345678, 1000, nil},
|
||||
{"00000000/00000000.wal", 0, 0, fmt.Errorf("invalid wal segment path")},
|
||||
{"00000000/00000000", 0, 0, fmt.Errorf("invalid wal segment path")},
|
||||
{"00000000/", 0, 0, fmt.Errorf("invalid wal segment path")},
|
||||
{"00000000", 0, 0, fmt.Errorf("invalid wal segment path")},
|
||||
{"0000000000bc614e/00000000000003e8.wal.lz4", 12345678, 1000, nil},
|
||||
{"0000000000000000/0000000000000000.wal", 0, 0, fmt.Errorf("invalid wal segment path")},
|
||||
{"0000000000000000/0000000000000000", 0, 0, fmt.Errorf("invalid wal segment path")},
|
||||
{"0000000000000000/", 0, 0, fmt.Errorf("invalid wal segment path")},
|
||||
{"0000000000000000", 0, 0, fmt.Errorf("invalid wal segment path")},
|
||||
{"", 0, 0, fmt.Errorf("invalid wal segment path")},
|
||||
} {
|
||||
t.Run("", func(t *testing.T) {
|
||||
index, offset, err := internal.ParseWALSegmentPath(tt.s)
|
||||
if got, want := index, tt.index; got != want {
|
||||
t.Errorf("index=%#v, want %#v", got, want)
|
||||
} else if got, want := offset, tt.offset; got != want {
|
||||
}
|
||||
if got, want := offset, tt.offset; got != want {
|
||||
t.Errorf("offset=%#v, want %#v", got, want)
|
||||
} else if got, want := err, tt.err; !reflect.DeepEqual(got, want) {
|
||||
}
|
||||
if got, want := err, tt.err; !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("err=%#v, want %#v", got, want)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user