ostafen / clover

A lightweight document-oriented NoSQL database written in pure Golang.
MIT License
677 stars 54 forks source link

Getting error when during bulk insert #111

Closed jcsco closed 1 year ago

jcsco commented 1 year ago

I'm trying to load documents from JSON. I wrote the following code.

    docs := make([]*clover.Document, 0)
    for _, doc := range jsonObjects {
        docs = append(docs, clover.NewDocumentOf(*doc))
    }

    err = db.Insert(collection, docs...)
    if err != nil {
        log.Printf("Insert error: %s\n", err.Error())
        return errors.New("Write error")
    }

I got the following error back and it seems it's coming from badger DB. https://github.com/dgraph-io/badger/issues/441

Txn is too big to fit into one request

They suggest using the WriteBatch API (https://github.com/dgraph-io/badger/issues/1242#issuecomment-595113199). Also, this seems to have been improved in newer versions of badger DB so updating the version used in clover could work.

ostafen commented 1 year ago

Can you send a PR?

jcsco commented 1 year ago

Sure will take it up

ostafen commented 1 year ago

Great, thank you