Skip to content
This repository was archived by the owner on Nov 23, 2018. It is now read-only.
This repository was archived by the owner on Nov 23, 2018. It is now read-only.

cgo error or something else? #21

Description

Hi, I am using oracle times ten database and my code is as follow:

func main() {
        godrv.SetAutoCommit(false)
        db, err := sql.Open("goracle", os.Getenv("ORACLE_DSN"))
        if err != nil {
                log.Println(err)
                os.Exit(1)
        }
        db.SetMaxOpenConns(128)
        db.SetMaxIdleConns(64)
        // 10 go routine insert
        runtime.GOMAXPROCS(4)
        var wg sync.WaitGroup
        log.Println(time.Now())
        var numInsert = 2500
        for i := 0; i < 4; i++ {
                wg.Add(1)
                go func() {
                        tx, err := db.Begin()
                        exit(err)
                        stmt, err := tx.Prepare("INSERT INTO users VALUES(?)")
                        defer stmt.Close()
                        for i := 0; i < numInsert; i++ {
                                _, err = stmt.Exec(time.Now().UnixNano())
                                exit(err)
                        }
                        err = tx.Commit()
                        exit(err)
                        wg.Done()
                }()
        }
        wg.Wait()
        log.Println(time.Now())
}

If I set numInsert to 250, it will not raise any error. But while it's set to 2500 or more, the error is like this:

bc77568c-e472-46e1-b273-407cfa856d6c

a7922410-be36-47cd-b1c1-c8c158961da8

2651f78e-3b56-4424-bae6-7be5d5af9765

19b9d345-5cf9-490f-9e7d-4e5017c351e1

I am not sure if it's due to my misuse of goracle or any other error. I think the code is simple as it is. BTW, if I start more than 4 go routines to insert data into database, it raised the same error which really confused me. Would you help?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions