jasonrogena / lightraft

Wrapper around SQLite that makes it distributed. This is an experiment, don't use in production
11 stars 2 forks source link

Don't Proxy SQL Read Queries #5

Closed jasonrogena closed 4 years ago

jasonrogena commented 4 years ago

SQL queries that don't modify the state of the database should not be proxied to the leader since they are technically not stat machine commands. This should be controlled by this piece of code, which seems to be broken. Follower panics with this error while trying to run commands locally:

panic: interface conversion: interface {} is *string, not string

goroutine 425 [running]:
github.com/jasonrogena/lightraft/persistence/sqlite.(*Driver).RunSelectQuery(0xc000010280, 0xc000026c80, 0x15, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        ~/go/src/github.com/jasonrogena/lightraft/persistence/sqlite/sqlite.go:110 +0xc56
github.com/jasonrogena/lightraft/persistence/sqlite.(*Driver).RunReadQuery(0xc000010280, 0xc000026c80, 0x15, 0x0, 0x0, 0x0, 0xc000010280, 0xc000026c80, 0x15, 0xc0001d5100)
      ~/go/src/github.com/jasonrogena/lightraft/persistence/sqlite/sqlite.go:62 +0x6f
github.com/jasonrogena/lightraft/persistence.(*Database).Commit(0xc0001322f0, 0xc000026c80, 0x15, 0x0, 0x15, 0xc000026c80, 0x41053b)
        ~/go/src/github.com/jasonrogena/lightraft/persistence/persistence.go:41 +0x103
github.com/jasonrogena/lightraft/consensus/raft.(*Node).IngestCommand(0xc0000e4280, 0xb164e0, 0xc0001aa438, 0xc000026c80, 0x15)
       ~/go/src/github.com/jasonrogena/lightraft/consensus/raft/raft.go:358 +0x3a3
main.initTCPServer.func2(0xc0001c97a0, 0xc000026c80, 0x15)
        ~/go/src/github.com/jasonrogena/lightraft/main.go:114 +0x83
github.com/firstrow/tcp_server.(*Client).listen(0xc0001c97a0)
       ~/go/pkg/mod/github.com/firstrow/tcp_server@v0.0.0-20190424084220-b7a05ff2879d/tcp_server.go:36 +0xd9
created by github.com/firstrow/tcp_server.(*server).Listen
       ~/go/pkg/mod/github.com/firstrow/tcp_server@v0.0.0-20190424084220-b7a05ff2879d/tcp_server.go:95 +0xe8