nakagami / firebirdsql

Firebird RDBMS sql driver for Go (golang)
MIT License
227 stars 60 forks source link

Timezone parsing issue #166

Open clseibold opened 7 months ago

clseibold commented 7 months ago

I'm getting an issue with Timezones. It seems to happen at line 305 in xsqlvar.go, within the parseTimestampTz function. db.go line 293 in my code is a call to rows.Next(). I'm not even getting to the point where I call rows.Scan(). This issue seems to have popped up out of nowhere. The program was working just fine for a while, and then suddenly I started getting this issue, and I didn't make any changes to this sql code.

panic: time: missing Location in call to Date
goroutine 116 [running]:
runtime/debug.Stack()
    C:/Users/krixa/sdk/go1.22.0/src/runtime/debug/stack.go:24 +0x5e
gitlab.com/clseibold/smallnetinformationservices.(*PortListener).multiplex.func2()
    C:/Users/krixa/go/pkg/mod/gitlab.com/clseibold/smallnetinformationservices@v0.0.0-20240304010439-d4a482cd82a3/port_listener.go:549 +0x79
panic({0x107d800?, 0x13eb630?})
    C:/Users/krixa/sdk/go1.22.0/src/runtime/panic.go:770 +0x132
time.Date(0x72e6df?, 0xc00000b4be?, 0x800000?, 0xc000518a60?, 0xd9b3dd7e00730cc5?, 0x10e55bc8?, 0x276ff271688?, 0x18?)
    C:/Users/krixa/sdk/go1.22.0/src/time/time.go:1490 +0x4c5
github.com/nakagami/firebirdsql.(*xSQLVAR).parseTimestampTz(0xc000518d48, {0xc00000b4b4, 0x2c?, 0xc})
    C:/Users/krixa/go/pkg/mod/github.com/nakagami/firebirdsql@v0.9.7/xsqlvar.go:305 +0x1c5
github.com/nakagami/firebirdsql.(*xSQLVAR).value(0x10d9660?, {0xc00000b4b4, 0x7ff2?, 0x0?}, {0x0?, 0xc0005200b0?}, {0xc0000e04ef?, 0xc000518d30?})
    C:/Users/krixa/go/pkg/mod/github.com/nakagami/firebirdsql@v0.9.7/xsqlvar.go:502 +0xa5
github.com/nakagami/firebirdsql.(*wireProtocol).opFetchResponse(0xc000176480, 0x80008?, 0xc0?, {0xc0001f6a88, 0x19, 0xd0?})
    C:/Users/krixa/go/pkg/mod/github.com/nakagami/firebirdsql@v0.9.7/wireprotocol.go:1129 +0x713
github.com/nakagami/firebirdsql.(*firebirdsqlRows).Next(0xc0003ea640, {0xc0004a4680, 0x19, 0x30072?})
    C:/Users/krixa/go/pkg/mod/github.com/nakagami/firebirdsql@v0.9.7/rows.go:102 +0x125
database/sql.(*Rows).nextLocked(0xc0001414d0)
    C:/Users/krixa/sdk/go1.22.0/src/database/sql/sql.go:3047 +0x107
database/sql.(*Rows).Next.func1()
    C:/Users/krixa/sdk/go1.22.0/src/database/sql/sql.go:3022 +0x29
database/sql.withLock({0x13f5488, 0xc000141508}, 0xc000519018)
    C:/Users/krixa/sdk/go1.22.0/src/database/sql/sql.go:3530 +0x82
database/sql.(*Rows).Next(0xc0001414d0)
    C:/Users/krixa/sdk/go1.22.0/src/database/sql/sql.go:3021 +0x85
gitlab.com/clseibold/auragem_sis/gemini/search.getImageFiles(0xc0001cde10, 0x1?)
    C:/Users/krixa/Dev/auragem_sis/gemini/search/db.go:293 +0x1db
gitlab.com/clseibold/auragem_sis/gemini/search.HandleSearchEngine.func40({0x0, 0x0, {0xc000034e40, 0x13}, {0xc0000dfb90, 0x2a}, {0x0, 0x0}, 0x0, {0x0, ...}, ...})
    C:/Users/krixa/Dev/auragem_sis/gemini/search/search.go:769 +0xa5
gitlab.com/clseibold/smallnetinformationservices.(*Server).gemini_handleRequest(0xc000255508, 0xc0004ea388, {0x1, {0xc0000dfb90, 0x2a}, {0xc0000dfb99, 0x10}, 0x0, {0x0, 0x0}, ...})
    C:/Users/krixa/go/pkg/mod/gitlab.com/clseibold/smallnetinformationservices@v0.0.0-20240304010439-d4a482cd82a3/gemini_server.go:221 +0x5bf
gitlab.com/clseibold/smallnetinformationservices.(*Server).handleRequest(0xc0000f2a10?, {0x13ffd90?, 0xc0004ea388?}, {0x1, {0xc0000dfb90, 0x2a}, {0xc0000dfb99, 0x10}, 0x0, {0x0, ...}, ...})
    C:/Users/krixa/go/pkg/mod/gitlab.com/clseibold/smallnetinformationservices@v0.0.0-20240304010439-d4a482cd82a3/server.go:706 +0x11d
gitlab.com/clseibold/smallnetinformationservices.(*PortListener).multiplex(0xc0000f2a10, {0x13ffd90, 0xc0004ea388}, 0x0?, 0x0?)
    C:/Users/krixa/go/pkg/mod/gitlab.com/clseibold/smallnetinformationservices@v0.0.0-20240304010439-d4a482cd82a3/port_listener.go:632 +0xaaa
created by gitlab.com/clseibold/smallnetinformationservices.(*PortListener).startTLS in goroutine 75
    C:/Users/krixa/go/pkg/mod/gitlab.com/clseibold/smallnetinformationservices@v0.0.0-20240304010439-d4a482cd82a3/port_listener.go:523 +0xe7c
nakagami commented 7 months ago
missing Location in call to Date

I have searched for this keyword and it looks like the zoneinfo database is missing.

I don't know how to fix it for your environment, but I think I did execute

apt install -y tzdata

https://stackoverflow.com/questions/44331836/apt-get-install-tzdata-noninteractive

clseibold commented 7 months ago

I'm on Windows. I don't see how my timezone info should be missing when the program (a server) was running just fine 6 hours ago and then suddenly stopped working after a restart. I haven't restarted the desktop at all, so I guess I could try that.

I also have a crawler currently running that has stayed running for longer than 6 hours, and it is working just fine and is able to keep inserting things into the db. So it's only when I startup my server within the past 6 hours that I've gotten the problem.

Thanks for the help. I guess I'll try restarting the whole desktop and report back here if that changes anything.

clseibold commented 7 months ago

@nakagami Golang has a zoneinfo.zip stored in GOROOT\lib\time\ to store the timezone information. I just checked and I do have the zoneinfo.zip file, so I don't think my timezone info is missing.

Golang fortunately has a way to use an embedded tzdata by importing the "time/tzdata" package, so I'll try that next.

clseibold commented 7 months ago

Ok, using the embedded tzdata (by importing with _ "time/tzdata") seems to have worked. I will still like to figure out why the tzdata stored in GOROOT wasn't being read, so I'll look more into that.