This repository was archived by the owner on Jan 20, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -231,6 +231,9 @@ func (stream *Stream) Close() error {
231231
232232// open opens the replay log, try to truncate the corrupted tail if there's any
233233func open (dir string , opts * wal.Options ) (* wal.Log , error ) {
234+ if opts == nil {
235+ opts = wal .DefaultOptions
236+ }
234237 rlog , err := wal .Open (dir , opts )
235238 if errors .Is (err , wal .ErrCorrupt ) {
236239 // try to truncate corrupted tail
Original file line number Diff line number Diff line change @@ -158,3 +158,25 @@ func TestAsyncWrite(t *testing.T) {
158158 require .NoError (t , err )
159159 require .Equal (t , uint64 (3 ), lastIndex )
160160}
161+
162+ func TestOpenWithNilOptions (t * testing.T ) {
163+ dir := t .TempDir ()
164+
165+ // Test that open function handles nil options correctly
166+ log , err := open (dir , nil )
167+ require .NoError (t , err )
168+ require .NotNil (t , log )
169+
170+ // Verify the log is functional by checking first and last index
171+ firstIndex , err := log .FirstIndex ()
172+ require .NoError (t , err )
173+ require .Equal (t , uint64 (0 ), firstIndex )
174+
175+ lastIndex , err := log .LastIndex ()
176+ require .NoError (t , err )
177+ require .Equal (t , uint64 (0 ), lastIndex )
178+
179+ // Clean up
180+ err = log .Close ()
181+ require .NoError (t , err )
182+ }
Original file line number Diff line number Diff line change @@ -18,7 +18,10 @@ func LogPath(dir string) string {
1818
1919// GetLastIndex returns the last written index of the replay log
2020func GetLastIndex (dir string ) (index uint64 , err error ) {
21- rlog , err := open (dir , nil )
21+ rlog , err := open (dir , & wal.Options {
22+ NoSync : true ,
23+ NoCopy : true ,
24+ })
2225 if err != nil {
2326 return 0 , err
2427 }
You can’t perform that action at this time.
0 commit comments