Open tednaleid opened 8 years ago
This isn't an issue with migrate, it's most likely due to the NATing from docker and the 3 minute pause is probably a 180 second timeout somewhere. Can you try by setting --net=host in your docker command, something like this:
docker run -d --net=host --name=cassandra -p 9042:9042 cassandra:2.2.3
Without the --net=host I'm getting the 3 minute pauses you experienced and with it I'm back to 2 seconds or so for completion.
I caught this problem too, but my cassandra not in docker.
I wrote the following script using only gocql
package main
import (
"fmt"
"log"
"github.com/gocql/gocql"
)
func main() {
cluster := gocql.NewCluster("10.54.29.171")
cluster.ProtoVersion = 4
cluster.Authenticator = gocql.PasswordAuthenticator{Username: "cassandra", Password: "cassandra", }
cluster.Keyspace = "myksp"
cluster.Consistency = gocql.All
session, err := cluster.CreateSession()
if err != nil {
fmt.Println(err)
}
defer session.Close()
var version int
if err := session.Query(`SELECT version FROM schema_migrations WHERE versionrow = ? limit 1`,
1).Consistency(gocql.One).Scan(&version); err != nil {
log.Fatal(err)
}
fmt.Println("Version:", version)
}
And my results are good. Correct version and very fast.
$ time go run main.go
Version: 1
real 0m2.456s
But then I used script with migrate
package main
import (
"fmt"
_ "github.com/mattes/migrate/driver/cassandra"
"github.com/mattes/migrate/migrate"
)
func main() {
version, err := migrate.Version("cassandra://cassandra:cassandra@10.54.29.171/myksp?protocol=4", "/home/migrations")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(version)
}
I'm getting 3 minutes pause and incorrect version value:
$ time go run main.go
0
real 3m0.408s
This issue is resolved in the latest 1.4.1 version of the Gemnasium fork: https://github.com/gemnasium/migrate/pull/17
This is still true
Fyi, The gemnasium fork is in the process of being moved to https://github.com/db-journey.
What's the db journey and why is it a copy of this repo with no backlinks to migrate?
@nathany did you see the latest v3 efforts? https://github.com/mattes/migrate/tree/v3.0-prev
That's a question for @gravis. But I do see a back link in the README at https://github.com/db-journey/journey
Hadn't seen the v3 efforts, thanks for pointing that out.
Yeah, sorry, I was just looking at migrate repo. Reached out to him, see what he is up to.
That being said, v3 is looking really awesome. Sources are drivers, too now. Making it super simple to integrate with go-bindata for example. migrate v3 is a full rewrite. I have more news soon, once there is an actual release candidate.
I could have something configured wrong, but every command that I run through
migrate
takes very slightly over 3 minutes to run. This example migration does a simple select on an empty table:This create statement is just making a new set of cql files in the migrations directory:
I'm running against a docker container using this
docker-compose.yml
file and the IP above is thedocker-machine ip default
value:It feels like there's some sort of timeout going on within the
migrate
command or thegocql
stuff. Interaction with the cassandra instance viacqlsh
is speedy and normal, example running cqlsh directly inside the docker container:Has anyone seen weird 3 minute pauses with the cassandra migrate driver?