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

问题,最后导致链接占满,超时,必须重启程序 #21

Closed
dingyangfan opened this issue Jul 3, 2016 · 2 comments
Closed

Comments

@dingyangfan
Copy link

ssdbPool, err = gossdb.NewPool(&gossdb.Config{
Host: ssdb_addr[0],
Port: port,
MinPoolSize: 5,
MaxPoolSize: 200,
AcquireIncrement: 5,

})

//导入代码部份
conn, err := ssdbPool.NewClient()
if err != nil {
log.Println("myg ssdb:", err.Error())
return
}
defer conn.Close()
_, err = conn.Qpush_front("visit", testvisit)

是 不是写的有问题,不是的话,就有问题了,导致最后程序无法链接。

@seefan
Copy link
Owner

seefan commented Jul 6, 2016

我在爬虫里试过,是可以的,请检查一下你的程序部分,协程是否都及时关闭了,看你给出的代码是没有问题。可以打印日志看一下。

也可以用下面的代码测试一下

package main

import (
    "log"
    "time"

    "github.com/seefan/gossdb/ssdb"
)

func main() {
    if err := ssdb.Start(); err != nil {
        log.Printf("ssdb连接错误", err)
        return
    }

    for i := 0; i < 10000; i++ {
        c, err := ssdb.Client()

        if err != nil {
            log.Printf("error %s", err.Error())
            break
        }
        c.Qpush_front("test", 1)

        time.Sleep(time.Microsecond)
        c.Close()
        log.Println(i)
    }
}

@DavidGSX
Copy link

the problem is solved at the following merge, you can test it again.
Merge pull request #23 from DavidGSX/master

@seefan seefan closed this as completed Dec 26, 2016
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

No branches or pull requests

3 participants