Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Panic when append entry to ReadWriteSegment #619

Closed
lsytj0413 opened this issue Feb 25, 2025 · 0 comments · Fixed by #627
Closed

Bug: Panic when append entry to ReadWriteSegment #619

lsytj0413 opened this issue Feb 25, 2025 · 0 comments · Fixed by #627

Comments

@lsytj0413
Copy link
Contributor

lsytj0413 commented Feb 25, 2025

Example code:

func TestSegmentAppendPanic(t *testing.T) {
	basePath := t.TempDir()
	rw, err := newReadWriteSegment(basePath, 0, 1024, 0, nil)
	assert.NoError(t, err)
	for i := int64(0); i < 100; i++ {
		err := rw.Append(i, fmt.Appendf(nil, "entry-%d", i))
		assert.NoError(t, err)
	}
}

will panic with:

panic: runtime error: slice bounds out of range [1030:1024] [recovered]
	panic: runtime error: slice bounds out of range [1030:1024]

goroutine 8 [running]:
testing.tRunner.func1.2({0x105424720, 0x14000034930})
	/Users/bytedance/.gvm/gos/go1.23.5/src/testing/testing.go:1632 +0x3c8
testing.tRunner.func1()
	/Users/bytedance/.gvm/gos/go1.23.5/src/testing/testing.go:1635 +0x6f8
panic({0x105424720?, 0x14000034930?})
	/Users/bytedance/.gvm/gos/go1.23.5/src/runtime/panic.go:785 +0x124
github.com/streamnative/oxia/server/wal/codec.(*V2).WriteRecord(0x1059de920, {0x105dfc000, 0x400, 0x400}, 0x406, 0x4c6ae8db, {0x14000292560, 0x8, 0x8})
	/Users/bytedance/workspace/github.com/streamnative/oxia/server/wal/codec/v2.go:145 +0x548
github.com/streamnative/oxia/server/wal.(*readWriteSegment).Append(0x140001ec160, 0x34, {0x14000292560, 0x8, 0x8})
	/Users/bytedance/workspace/github.com/streamnative/oxia/server/wal/wal_rw_segment.go:163 +0x1c8

We should not panic even if the segment cann't accept entry exceeded it's size.

merlimat added a commit that referenced this issue Feb 27, 2025
…ot panic (#627)

Fix: #619

---------

Co-authored-by: Matteo Merli <mmerli@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant