在使用gocb的go代码中,我们正在查询返回32k In的视图。然后,我们执行一个大容量查询(参见下面的代码),如CouchBase博客文章中所解释的那样。然而,我们只得到了部分结果。我们可以看到,ruleset, _ := items[i].(*gocb.GetOp).Value.(*RuleSet)只返回第一个2048个ids的值。然后ids 2049-11322不包含值,以此类推。我们的结果如下:
Line 1 Key: 12345678901234567890123456789012, Value: map[0.0.0.0/0:map[jsona:valueofjsona]]
...
Line 2018 Key: 12345678901234567890123456712345, Value: map[0.0.0.0/0:map[jsona:valueofjsona]]
Line 2019 Key: 12345678901234567890123456712345, Value: map[]
...
Line 11323 Key: 12345678901234567890123456712347, Value: map[jsonb:valueofjsonb]](简化了上面的行,键与实际数据不匹配,值也不匹配。)
请求的数据中有很大一部分实际上未被返回:
CB# grep '\[\]' result.out |wc -l
27042
CB# wc -l result.out
31988 rdmp.outbucket.do是否在完成所有查询之前返回?我们查看了API代码,但找不到解释。
知道怎么解决这个问题吗?
type RuleSet struct {
Rules map[string]interface{} "json:\"rules,\""
}
func DiffViaBulkQuery() {
var items []gocb.BulkOp
var row interface{}
var cnt int = 0
bucket := cbase.MyBucket()
// [...]
// add 600k entries to itemsget in a loop like
// itemsGet = append(itemsGet, &gocb.GetOp{Key: key + "_" + strconv.Itoa(i), Value: &Doc{}})
// Perform the bulk operation to Get all documents
err = bucket.Do(itemsGet)
if err != nil {
fmt.Println("ERRROR PERFORMING BULK GET:", err)
}
// Print the output
for i := 0; i < len(itemsGet); i++ {
fmt.Println(itemsGet[i].(*gocb.GetOp).Key, itemsGet[i].(*gocb.GetOp).Value.(*Doc).Item)
}Thx提前,托尔斯滕
发布于 2018-11-29 18:42:24
值得检查您正在执行的每个操作的错误值。您可以通过执行op.Err来做到这一点,例如,这将是
for i := 0; i < len(items); i++ {
fmt.Println(items[i].(*gocb.GetOp).Key, items[i].(*gocb.GetOp).Value.(*Doc).Item, items[i].(*gocb.GetOp).Err)
}我希望您将看到的是,您正在命中queue overflowed错误,这个错误发生在gocb队列中,默认为最大大小为2048项。解决方案通常是在较小的批中执行工作,以便不使gocb过载。在https://forums.couchbase.com/t/bulk-upsert-data-into-couchbase/17354/2上有一个类似的问题
https://stackoverflow.com/questions/53519688
复制相似问题