I have 2 different servers for example (Server 1 , Server 2), In the first server I have golang app which splits files and sending to second server which should save in mongodb via mgo.v2
Server 1:
func mainHandle(rw http.ResponseWriter, rq *http.Request) {
fileToBeChunked := "/Users/IT/Desktop/4k.jpg"
file, err := os.Open(fileToBeChunked)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
defer file.Close()
fileInfo, _ := file.Stat()
var fileSize int64 = fileInfo.Size()
const fileChunk = 0.25 * (1 << 20) // 1 MB, change this to your requirement
// calculate total number of parts the file will be chunked into
totalPartsNum := uint64(math.Ceil(float64(fileSize) / float64(fileChunk)))
fmt.Printf("Splitting to %d pieces.\n", totalPartsNum)
var sent int
prev_part := 0
for i := uint64(0); i < totalPartsNum; i++ {
partSize := int(math.Min(fileChunk, float64(fileSize-int64(i*fileChunk))))
sent = sent + partSize
partBuffer := make([]byte, partSize)
//fileBuffer := make([]byte, fileSize)
//fmt.Printf("File size is %d \n",fileBuffer)
fmt.Printf("Part size is %d \n",partSize)
file.Read(partBuffer)
client := &http.Client{}
req, _ := http.NewRequest("PUT", "http://localhost:8011/upload/23", bytes.NewReader(partBuffer))
req.Header.Set("Content-Range", "bytes "+strconv.Itoa(prev_part) + "-"+strconv.Itoa(sent-1)+"/"+strconv.FormatInt(fileSize,10))
req.Header.Set("Content-Length", strconv.Itoa(partSize))
res, _ := client.Do(req)
prev_part = sent
fmt.Println(res)
}
}
Server 2
func UploadFileChunk(rw http.ResponseWriter,rq *http.Request) {
fmt.Println(rq.Header["Content-Range"])
cnt_range:=rq.Header["Content-Range"]
file:=createFileByName("asd")
if(checkFileChunkIndex(cnt_range[0])) {
buf, err := ioutil.ReadAll(rq.Body)
if err!=nil {log.Fatal("request",err)}
file.Write(buf)
} else {
file.Close()
}
}
func checkFileChunkIndex(cnt_r string ) bool {
re := regexp.MustCompile(`([a-z]+) ([[:alnum:]]+)-([[:alnum:]]+)/([[:alnum:]]+)`)
component:= re.FindStringSubmatch(cnt_r)
filesize,_:= strconv.Atoi(component[4])
last_chunk,_:= strconv.Atoi(component[3])
return filesize - last_chunk - 1 > 0
}
func createFileByName(fname string ) *mgo.GridFile {
if(!file_created) {
_File,err:= db.GridFS("fs").Create("112233")
File = *_File
if err != nil {
panic(err)
}
file_created = true
return &File
}
return &File
}
For testing I have send a file with size 4mb, but after 3rd request , as a response I have got the following error
fatal error: sync: unlock of unlocked mutex
Here is the full error response
fatal error: sync: unlock of unlocked mutex
goroutine 7 [running]:
runtime.throw(0x144de3d, 0x1e)
/usr/local/go/src/runtime/panic.go:596 +0x95 fp=0xc42004b8c0 sp=0xc42004b8a0
sync.throw(0x144de3d, 0x1e)
/usr/local/go/src/runtime/panic.go:585 +0x35 fp=0xc42004b8e0 sp=0xc42004b8c0
sync.(*Mutex).Unlock(0xc4200ca8c0)
/usr/local/go/src/sync/mutex.go:113 +0xa4 fp=0xc42004b908 sp=0xc42004b8e0
sync.(*Cond).Wait(0x162c4e8)
/usr/local/go/src/sync/cond.go:56 +0x6c fp=0xc42004b938 sp=0xc42004b908
gopkg.in/mgo%2ev2.(*GridFile).insertChunk(0x162c4e0, 0xc42018a000, 0x3fc00, 0x40000)
/Users/IT/go/src/gopkg.in/mgo.v2/gridfs.go:623 +0x1b3 fp=0xc42004ba48 sp=0xc42004b938
gopkg.in/mgo%2ev2.(*GridFile).Write(0x162c4e0, 0xc420678000, 0x40000, 0x7fe00, 0x40000, 0x0, 0x0)
/Users/IT/go/src/gopkg.in/mgo.v2/gridfs.go:595 +0x2d6 fp=0xc42004baf0 sp=0xc42004ba48
go_storage/files.UploadFileChunk(0x15faf80, 0xc4202e4380, 0xc42000b000)
/Users/IT/go/src/go_storage/files/files.go:249 +0x23b fp=0xc42004bba8 sp=0xc42004baf0
net/http.HandlerFunc.ServeHTTP(0x1459710, 0x15faf80, 0xc4202e4380, 0xc42000b000)
/usr/local/go/src/net/http/server.go:1942 +0x44 fp=0xc42004bbd0 sp=0xc42004bba8
github.com/gorilla/mux.(*Router).ServeHTTP(0xc42001a320, 0x15faf80, 0xc4202e4380, 0xc42000b000)
/Users/IT/go/src/github.com/gorilla/mux/mux.go:114 +0x10c fp=0xc42004bcd0 sp=0xc42004bbd0
net/http.(*ServeMux).ServeHTTP(0x162bee0, 0x15faf80, 0xc4202e4380, 0xc42000ae00)
/usr/local/go/src/net/http/server.go:2238 +0x130 fp=0xc42004bd10 sp=0xc42004bcd0
net/http.serverHandler.ServeHTTP(0xc420096dc0, 0x15faf80, 0xc4202e4380, 0xc42000ae00)
/usr/local/go/src/net/http/server.go:2568 +0x92 fp=0xc42004bd58 sp=0xc42004bd10
net/http.(*conn).serve(0xc4200cd2c0, 0x15fb7c0, 0xc420016ac0)
/usr/local/go/src/net/http/server.go:1825 +0x612 fp=0xc42004bfc8 sp=0xc42004bd58
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc42004bfd0 sp=0xc42004bfc8
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2668 +0x2ce
goroutine 1 [IO wait]:
net.runtime_pollWait(0x23a0e40, 0x72, 0x0)
/usr/local/go/src/runtime/netpoll.go:164 +0x59
net.(*pollDesc).wait(0xc4200556b8, 0x72, 0x0, 0xc4200bcee0)
/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
net.(*pollDesc).waitRead(0xc4200556b8, 0xffffffffffffffff, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
net.(*netFD).accept(0xc420055650, 0x0, 0x15f6ec0, 0xc4200bcee0)
/usr/local/go/src/net/fd_unix.go:430 +0x1e5
net.(*TCPListener).accept(0xc42000e0a0, 0xc4200cd340, 0x13c96c0, 0xffffffffffffffff)
/usr/local/go/src/net/tcpsock_posix.go:136 +0x2e
net.(*TCPListener).AcceptTCP(0xc42000e0a0, 0xc420049df0, 0xc420049df8, 0xc420049de8)
/usr/local/go/src/net/tcpsock.go:215 +0x49
net/http.tcpKeepAliveListener.Accept(0xc42000e0a0, 0x1459ca8, 0xc4200cd2c0, 0x15fb880, 0xc420019c80)
/usr/local/go/src/net/http/server.go:3044 +0x2f
net/http.(*Server).Serve(0xc420096dc0, 0x15fb280, 0xc42000e0a0, 0x0, 0x0)
/usr/local/go/src/net/http/server.go:2643 +0x228
net/http.(*Server).ListenAndServe(0xc420096dc0, 0xc420096dc0, 0x15f60c0)
/usr/local/go/src/net/http/server.go:2585 +0xb0
net/http.ListenAndServe(0x143fbf7, 0x5, 0x0, 0x0, 0xc420110360, 0xc420019230)
/usr/local/go/src/net/http/server.go:2787 +0x7f
main.main()
/Users/IT/go/src/go_storage/main.go:24 +0x358
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:2197 +0x1
goroutine 5 [select]:
gopkg.in/mgo%2ev2.(*mongoCluster).syncServersLoop(0xc42000a800)
/Users/IT/go/src/gopkg.in/mgo.v2/cluster.go:394 +0x3a3
created by gopkg.in/mgo%2ev2.newCluster
/Users/IT/go/src/gopkg.in/mgo.v2/cluster.go:78 +0x188
goroutine 22 [semacquire]:
sync.runtime_SemacquireMutex(0xc4200f20e4)
/usr/local/go/src/runtime/sema.go:62 +0x34
sync.(*Mutex).Lock(0xc4200f20e0)
/usr/local/go/src/sync/mutex.go:87 +0x9d
gopkg.in/mgo%2ev2.(*mongoSocket).Acquire(0xc4200f20e0, 0x0)
/Users/IT/go/src/gopkg.in/mgo.v2/socket.go:242 +0x31
gopkg.in/mgo%2ev2.(*Session).acquireSocket(0xc4200e04e0, 0x0, 0x0, 0x0, 0x0)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:4419 +0x475
gopkg.in/mgo%2ev2.(*Collection).writeOp(0xc420019f20, 0x139efa0, 0xc4200e8000, 0x100e501, 0x0, 0x0, 0x0)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:4603 +0xd6
gopkg.in/mgo%2ev2.(*Collection).Insert(0xc420019f20, 0xc420010070, 0x1, 0x1, 0x0, 0x0)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:2437 +0xac
gopkg.in/mgo%2ev2.(*GridFile).insertChunk.func1(0x162c4e0, 0xc42033c000, 0x3fc3e, 0x40000)
/Users/IT/go/src/gopkg.in/mgo.v2/gridfs.go:642 +0xe8
created by gopkg.in/mgo%2ev2.(*GridFile).insertChunk
/Users/IT/go/src/gopkg.in/mgo.v2/gridfs.go:650 +0x460
goroutine 19 [sleep]:
time.Sleep(0x37e11d600)
/usr/local/go/src/runtime/time.go:59 +0xf9
gopkg.in/mgo%2ev2.(*mongoServer).pinger(0xc4200f2000, 0x1)
/Users/IT/go/src/gopkg.in/mgo.v2/server.go:301 +0x293
created by gopkg.in/mgo%2ev2.newServer
/Users/IT/go/src/gopkg.in/mgo.v2/server.go:89 +0x166
goroutine 21 [semacquire]:
sync.runtime_SemacquireMutex(0xc4200f20e4)
/usr/local/go/src/runtime/sema.go:62 +0x34
sync.(*Mutex).Lock(0xc4200f20e0)
/usr/local/go/src/sync/mutex.go:87 +0x9d
gopkg.in/mgo%2ev2.(*mongoSocket).readLoop(0xc4200f20e0)
/Users/IT/go/src/gopkg.in/mgo.v2/socket.go:582 +0x40a
created by gopkg.in/mgo%2ev2.newSocket
/Users/IT/go/src/gopkg.in/mgo.v2/socket.go:194 +0x259
goroutine 9 [semacquire]:
sync.runtime_SemacquireMutex(0xc4202d2044)
/usr/local/go/src/runtime/sema.go:62 +0x34
sync.(*Mutex).Lock(0xc4202d2040)
/usr/local/go/src/sync/mutex.go:87 +0x9d
gopkg.in/mgo%2ev2.(*mongoSocket).SimpleQuery(0xc4200f20e0, 0xc4202e4000, 0x6, 0x143fbe3, 0x5, 0xc4202d2031, 0xb)
/Users/IT/go/src/gopkg.in/mgo.v2/socket.go:367 +0x28b
gopkg.in/mgo%2ev2.(*Database).run(0xc4200bc8e0, 0xc4200f20e0, 0x13d0f00, 0xc4202d4040, 0x13cbb00, 0xc4202e2000, 0xc4200f2000, 0xc4200f20e0)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:3261 +0x1b3
gopkg.in/mgo%2ev2.(*Collection).writeOpCommand(0xc420019f20, 0xc4200f20e0, 0xc4200e2000, 0x139efa0, 0xc4202d6000, 0x1010001, 0x23685a8, 0x0, 0x100c420028638)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:4786 +0x1db
gopkg.in/mgo%2ev2.(*Collection).writeOp(0xc420019f20, 0x139efa0, 0xc4202d6000, 0x100e501, 0x0, 0x0, 0x0)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:4645 +0x6dc
gopkg.in/mgo%2ev2.(*Collection).Insert(0xc420019f20, 0xc4202d2000, 0x1, 0x1, 0x0, 0x0)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:2437 +0xac
gopkg.in/mgo%2ev2.(*GridFile).insertChunk.func1(0x162c4e0, 0xc420290000, 0x3fc3e, 0x40000)
/Users/IT/go/src/gopkg.in/mgo.v2/gridfs.go:642 +0xe8
created by gopkg.in/mgo%2ev2.(*GridFile).insertChunk
/Users/IT/go/src/gopkg.in/mgo.v2/gridfs.go:650 +0x460
goroutine 12 [semacquire]:
sync.runtime_SemacquireMutex(0xc4200e6074)
/usr/local/go/src/runtime/sema.go:62 +0x34
sync.(*Mutex).Lock(0xc4200e6070)
/usr/local/go/src/sync/mutex.go:87 +0x9d
gopkg.in/mgo%2ev2.(*mongoSocket).SimpleQuery(0xc4200f20e0, 0xc4202e40e0, 0x6, 0x143fbe3, 0x5, 0xc4200e6060, 0xb)
/Users/IT/go/src/gopkg.in/mgo.v2/socket.go:367 +0x28b
gopkg.in/mgo%2ev2.(*Database).run(0xc4200bc8e0, 0xc4200f20e0, 0x13d0f00, 0xc4200ee080, 0x13cbb00, 0xc4202e2060, 0x2, 0xc42005e400)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:3261 +0x1b3
gopkg.in/mgo%2ev2.(*Collection).writeOpCommand(0xc420019f20, 0xc4200f20e0, 0xc4200e2000, 0x139efa0, 0xc420018d20, 0x1010001, 0x2304558, 0x46, 0x8700c420023638)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:4786 +0x1db
gopkg.in/mgo%2ev2.(*Collection).writeOp(0xc420019f20, 0x139efa0, 0xc420018d20, 0x100e501, 0x0, 0x0, 0x0)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:4645 +0x6dc
gopkg.in/mgo%2ev2.(*Collection).Insert(0xc420019f20, 0xc420010060, 0x1, 0x1, 0x0, 0x0)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:2437 +0xac
gopkg.in/mgo%2ev2.(*GridFile).insertChunk.func1(0x162c4e0, 0xc42013a000, 0x3fc3e, 0x40000)
/Users/IT/go/src/gopkg.in/mgo.v2/gridfs.go:642 +0xe8
created by gopkg.in/mgo%2ev2.(*GridFile).insertChunk
/Users/IT/go/src/gopkg.in/mgo.v2/gridfs.go:650 +0x460
goroutine 38 [IO wait]:
net.runtime_pollWait(0x23a0f00, 0x77, 0x4)
/usr/local/go/src/runtime/netpoll.go:164 +0x59
net.(*pollDesc).wait(0xc4200fa068, 0x77, 0x15f84c0, 0x15f4540)
/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
net.(*pollDesc).waitWrite(0xc4200fa068, 0xc420392ef2, 0x2edd1)
/usr/local/go/src/net/fd_poll_runtime.go:84 +0x34
net.(*netFD).Write(0xc4200fa000, 0xc420382000, 0x3fcc3, 0x40000, 0x10ef2, 0x15f84c0, 0x15f4540)
/usr/local/go/src/net/fd_unix.go:340 +0x34d
net.(*conn).Write(0xc4200ea008, 0xc420382000, 0x3fcc3, 0x40000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:193 +0x70
gopkg.in/mgo%2ev2.(*mongoSocket).Query(0xc4200f20e0, 0xc420181878, 0x1, 0x1, 0x0, 0x2)
/Users/IT/go/src/gopkg.in/mgo.v2/socket.go:525 +0x2ad1
gopkg.in/mgo%2ev2.(*mongoSocket).SimpleQuery(0xc4200f20e0, 0xc4200f21c0, 0x6, 0x143fbe3, 0x5, 0xc420010631, 0xb)
/Users/IT/go/src/gopkg.in/mgo.v2/socket.go:363 +0x22a
gopkg.in/mgo%2ev2.(*Database).run(0xc4200bc8e0, 0xc4200f20e0, 0x13d0f00, 0xc4202d4140, 0x13cbb00, 0xc4200f6000, 0x1444391, 0xc42002a800)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:3261 +0x1b3
gopkg.in/mgo%2ev2.(*Collection).writeOpCommand(0xc420019f20, 0xc4200f20e0, 0xc4200e2000, 0x139efa0, 0xc4200e8000, 0x1010001, 0x2306a28, 0x0, 0x800c4204a3e38)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:4786 +0x1db
gopkg.in/mgo%2ev2.(*Collection).writeOp(0xc420019f20, 0x139efa0, 0xc4200e8000, 0xc4200e6001, 0x0, 0x0, 0x0)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:4645 +0x6dc
gopkg.in/mgo%2ev2.(*Collection).Insert(0xc420019f20, 0xc4200e6000, 0x1, 0x1, 0x0, 0x0)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:2437 +0xac
gopkg.in/mgo%2ev2.(*GridFile).insertChunk.func1(0x162c4e0, 0xc4204d8000, 0x3fc3e, 0x40000)
/Users/IT/go/src/gopkg.in/mgo.v2/gridfs.go:642 +0xe8
created by gopkg.in/mgo%2ev2.(*GridFile).insertChunk
/Users/IT/go/src/gopkg.in/mgo.v2/gridfs.go:650 +0x460
goroutine 24 [semacquire]:
sync.runtime_SemacquireMutex(0xc4200f20e4)
/usr/local/go/src/runtime/sema.go:62 +0x34
sync.(*Mutex).Lock(0xc4200f20e0)
/usr/local/go/src/sync/mutex.go:87 +0x9d
gopkg.in/mgo%2ev2.(*mongoSocket).Acquire(0xc4200f20e0, 0x0)
/Users/IT/go/src/gopkg.in/mgo.v2/socket.go:242 +0x31
gopkg.in/mgo%2ev2.(*Session).acquireSocket(0xc4200e04e0, 0x0, 0x0, 0x0, 0x0)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:4419 +0x475
gopkg.in/mgo%2ev2.(*Collection).writeOp(0xc420019f20, 0x139efa0, 0xc4202d6000, 0x100e501, 0x0, 0x0, 0x0)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:4603 +0xd6
gopkg.in/mgo%2ev2.(*Collection).Insert(0xc420019f20, 0xc4202d2010, 0x1, 0x1, 0x0, 0x0)
/Users/IT/go/src/gopkg.in/mgo.v2/session.go:2437 +0xac
gopkg.in/mgo%2ev2.(*GridFile).insertChunk.func1(0x162c4e0, 0xc4205f8000, 0x3fc3e, 0x40000)
/Users/IT/go/src/gopkg.in/mgo.v2/gridfs.go:642 +0xe8
created by gopkg.in/mgo%2ev2.(*GridFile).insertChunk
/Users/IT/go/src/gopkg.in/mgo.v2/gridfs.go:650 +0x460
goroutine 14 [IO wait]:
net.runtime_pollWait(0x23a0d80, 0x72, 0x7)
/usr/local/go/src/runtime/netpoll.go:164 +0x59
net.(*pollDesc).wait(0xc420055728, 0x72, 0x15f84c0, 0x15f4540)
/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
net.(*pollDesc).waitRead(0xc420055728, 0xc420016b11, 0x1)
/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
net.(*netFD).Read(0xc4200556c0, 0xc420016b11, 0x1, 0x1, 0x0, 0x15f84c0, 0x15f4540)
/usr/local/go/src/net/fd_unix.go:250 +0x1b7
net.(*conn).Read(0xc42000e0a8, 0xc420016b11, 0x1, 0x1, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:181 +0x70
net/http.(*connReader).backgroundRead(0xc420016b00)
/usr/local/go/src/net/http/server.go:656 +0x58
created by net/http.(*connReader).startBackgroundRead
/usr/local/go/src/net/http/server.go:652 +0xdf
Process finished with exit code 2
I have found that in the write function there is a code look like this
file.assertMode(gfsWriting)
file.m.Lock()
debugf("GridFile %p: writing %d bytes", file, len(data))
defer file.m.Unlock()
if file.err != nil {
return 0, file.err
}
You are making a copy of the GridFile returned by GridFS.Create for no reason. Don't copy the struct, just return the pointer you are given.
GridFile contains private fields which cannot be copied, like a sync.Mutex and a sync.Cond. Running go vet on your code should catch these errors for you.
Related
I'm currently writing a REST API in Golang but I'm getting an error when making a GET request to an endpoint that then retrieves data from a Postgres database table.
Specifically, this error is in relation to parsing a postgres array to a golang slice.
The error is as follows:
sql: Scan error on column index 8, name "image_paths": pq: parsing array element index 0: pq: scanning to data.Image is not implemented; only sql.Scanner
This is the database with one entry (the relevant column is highlighted):
The relevant code is as follows:
func (s SpaceDetailsModel) GetForUser(filters Filters, id int64) ([]*SpaceDetails, Metadata, error) {
if id < 1 {
return nil, Metadata{}, ErrRecordNotFound
}
query := `
SELECT count(*) OVER(), id, created_At, space_owner_id, location_text, post_code, longitude, latitude, image_paths, space_description, booking_count, number_of_reviews, average_rating, version
FROM spaces
WHERE space_owner_id = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3`
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
args := []interface{}{id, filters.limit(), filters.offset()}
rows, err := s.DB.QueryContext(ctx, query, args...)
if err != nil {
return nil, Metadata{}, err
}
defer rows.Close()
totalRecords := 0
spaces := []*SpaceDetails{}
for rows.Next() {
var space SpaceDetails
err := rows.Scan(
&totalRecords,
&space.ID,
&space.CreatedAt,
&space.SpaceOwnerId,
&space.LocationText,
&space.PostCode,
&space.Coordinates.Longitude,
&space.Coordinates.Latitude,
pq.Array(&space.Images),
&space.SpaceDescription,
&space.BookingCount,
&space.NumberOfReviews,
&space.AverageRating,
&space.Version,
)
if err != nil {
return nil, Metadata{}, err
}
spaces = append(spaces, &space)
}
if err = rows.Err(); err != nil {
return nil, Metadata{}, err
}
metadata := calculateMetadata(totalRecords, filters.Page, filters.PageSize)
return spaces, metadata, nil
}
The stack trace is:
PS C:\Users\bcart\OneDrive\Desktop\Project\Project Z\Code\Parkit>
go run ./cmd/api
{"level":"INFO","time":"2022-07-28T13:40:14Z","message":"database connection pool established"}
{"level":"INFO","time":"2022-07-28T13:40:14Z","message":"starting server","properties":{"addr":":4000","env":"development"}}
{"level":"ERROR","time":"2022-07-28T13:40:19Z","message":"sql: Scan error on column index 8, name \"image_paths\": pq: parsing array element index 0: pq: scanning to data.Image is not implemented; only sql.Scanner","properties":{"request_method":"POST","request_url":"/api/v1/days_bookings_record"},"trace":"goroutine 22 [running]:\nruntime/debug.Stack(0x31011630, 0xeda7488c3, 0x0)\n\tC:/Program Files/Go/src/runtime/debug/stack.go:24 +0xa5\nparkit/internal/jsonlog.(*Logger).print(0xc000054600, 0xc0000fe001, 0xc0000fe000, 0x99, 0xc00009cc60, 0x0, 0x0, 0x0)\n\tC:/Users/bcart/OneDrive/Desktop/Project/Project Z/Code/Parkit/internal/jsonlog/jsonlog.go:80 +0x475\nparkit/internal/jsonlog.(*Logger).PrintError(0xc000054600, 0xbd9ba0, 0xc00009a2e0, 0xc00009cc60)\n\tC:/Users/bcart/OneDrive/Desktop/Project/Project Z/Code/Parkit/internal/jsonlog/jsonlog.go:52 +0x69\nmain.(*application).logError(0xc0000be000, 0xc0000c6300, 0xbd9ba0, 0xc00009a2e0)\n\tC:/Users/bcart/OneDrive/Desktop/Project/Project Z/Code/Parkit/cmd/api/errors.go:9 +0x145\nmain.(*application).serverErrorResponse(0xc0000be000, 0xbe03e0, 0xc0000883c0, 0xc0000c6300, 0xbd9ba0, 0xc00009a2e0)\n\tC:/Users/bcart/OneDrive/Desktop/Project/Project Z/Code/Parkit/cmd/api/errors.go:26 +0x54\nmain.(*application).createDaysBookingsRecordHandler(0xc0000be000, 0xbe03e0, 0xc0000883c0, 0xc0000c6300)\n\tC:/Users/bcart/OneDrive/Desktop/Project/Project Z/Code/Parkit/cmd/api/spacebookings.go:39 +0x6cd\nnet/http.HandlerFunc.ServeHTTP(0xc0000a4340, 0xbe03e0, 0xc0000883c0, 0xc0000c6300)\n\tC:/Program Files/Go/src/net/http/server.go:2069 +0x4b\ngithub.com/julienschmidt/httprouter.(*Router).Handler.func1(0xbe03e0, 0xc0000883c0, 0xc0000c6300, 0x0, 0x0, 0x0)\n\tC:/Users/bcart/go/pkg/mod/github.com/julienschmidt/httprouter#v1.3.0/router.go:275 +0x1e7\ngithub.com/julienschmidt/httprouter.(*Router).ServeHTTP(0xc000088180, 0xbe03e0, 0xc0000883c0, 0xc0000c6300)\n\tC:/Users/bcart/go/pkg/mod/github.com/julienschmidt/httprouter#v1.3.0/router.go:387 +0xc7e\nmain.(*application).authenticate.func1(0xbe03e0, 0xc0000883c0, 0xc0000c6200)\n\tC:/Users/bcart/OneDrive/Desktop/Project/Project Z/Code/Parkit/cmd/api/middleware.go:128 +0x423\nnet/http.HandlerFunc.ServeHTTP(0xc00009a0a0, 0xbe03e0, 0xc0000883c0, 0xc0000c6200)\n\tC:/Program Files/Go/src/net/http/server.go:2069 +0x4b\nmain.(*application).rateLimit.func2(0xbe03e0, 0xc0000883c0, 0xc0000c6200)\n\tC:/Users/bcart/OneDrive/Desktop/Project/Project Z/Code/Parkit/cmd/api/middleware.go:84 +0x82\nnet/http.HandlerFunc.ServeHTTP(0xc00009c2a0, 0xbe03e0, 0xc0000883c0, 0xc0000c6200)\n\tC:/Program Files/Go/src/net/http/server.go:2069 +0x4b\nmain.(*application).enableCORS.func1(0xbe03e0, 0xc0000883c0, 0xc0000c6200)\n\tC:/Users/bcart/OneDrive/Desktop/Project/Project Z/Code/Parkit/cmd/api/middleware.go:208 +0x3ec\nnet/http.HandlerFunc.ServeHTTP(0xc00009a0c0, 0xbe03e0, 0xc0000883c0, 0xc0000c6200)\n\tC:/Program Files/Go/src/net/http/server.go:2069 +0x4b\nmain.(*application).recoverPanic.func1(0xbe03e0, 0xc0000883c0, 0xc0000c6200)\n\tC:/Users/bcart/OneDrive/Desktop/Project/Project Z/Code/Parkit/cmd/api/middleware.go:30 +0x98\nnet/http.HandlerFunc.ServeHTTP(0xc00009a0e0, 0xbe03e0, 0xc0000883c0, 0xc0000c6200)\n\tC:/Program Files/Go/src/net/http/server.go:2069 +0x4b\ngithub.com/felixge/httpsnoop.CaptureMetrics.func1(0xbe03e0, 0xc0000883c0)\n\tC:/Users/bcart/go/pkg/mod/github.com/felixge/httpsnoop#v1.0.3/capture_metrics.go:29 +0x53\ngithub.com/felixge/httpsnoop.(*Metrics).CaptureMetrics(0xc0000960a8, 0xbdfe70, 0xc0000c80e0, 0xc000073ab0)\n\tC:/Users/bcart/go/pkg/mod/github.com/felixge/httpsnoop#v1.0.3/capture_metrics.go:84 +0x1e7\ngithub.com/felixge/httpsnoop.CaptureMetricsFn(...)\n\tC:/Users/bcart/go/pkg/mod/github.com/felixge/httpsnoop#v1.0.3/capture_metrics.go:39\ngithub.com/felixge/httpsnoop.CaptureMetrics(0xbda7e0, 0xc00009a0e0, 0xbdfe70, 0xc0000c80e0, 0xc0000c6200, 0x970ca7, 0xc0000aa2ec, 0x1e0edbf0778)\n\tC:/Users/bcart/go/pkg/mod/github.com/felixge/httpsnoop#v1.0.3/capture_metrics.go:28 +0xae\nmain.(*application).metrics.func1(0xbdfe70, 0xc0000c80e0, 0xc0000c6200)\n\tC:/Users/bcart/OneDrive/Desktop/Project/Project Z/Code/Parkit/cmd/api/middleware.go:223 +0x87\nnet/http.HandlerFunc.ServeHTTP(0xc0000aa0c0, 0xbdfe70, 0xc0000c80e0, 0xc0000c6200)\n\tC:/Program Files/Go/src/net/http/server.go:2069 +0x4b\nnet/http.serverHandler.ServeHTTP(0xc0000c8000, 0xbdfe70, 0xc0000c80e0, 0xc0000c6200)\n\tC:/Program Files/Go/src/net/http/server.go:2887 +0xaa\nnet/http.(*conn).serve(0xc00008a140, 0xbe0f20, 0xc0000aa240)\n\tC:/Program Files/Go/src/net/http/server.go:1952 +0x8cd\ncreated by net/http.(*Server).Serve\n\tC:/Program Files/Go/src/net/http/server.go:3013 +0x3b8\n"}
2022/07/28 14:40:19 http: superfluous response.WriteHeader call from github.com/felixge/httpsnoop.(*Metrics).CaptureMetrics.func1.1 (capture_metrics.go:53)
Does anyone know what is causing this error and how to resolve it?
I am trying to use sgx_rijndael128GCM_encrypt to encrypt some data but the buffer remains empaty. I dont know why or what i am doing wrong. This is the code I am using, if there is any errors please mention them. As far as I think, there will be some changes in line 2, where i am calculating aesgcm_len or maybe i am using the wrong key. But if the key is wrong then it should show some errors. Please guide me. Thank you in advance.
uint8_t *plaintext = (uint8_t *)item->certificate;
size_t aesgcm_len =4 + ((((double)sizee)/16))*16 +16;
item->encrypteee = (uint8_t*)malloc(aesgcm_len);
sgx_aes_gcm_128bit_tag_t mac;
const sgx_aes_gcm_128bit_key_t aes_key= { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf };
//sgx_read_rand((unsigned char *) &aes_key, sizeof(sgx_aes_gcm_128bit_key_t));
uint8_t iv[12];
memset(iv,0,12);
((int*)item->encrypteee)[0]=sizee;
sgx_status_t res;
res= sgx_rijndael128GCM_encrypt(&aes_key, plaintext, sizee, (uint8_t*)item->encrypteee+4,iv,12 ,NULL,0,&mac);
if (res != SGX_SUCCESS) {
//printf("encryption error");
free(wallet);
return ERR_FAIL_UNSEAL;
}
I have updated go-pg lib from v9.0.3 to v9.2.0.
Getting error:
panic: not reached [recovered]
panic: not reached
/usr/local/go/src/runtime/panic.go:969 +0x175
github.com/go-pg/pg/v9/internal/pool.(*SingleConnPool).SetConn(...)
/Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/internal/pool/pool_single.go:61
github.com/go-pg/pg/v9.(*baseDB).initConn(0xc0002440f0, 0x1efb500, 0xc00019e008, 0xc000292550, 0x0, 0x0)
/Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/base.go:115 +0x585
github.com/go-pg/pg/v9.(*baseDB).getConn(0xc0002440f0, 0x1efb500, 0xc00019e008, 0x0, 0x0, 0x0)
/Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/base.go:79 +0x90
github.com/go-pg/pg/v9.(*baseDB).withConn(0xc0002440f0, 0x1efb500, 0xc00019e008, 0xc000813c00, 0x0, 0x0)
/Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/base.go:133 +0x7c
github.com/go-pg/pg/v9.(*Tx).withConn(...)
/Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/tx.go:96
github.com/go-pg/pg/v9.(*Tx).exec(0xc00072c980, 0x1efb500, 0xc00019e008, 0x1bd4d20, 0x1ec3250, 0x0, 0x0, 0x0, 0x8, 0xc000078cd0, ...)
/Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/tx.go:149 +0x1f0
github.com/go-pg/pg/v9.(*Tx).ExecContext(...)
/Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/tx.go:139
github.com/go-pg/pg/v9.(*Tx).begin(0xc00072c980, 0x1efb500, 0xc00019e008, 0x4b2, 0x0)
/Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/tx.go:339 +0xb6
github.com/go-pg/pg/v9.(*baseDB).Begin(0xc000244000, 0x25f0b4e, 0x24, 0xc000589ea0)
/Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/tx.go:53 +0x1ca
github.com/sanches1984/gopkg-database.(*dbWrapper).StartTransaction(0xc0007180c0, 0x0, 0x25f0b4e, 0x24, 0xc0000003f3)
Fail on:
tx, err := conn.Begin()
Found that they fix it here, but it doesn't work. What's the problem?
Check first if this is linked to go-pg/pg issue 1687, which is supposed to be resolved in PR 1688.
That PR is only available in v10.0.0-beta.9, so you would need to explicitly upgrade your dependency
go get github.com/go-pg/pg#v10.0.0-beta.14
I'm using using go.mongodb.org/mongo-driver/mongo and I'm trying to story byte slice in MongoDB. However, the driver marshals it as an array of integers.
In my case I have the following type:
type Hash [20]byte
I tried to implement the ValueMarshaler interface as the foollowing:
func (h Hash) MarshalBSONValue() (bsontype.Type, []byte, error) {
return bsontype.Binary, h[:20], nil
}
But it is clear that h[:20] does not return valid bytes for mongo. It panics and returns the following:
panic: runtime error: slice bounds out of range [:-658764325]
goroutine 39 [running]:
go.mongodb.org/mongo-driver/x/bsonx/bsoncore.ReadElement(0xc0004bca1c, 0x1d, 0xe4, 0x55b6910, 0xffffffffffffff01, 0xc000178d00, 0xc00129aa18, 0x406d52d, 0x4819ea0, 0xc000bba240)
/go/pkg/mod/go.mongodb.org/mongo-driver#v1.0.1/x/bsonx/bsoncore/bsoncore.go:122 +0x271
go.mongodb.org/mongo-driver/x/bsonx/bsoncore.Document.Validate(0xc0004bca18, 0x21, 0xe8, 0x4799100, 0x26)
/go/pkg/mod/go.mongodb.org/mongo-driver#v1.0.1/x/bsonx/bsoncore/document.go:377 +0xe4
go.mongodb.org/mongo-driver/x/bsonx.(*Doc).UnmarshalBSON(0xc00129aba0, 0xc0004bca18, 0x21, 0xe8, 0x5, 0xc00129abc8)
/go/pkg/mod/go.mongodb.org/mongo-driver#v1.0.1/x/bsonx/document.go:225 +0x6e
go.mongodb.org/mongo-driver/x/bsonx.ReadDoc(0xc0004bca18, 0x21, 0xe8, 0xc0004bca18, 0x21, 0xe8, 0xc0004bca39, 0x0)
/go/pkg/mod/go.mongodb.org/mongo-driver#v1.0.1/x/bsonx/document.go:54 +0x77
go.mongodb.org/mongo-driver/x/bsonx.(*Val).UnmarshalBSONValue(0xc00129b2c0, 0x3, 0xc0004bca18, 0x21, 0xe8, 0x21, 0xe8)
/go/pkg/mod/go.mongodb.org/mongo-driver#v1.0.1/x/bsonx/value.go:249 +0x90f
go.mongodb.org/mongo-driver/x/bsonx.(*Doc).UnmarshalBSON(0xc00129b370, 0xc0004bca0a, 0x30, 0xf6, 0x44747df, 0xc0000b21e0)
/go/pkg/mod/go.mongodb.org/mongo-driver#v1.0.1/x/bsonx/document.go:236 +0x173
go.mongodb.org/mongo-driver/x/bsonx.ReadDoc(0xc0004bca0a, 0x30, 0xf6, 0xc0004bca0a, 0x30, 0xf6, 0xc0004bca3a, 0x0)
/go/pkg/mod/go.mongodb.org/mongo-driver#v1.0.1/x/bsonx/document.go:54 +0x77
go.mongodb.org/mongo-driver/x/bsonx.(*Val).UnmarshalBSONValue(0xc00129ba90, 0x3, 0xc0004bca0a, 0x30, 0xf6, 0x30, 0xf6)
/go/pkg/mod/go.mongodb.org/mongo-driver#v1.0.1/x/bsonx/value.go:249 +0x90f
go.mongodb.org/mongo-driver/x/bsonx.(*Doc).UnmarshalBSON(0xc00129bb40, 0xc0004bca00, 0x3b, 0x100, 0xc0000b21e0, 0x100)
/go/pkg/mod/go.mongodb.org/mongo-driver#v1.0.1/x/bsonx/document.go:236 +0x173
go.mongodb.org/mongo-driver/x/bsonx.ReadDoc(0xc0004bca00, 0x3b, 0x100, 0x0, 0x100, 0x4833880, 0xc000bba090, 0xc0004bca00)
/go/pkg/mod/go.mongodb.org/mongo-driver#v1.0.1/x/bsonx/document.go:54 +0x77
go.mongodb.org/mongo-driver/mongo.transformDocument(0xc00014a070, 0x4833880, 0xc000bba090, 0xc000bba120, 0x1, 0x1, 0x0, 0x0)
/go/pkg/mod/go.mongodb.org/mongo-driver#v1.0.1/mongo/mongo.go:155 +0x1f5
go.mongodb.org/mongo-driver/mongo.(*Collection).UpdateOne(0xc00010e1e0, 0x4cca0a0, 0xc00010e3c0, 0x4833880, 0xc000bba060, 0x4833880, 0xc000bba090, 0x0, 0x0, 0x0, ...)
/go/pkg/mod/go.mongodb.org/mongo-driver#v1.0.1/mongo/collection.go:530 +0xf0
Process finished with exit code 2
BSON is a binary JSON. JSON per se doesn't have the byte array type, but it does have arrays.
The library can handle types without any additional marshallers.
Here is a minimal working example.
package main
import (
"context"
"fmt"
"time"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
type Hash [4]byte
type Model struct {
Key Hash `bson:"key"`
}
func main() {
client, err := mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017"))
if err != nil {
panic(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
err = client.Connect(ctx)
if err != nil {
panic(err)
}
db := client.Database("database")
collection := db.Collection("collection")
// insert as plain []byte slice
_, err = collection.InsertOne(ctx, bson.M{"key": [4]byte{1, 2, 3, 4}})
if err != nil {
panic(err)
}
// insert h as a Hash type
h := Hash([4]byte{1, 2, 3, 4})
_, err = collection.InsertOne(ctx, bson.M{"key": h})
if err != nil {
panic(err)
}
cursor, err := collection.Find(ctx, bson.M{})
if err != nil {
panic(err)
}
var all []Model
if err := cursor.All(ctx, &all); err != nil {
panic(err)
}
fmt.Println(all)
}
I try use follow command to generate cloud foundry deployment file cf-deployment.yml in my VM(centos7 it already installed an openstack environment, rdo juno)
./generate_deployment_manifest openstack cf-stub.yml > cf-deployment.yml
the cf-stub.yml content is in follow
# The following line helps maintain current documentation at http://docs.cloudfoundry.org.
# code_snippet cf-stub-openstack start
---
director_uuid: 90c73a6e-4fd1-41bb-9282-299eb49af9fc
meta:
openstack:
net_id: 9e5a6fd5-fa2e-48da-94ce-f85337bc2451
auth_url: http://172.24.10.128:5000/v2.0
tenant: demo
username: demo
api_key: openstack
security_groups: [bosh]
floating_static_ips:
- 172.24.10.133
networks:
- name: cf1
subnets:
- cloud_properties:
static:
- 10.0.5.20 - 0.0.0.50
properties:
cc:
droplets:
droplet_directory_key: cloudfoundry-droplets
buildpacks:
buildpack_directory_key: cloudfoundry-buildpacks
staging_upload_user: update
staging_upload_password: openstack
bulk_api_password: openstack
db_encryption_key: openstack
ccdb:
roles:
- name: ccadmin
password: openstack
tag: admin
databases:
roles:
- name: ccadmin
password: openstack
- name: uaaadmin
password: openstack
dea_next:
disk_mb: 2048
memory_mb: 1024
domain: example.com
loggregator_endpoint:
shared_secret: openstack
nats:
user: nats
password: openstack
router:
enable_ssl: true
ssl_cert: |
-----BEGIN CERTIFICATE-----
MIIDBjCCAe4CCQCz3nn1SWrDdTANBgkqhkiG9w0BAQ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hwDRHjaWdR2Z/w5m
eIuOvF3lN2MWZm175ouynDKDeoaAsiS2VttB6R/aRFxX42UHfoYXC8LcTmyAK5zF
8X3SMf7H5wtqBepQVt+Gm5zGSSqLcEnQ3H5c+impOh105CGoxt0rk4Ui/AeRIalv
C70AJOcvD3eu5aFq9gDe/1ECgYBAhkVbASzYGnMh+pKVH7rScSxto8v6/XBYT1Ez
7JOlMhD667/qvtFJtgIHkq7qzepbhnTv5x3tscQVnZY34/u9ILpD1s8dc+dibEvx
6S/gYLVorB5ois/DLMqaobRcew6Gs+XX9RPwmLahOJpZ9mh4XrOmCgPAYtP71YM9
ExpHCQKBgQCMMDDWGMRdFMJgXbx1uMere7OoniBdZaOexjbglRh1rMVSXqzBoU8+
yhEuHGAsHGWQdSBHnqRe9O0Bj/Vlw2VVEaJeL1ewRHb+jXSnuKclZOJgMsJAvgGm
SOWIahDrATA4g1T6yLBWQPhj3ZXD3eCMxT1Q3DvpG1DjgvXwmXQJAA==
-----END RSA PRIVATE KEY-----
cipher_suites: TLS_RSA_WITH_RC4_128_SHA:TLS_RSA_WITH_AES_128_CBC_SHA
status:
user: router_user
password: openstack
secure_cookies: true
uaa:
admin:
client_secret: openstack
batch:
username: batch
password: openstack
cc:
client_secret: openstack
clients:
app-direct:
secret: openstack
developer_console:
secret: openstack
notifications:
secret: openstack
login:
secret: openstack
doppler:
secret: openstack
cloud_controller_username_lookup:
secret: cloud_controller_username_lookup_secret
gorouter:
secret: openstack
jwt:
verification_key:
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw6WKxiVxx5+rqoMvj4vk
X5FpipdWaVLpcPhmN8O5ut2bqcU8KV6pMV7/n+zowITVFHCbS/6J6Uk875NclTC1
UI86Pxn3c+14KYL6KLe/Gi8McRyqvO5BpkQr3BTtBe9Z0EMgoeq5fAol2Lc/8SNz
/uLdSkMc5CmtpEgZ7isnsc8ExSDCchRmrCmKaxIPxNUZvCYgq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/sHynj6pN4GBIlZTjZXiCwsCgYEAyMCE
8MEPJZmAQ8vaWjzkzbToUbW5knrEhRNEoxnlbRXXwzXReUIbu+E22FQjwNNxlsJx
smKFWzPvF5seiChBp7yT9dnDKCm9bJVRRAlVD5oyBIFkqXmCn3QM9ySWW6QHxgEH
4wsoNs0RcpTNW/CLi7E9tvtzjnoFqdfDIaSbPV0CgYBhv56OcI4cN+1WcHjBHl0D
rG79RshjAZEW9LeP4gW/ayzQp6967GAY6wmZ+i26rVYSn8zl6b3p1wLcKF/0tw4M
BQzimQb/U+E7ntTOOi8YMxCVuBqimgd7FgxTpSogU0YZQHjMEUPGKXtvM+1Yi7vB
+6EgKPLJoX7DwkjYJ0o6AwKBgQC842gyn3SBDE2DfOuWvHUMmIt/Vl2lVZ5TGC4c
yOD2IvdA1gKi9XDi9qWEJqb9Z/YYxBv2nHyds9/jdjDkK/yatvUA/kSCJcP1xwkP
2zgN1if51UXBsHMXVTpd0C8pSs2FoLKrDnRoG8uu5BPVzh9+8OYApde011s806bm
oNrwgQKBgQCW/CUPXOrfyIwdFIEqSPB79GuV9e27cm8iB8Fu+Rcc3xlQc+3Ak97X
bLi2C1to/pMX+q8ksudd1jOMoyhufle8wJaxC0jLgVx4DGUorvA0uiVtEAULreXz
beE4LXyvVu+tYIl4ATlIyEQSAnNIR6oCX5KvQJu+jHA4i9z+Vg0mpA==
-----END RSA PRIVATE KEY-----
scim:
users:
- admin|openstack|scim.write,scim.read,openid,cloud_controller.admin,doppler.firehose
uaadb:
roles:
- name: uaaadmin
password: openstack
tag: admin
# code_snippet cf-stub-openstack end
# The previous line helps maintain current documentation at http://docs.cloudfoundry.org.
then I get the error
./generate_deployment_manifest openstack cf-stub.yml > cf-deployment.yml
fatal error: runtime: out of memory
runtime stack:
runtime.SysMap(0xc3d3860000, 0x72eb0000, 0x754900, 0x75ca58)
/usr/local/Cellar/go/1.4.2/libexec/src/runtime/mem_linux.c:149 +0x98
runtime.MHeap_SysAlloc(0x762140, 0x72eb0000, 0x429d02)
/usr/local/Cellar/go/1.4.2/libexec/src/runtime/malloc.c:284 +0x124
runtime.MHeap_Alloc(0x762140, 0x39755, 0x10100000000, 0xc208000120)
/usr/local/Cellar/go/1.4.2/libexec/src/runtime/mheap.c:240 +0x66
goroutine 1 [running]:
runtime.switchtoM()
/usr/local/Cellar/go/1.4.2/libexec/src/runtime/asm_amd64.s:198 fp=0xc208141858 sp=0xc208141850
runtime.mallocgc(0x72ea9ff0, 0x61e9e0, 0x0, 0x73c280)
/usr/local/Cellar/go/1.4.2/libexec/src/runtime/malloc.go:199 +0x9f3 fp=0xc208141908 sp=0xc208141858
runtime.newarray(0x61e9e0, 0x4c9c6aa, 0x57be3e)
/usr/local/Cellar/go/1.4.2/libexec/src/runtime/malloc.go:365 +0xc1 fp=0xc208141940 sp=0xc208141908
runtime.growslice(0x5946c0, 0xc377970000, 0x3d49eaa, 0x3d49eaa, 0x1, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.4.2/libexec/src/runtime/slice.go:87 +0x2bb fp=0xc2081419a0 sp=0xc208141940
github.com/cloudfoundry-incubator/spiff/dynaml.ipRange(0xc208156cd0, 0x10, 0x10, 0xc208156d20, 0x10, 0x10, 0x0, 0x0, 0x0)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/dynaml/call.go:187 +0x221 fp=0xc208141a58 sp=0xc2081419a0
github.com/cloudfoundry-incubator/spiff/dynaml.staticIPPool(0xc208156c90, 0x1, 0x1, 0x0, 0x0, 0x0, 0xc208141be0)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/dynaml/call.go:173 +0x296 fp=0xc208141b88 sp=0xc208141a58
github.com/cloudfoundry-incubator/spiff/dynaml.generateStaticIPs(0x7f63bde43170, 0xc208046370, 0xc2081564c8, 0x1, 0x1, 0x0, 0x0, 0x600000000000000)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/dynaml/call.go:63 +0x16f fp=0xc208141ca0 sp=0xc208141b88
github.com/cloudfoundry-incubator/spiff/dynaml.CallExpr.Evaluate(0xc208156211, 0xa, 0xc2081560b0, 0x1, 0x1, 0x7f63bde43170, 0xc208046370, 0x0, 0x0, 0xc208141e00)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/dynaml/call.go:33 +0x2bc fp=0xc208141d88 sp=0xc208141ca0
github.com/cloudfoundry-incubator/spiff/dynaml.(*CallExpr).Evaluate(0xc20810c9f0, 0x7f63bde43170, 0xc208046370, 0x0, 0x0, 0xc208046370)
<autogenerated>:11 +0xc6 fp=0xc208141de0 sp=0xc208141d88
github.com/cloudfoundry-incubator/spiff/flow.flow(0x7f63bde41ef0, 0xc2080b85c0, 0xc208208060, 0x3, 0x4, 0xc20800a500, 0x5, 0x8, 0xc20800a340, 0x1, ...)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/flow/flow.go:49 +0x2df fp=0xc208141f08 sp=0xc208141de0
github.com/cloudfoundry-incubator/spiff/flow.flowMap(0x7f63bde41ef0, 0xc2080b8600, 0xc208208060, 0x3, 0x4, 0xc208034600, 0x4, 0x6, 0xc20800a340, 0x1, ...)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/flow/flow.go:98 +0x8c7 fp=0xc208142278 sp=0xc208141f08
github.com/cloudfoundry-incubator/spiff/flow.flow(0x7f63bde41ef0, 0xc2080b8600, 0xc208156b10, 0x2, 0x2, 0xc208034600, 0x4, 0x6, 0xc20800a340, 0x1, ...)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/flow/flow.go:43 +0x131 fp=0xc2081423a0 sp=0xc208142278
github.com/cloudfoundry-incubator/spiff/flow.flowList(0x7f63bde41ef0, 0xc2080b8660, 0xc208156b10, 0x2, 0x2, 0xc208145580, 0x3, 0x4, 0xc20800a340, 0x1, ...)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/flow/flow.go:113 +0x420 fp=0xc208142600 sp=0xc2081423a0
github.com/cloudfoundry-incubator/spiff/flow.flow(0x7f63bde41ef0, 0xc2080b8660, 0xc208156b10, 0x2, 0x2, 0xc208145580, 0x3, 0x4, 0xc20800a340, 0x1, ...)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/flow/flow.go:46 +0x1ed fp=0xc208142728 sp=0xc208142600
github.com/cloudfoundry-incubator/spiff/flow.flowMap(0x7f63bde41ef0, 0xc2080b87e0, 0xc208156b10, 0x2, 0x2, 0xc208149ea0, 0x2, 0x2, 0xc20800a340, 0x1, ...)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/flow/flow.go:98 +0x8c7 fp=0xc208142a98 sp=0xc208142728
github.com/cloudfoundry-incubator/spiff/flow.flow(0x7f63bde41ef0, 0xc2080b87e0, 0xc2080440c8, 0x1, 0x1, 0xc208149ea0, 0x2, 0x2, 0xc20800a340, 0x1, ...)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/flow/flow.go:43 +0x131 fp=0xc208142bc0 sp=0xc208142a98
github.com/cloudfoundry-incubator/spiff/flow.flowList(0x7f63bde41ef0, 0xc208148fc0, 0xc2080440c8, 0x1, 0x1, 0xc208156a70, 0x1, 0x1, 0xc20800a340, 0x1, ...)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/flow/flow.go:113 +0x420 fp=0xc208142e20 sp=0xc208142bc0
github.com/cloudfoundry-incubator/spiff/flow.flow(0x7f63bde41ef0, 0xc208148fc0, 0xc2080440c8, 0x1, 0x1, 0xc208156a70, 0x1, 0x1, 0xc20800a340, 0x1, ...)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/flow/flow.go:46 +0x1ed fp=0xc208142f48 sp=0xc208142e20
github.com/cloudfoundry-incubator/spiff/flow.flowMap(0x7f63bde41ef0, 0xc208149b80, 0xc2080440c8, 0x1, 0x1, 0x0, 0x0, 0x0, 0xc20800a340, 0x1, ...)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/flow/flow.go:98 +0x8c7 fp=0xc2081432b8 sp=0xc208142f48
github.com/cloudfoundry-incubator/spiff/flow.flow(0x7f63bde41ef0, 0xc208149b80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc20800a340, 0x1, ...)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/flow/flow.go:43 +0x131 fp=0xc2081433e0 sp=0xc2081432b8
github.com/cloudfoundry-incubator/spiff/flow.Flow(0x7f63bde41ef0, 0xc20801f2c0, 0xc20800a340, 0x1, 0x4, 0x0, 0x0, 0x0, 0x0)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/flow/flow.go:19 +0xd6 fp=0xc208143500 sp=0xc2081433e0
github.com/cloudfoundry-incubator/spiff/flow.Cascade(0x7f63bde41ef0, 0xc208073960, 0xc20800a300, 0x5, 0x8, 0x0, 0x0, 0x0, 0x0)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/flow/cascade.go:9 +0x100 fp=0xc208143590 sp=0xc208143500
main.merge(0x7fffddc9a701, 0x1d, 0xc20800a030, 0x5, 0x5)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/spiff.go:90 +0xd0c fp=0xc208143770 sp=0xc208143590
main.funcĀ·001(0xc20807a1c0)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/spiff.go:36 +0x124 fp=0xc2081437e8 sp=0xc208143770
github.com/codegangsta/cli.Command.Run(0x63a750, 0x5, 0x63a510, 0x1, 0x0, 0x0, 0x0, 0x67e3f0, 0x29, 0x0, ...)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/Godeps/_workspace/src/github.com/codegangsta/cli/command.go:118 +0x104b fp=0xc208143be8 sp=0xc2081437e8
github.com/codegangsta/cli.(*App).Run(0xc20806c0f0, 0xc20800a000, 0x8, 0x8, 0x0, 0x0)
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/Godeps/_workspace/src/github.com/codegangsta/cli/app.go:177 +0xdf6 fp=0xc208143ee8 sp=0xc208143be8
main.main()
/Users/fraenkel/go/src/github.com/cloudfoundry-incubator/spiff/spiff.go:60 +0x292 fp=0xc208143f98 sp=0xc208143ee8
runtime.main()
/usr/local/Cellar/go/1.4.2/libexec/src/runtime/proc.go:63 +0xf3 fp=0xc208143fe0 sp=0xc208143f98
runtime.goexit()
/usr/local/Cellar/go/1.4.2/libexec/src/runtime/asm_amd64.s:2232 +0x1 fp=0xc208143fe8 sp=0xc208143fe0
even I config my vm to 10g ram, the error still there, this let me start to think it may be not a memory issue. so I ask here.
does any body can give me some advice ?
thanks in advance.
this error cause by the - 10.0.5.20 - 0.0.0.50 ip error, if the ip is not in same net xxx.xxx.xxx.xxx- xxx.xxx.yyy.xxx will cause OOM error