go-mysql-server icon indicating copy to clipboard operation
go-mysql-server copied to clipboard

Document major limitations

Open frioux opened this issue 5 years ago • 2 comments

This is an exciting project and I used it in my test harness for months, till the limitations basically made the situation untenable. At the very least I hope this issue helps people know what this project can and cannot do before they invest a lot of time in it.

Dead?

Sadly, I think all of src-d have stopped pushing to the open source repos. At best they have decided to invest in internal stuff. At worst the company went under six months ago. Keep this in mind along with the other limitations here.

Inscrutable errors

When you accidentally hit an unsupported feature, next steps are super difficult. Here's some code that I'd expect to error due to an unknown table for example:

package main

import (
	"database/sql"
	"fmt"
	
       sqle "github.com/src-d/go-mysql-server"
       "github.com/src-d/go-mysql-server/auth"
       "github.com/src-d/go-mysql-server/memory"
       "github.com/src-d/go-mysql-server/server"

	_ "github.com/go-sql-driver/mysql"
)

func main() {
	engine := sqle.NewDefault()
	engine.AddDatabase(memory.NewDatabase("testing"))

	srv, err := server.NewDefaultServer(server.Config{
		Protocol: "tcp",
		Address:  "127.0.0.1:0",
		Auth:     new(auth.None),
	}, engine)

	go func() {
		err := srv.Start()
		if err != nil {
			// Start always returns nil, never a real error, so this is exceptional
			panic(err)
		}
	}()

	db, err := sql.Open("mysql", "user:password@tcp("+srv.Listener.Addr().String()+")/testdb")
	if err != nil {
		panic(err)
	}

	_, err = db.Query("SELECT * FROM foo WHERE id = ?", 1)
	if err != nil {
		panic(err)
	}
}

The actual error is:

ERRO[0000] Got unhandled packet (default) from client 1 (127.0.0.1:12760), returning error: [22 83 69 76 69 67 84 32 42 32 70 82 79 77 32 102 111 111 32 87 72 69 82 69 32 105 100 32 61 32 63] 
panic: Error 1047: command handling not implemented yet: 22

Again, keep this in mind for some of the unsupported features below.

Poor Concurrency support

The server seems to not support concurrent access very well, choking with inscrutable errors like the above on code that works non-concurrently. This is maybe not a big deal for many, but we tend to run all of our tests with t.Parallel() to shake out concurrency related bugs.

No Auto incrementing value support

You basically cannot use SQL to insert into the database, instead you are forced to use sql.Inserter. This dramatically reduces the usefulness of this project.

No Bindvar Support

If you try to use bind vars (?'s in SQL) this thing will choke on them, so you have to do that client side. This is livable since you can set that flag on the database connection.


I'm sure there's more, but all the above forced me to stop using this. I hope that the community can help pick this back up and give it the love it needs. I would love to pitch in and might, but I assume someone will need to fork it and give it a new home.

frioux avatar Apr 25 '20 15:04 frioux

We've got an active fork with ~400 extra commits of bug fixes and additions after src-d quit. We're planning on continuing development indefinitely, as this is powering our open-source database product. Check it out if you're interested:

https://github.com/liquidata-inc/go-mysql-server

We haven't fixed concurrency issues (haven't used the server extensively enough to discover them on our own). If you have a repro we would be glad to look into it! Auto increment and bindvar support are both on our roadmap.

zachmu avatar Apr 30 '20 04:04 zachmu

Thanks for the tip zachmu! I'll definitely give it a shot.

frioux avatar Apr 30 '20 14:04 frioux