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

Document test failed when using memdb #1018

Open
JOOHOJANG opened this issue Sep 25, 2024 · 1 comment
Open

Document test failed when using memdb #1018

JOOHOJANG opened this issue Sep 25, 2024 · 1 comment
Labels
bug 🐞 Something isn't working

Comments

@JOOHOJANG
Copy link
Contributor

Description:
I found this TC fails when using memdb, but it passes when using mongoDB. (main branch)
CI cannot detect it because its using mongoDB when testing.

--- FAIL: TestDocumentWithProjects (0.65s)
    --- FAIL: TestDocumentWithProjects/includeSnapshot_test (0.01s)
panic: runtime error: index out of range [0] with length 0 [recovered]
        panic: runtime error: index out of range [0] with length 0

goroutine 4213 [running]:
testing.tRunner.func1.2({0x101ec9e00, 0xc002597f50})
        /opt/homebrew/Cellar/go/1.23.0/libexec/src/testing/testing.go:1632 +0x2c4
testing.tRunner.func1()
        /opt/homebrew/Cellar/go/1.23.0/libexec/src/testing/testing.go:1635 +0x47c
panic({0x101ec9e00?, 0xc002597f50?})
        /opt/homebrew/Cellar/go/1.23.0/libexec/src/runtime/panic.go:785 +0x124
github.com/yorkie-team/yorkie/test/integration.TestDocumentWithProjects.func3(0xc0025a6340)
        /Users/user/Documents/yorkie/test/integration/document_test.go:828 +0x3b8
testing.tRunner(0xc0025a6340, 0xc003903500)
        /opt/homebrew/Cellar/go/1.23.0/libexec/src/testing/testing.go:1690 +0x188
created by testing.(*T).Run in goroutine 4062
        /opt/homebrew/Cellar/go/1.23.0/libexec/src/testing/testing.go:1743 +0x5e4
FAIL    github.com/yorkie-team/yorkie/test/integration  26.292s
FAIL
make: *** [test] Error 1

Why:

@raararaara
Copy link
Contributor

When PageSize is set to 0, MongoDB returns all results. (Official Documentation)

Unlike MongoDB, memDB does not apply any specific logic to set a limit. Currently, the implementation in memDB stops iteration when len(docInfo) is greater than or equal to PageSize.

var docInfos []*database.DocInfo
for raw := iterator.Next(); raw != nil; raw = iterator.Next() {
info := raw.(*database.DocInfo)
if len(docInfos) >= paging.PageSize || info.ProjectID != projectID {
break
}
if info.ID != paging.Offset && info.RemovedAt.IsZero() {
docInfos = append(docInfos, info)
}
}

As a result, no docInfo is returned, which seems to have caused the 'index out of range' issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

3 participants