toni-moreno / syncflux

SyncFlux is an Open Source InfluxDB Data synchronization and replication tool for migration purposes or HA clusters
MIT License
154 stars 34 forks source link

panic index out of range when execute the function agent.GetFields #48

Open fcddk opened 3 years ago

fcddk commented 3 years ago

log:

time="2020-11-10 06:34:45" level=debug msg="discovered measurement &{\x18.�\x1b\x00\v� map[]} on DB: prometheus-RP:autogen" time="2020-11-10 06:34:45" level=debug msg="get fields query[show field keys from \"\x18.�\x1b\x00\v�\"],db[prometheus],meas[\x18.�\x1b\x00\v�]" time="2020-11-10 06:34:45" level=debug msg="get fields from meas[\x18.�\x1b\x00\v�], response:[[]]" panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]: github.com/toni-moreno/syncflux/pkg/agent.GetFields(0xbee080, 0xc00038aa90, 0xc00039a870, 0xa, 0xc00012c890, 0xb, 0xc00002f9a7, 0x7, 0xc0002ae000) /home/golang/src/github.com/toni-moreno/syncflux/pkg/agent/client.go:256 +0x8fc github.com/toni-moreno/syncflux/pkg/agent.(*HACluster).GetSchema(0xc000120f70, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xb58088, 0xc0001cdd60, ...) /home/golang/src/github.com/toni-moreno/syncflux/pkg/agent/hacluster.go:147 +0x8ea github.com/toni-moreno/syncflux/pkg/agent.HAMonitorStart(0xc00012c2a0, 0xa, 0xc00012c380, 0xa) /home/golang/src/github.com/toni-moreno/syncflux/pkg/agent/agent.go:247 +0x9b main.main() /home/golang/src/github.com/toni-moreno/syncflux/pkg/main.go:296 +0x53b

fcddk commented 3 years ago

code: pkg/agent/client.go if len(res[0].Series) == 0 {
log.Warnf("The response for Query is null, get Fields from DB %s Measurement %s error!\n", sdb, meas)
} else {

    values := res[0].Series[0].Values   
    //show progress of getting measurements 
    for _, row := range values {    
        fieldname := row[0].(string)    
        fieldtype := row[1].(string)    
        fields[fieldname] = &FieldSch{Name: fieldname, Type: fieldtype} 
        log.Debugf("Detected Field [%s] type [%s] on measurement [%s]", fieldname, fieldtype, meas) 
    }           }

}       }

return fields       return fields

}

toni-moreno commented 3 years ago

Hello @fcddk What version of influxdb are you trying to copy?

fcddk commented 3 years ago

influxdb version: 1.8.3