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

batch-size error when using embbeded ferretdb package #4235

Closed
tbnguyen1407 opened this issue Apr 15, 2024 · 1 comment · Fixed by #4278
Closed

batch-size error when using embbeded ferretdb package #4235

tbnguyen1407 opened this issue Apr 15, 2024 · 1 comment · Fixed by #4278
Assignees
Labels
code/bug Some user-visible feature works incorrectly
Milestone

Comments

@tbnguyen1407
Copy link

tbnguyen1407 commented Apr 15, 2024

We should set that field for the embeddable package there:

TestOpts: registry.TestOpts{
CappedCleanupPercentage: 10, // handler expects it to be a non-zero value
},


FerretDB version

0.21.0

Backend

SQLite

Environment

  • OS: Windows 11
  • Deployment: Embbeded
  • Deployment details:

What did you do?

Insert document

package main

import (
	"context"
	"log"

	"github.com/FerretDB/FerretDB/ferretdb"
	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/mongo"
	"go.mongodb.org/mongo-driver/mongo/options"
)

func main() {
	// start server
	f, err := ferretdb.New(&ferretdb.Config{
		Listener: ferretdb.ListenerConfig{
			TCP: "127.0.0.1:0",
		},
		Handler:   "sqlite",
		SQLiteURL: "file:./?mode=memory",
	})
	if err != nil {
		log.Fatal(err)
	}

	ctx, cancel := context.WithCancel(context.Background())

	done := make(chan struct{})

	go func() {
		log.Print(f.Run(ctx))
		close(done)
	}()

	uri := f.MongoDBURI()

	// start client
	mongoCli, _ := mongo.Connect(ctx, options.Client().ApplyURI(uri))
	_, e := mongoCli.Database("test").Collection("test").InsertOne(context.TODO(), bson.M{"abc": "def"})
	if e != nil {
		log.Print(e)
	}
	cancel()
	<-done
}

What did you expect to see?

No error

What did you see instead?

2024-04-15T15:59:25.084+0800    DPANIC  // 127.0.0.1:52039 -> 127.0.0.1:52037   clientconn/conn.go:170  batch-size should be greater or equal to 1
(err = <nil>)
github.com/FerretDB/FerretDB/internal/clientconn.(*conn).run.func3
        C:/Users/ben/go/pkg/mod/github.com/!ferret!d!b/!ferret!d!b@v1.21.0/internal/clientconn/conn.go:170
runtime.gopanic
        C:/Users/ben/scoop/apps/go/current/src/runtime/panic.go:770
github.com/FerretDB/FerretDB/internal/backends/sqlite.(*collection).InsertAll.func1
        C:/Users/ben/go/pkg/mod/github.com/!ferret!d!b/!ferret!d!b@v1.21.0/internal/backends/sqlite/collection.go:114
github.com/FerretDB/FerretDB/internal/util/fsql.(*DB).InTransaction
        C:/Users/ben/go/pkg/mod/github.com/!ferret!d!b/!ferret!d!b@v1.21.0/internal/util/fsql/db.go:172
github.com/FerretDB/FerretDB/internal/backends/sqlite.(*collection).InsertAll
        C:/Users/ben/go/pkg/mod/github.com/!ferret!d!b/!ferret!d!b@v1.21.0/internal/backends/sqlite/collection.go:111
github.com/FerretDB/FerretDB/internal/backends.(*collectionContract).InsertAll
        C:/Users/ben/go/pkg/mod/github.com/!ferret!d!b/!ferret!d!b@v1.21.0/internal/backends/collection.go:202
github.com/FerretDB/FerretDB/internal/backends/decorators/oplog.(*collection).InsertAll
        C:/Users/ben/go/pkg/mod/github.com/!ferret!d!b/!ferret!d!b@v1.21.0/internal/backends/decorators/oplog/collection.go:64
github.com/FerretDB/FerretDB/internal/handler.(*Handler).MsgInsert
        C:/Users/ben/go/pkg/mod/github.com/!ferret!d!b/!ferret!d!b@v1.21.0/internal/handler/msg_insert.go:145
github.com/FerretDB/FerretDB/internal/handler.(*Handler).initCommands.(*Handler).authenticateWrapper.func1
        C:/Users/ben/go/pkg/mod/github.com/!ferret!d!b/!ferret!d!b@v1.21.0/internal/handler/commands.go:304
github.com/FerretDB/FerretDB/internal/clientconn.(*conn).handleOpMsg
        C:/Users/ben/go/pkg/mod/github.com/!ferret!d!b/!ferret!d!b@v1.21.0/internal/clientconn/conn.go:575
github.com/FerretDB/FerretDB/internal/clientconn.(*conn).route
        C:/Users/ben/go/pkg/mod/github.com/!ferret!d!b/!ferret!d!b@v1.21.0/internal/clientconn/conn.go:432
github.com/FerretDB/FerretDB/internal/clientconn.(*conn).run
        C:/Users/ben/go/pkg/mod/github.com/!ferret!d!b/!ferret!d!b@v1.21.0/internal/clientconn/conn.go:316
github.com/FerretDB/FerretDB/internal/clientconn.acceptLoop.func1
        C:/Users/ben/go/pkg/mod/github.com/!ferret!d!b/!ferret!d!b@v1.21.0/internal/clientconn/listener.go:305

Additional

0.20.1 does not have such error.

@tbnguyen1407 tbnguyen1407 added code/bug Some user-visible feature works incorrectly not ready Issues that are not ready to be worked on; PRs that should skip CI labels Apr 15, 2024
@AlekSi AlekSi added this to the v1.22.0 milestone Apr 15, 2024
@AlekSi AlekSi removed the not ready Issues that are not ready to be worked on; PRs that should skip CI label Apr 15, 2024
@AlekSi
Copy link
Member

AlekSi commented Apr 15, 2024

@tbnguyen1407 Want to send a PR with a fix that just sets that field there?

TestOpts: registry.TestOpts{
CappedCleanupPercentage: 10, // handler expects it to be a non-zero value
},

@AlekSi AlekSi added the good first issue Good issues for new external contributors label Apr 15, 2024
@noisersup noisersup self-assigned this May 8, 2024
@AlekSi AlekSi removed the good first issue Good issues for new external contributors label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code/bug Some user-visible feature works incorrectly
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants