migrate icon indicating copy to clipboard operation
migrate copied to clipboard

all cassandra migrate commands take 3+ minutes to execute

Open tednaleid opened this issue 9 years ago • 9 comments

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:

migrate -url cassandra://192.168.99.100/items -path ./migrations migrate +1
> 0001_foobar.up.cql

3.0054 minutes

This create statement is just making a new set of cql files in the migrations directory:

time migrate -url cassandra://192.168.99.100/items -path ./migrations create foobar3
Version 3 migration files created in ./migrations:
0003_foobar3.up.cql
0003_foobar3.down.cql
migrate -url cassandra://192.168.99.100/items -path ./migrations create   0.01s user 0.02s system 0% cpu 3:00.28 total

I'm running against a docker container using this docker-compose.yml file and the IP above is the docker-machine ip default value:

cassandra:
  image: library/cassandra:2.2.3
  ports:
    - "9160:9160"
    - "9042:9042"
  volumes:
    - ./migrations:/migrations

It feels like there's some sort of timeout going on within the migrate command or the gocql stuff. Interaction with the cassandra instance via cqlsh is speedy and normal, example running cqlsh directly inside the docker container:

time docker exec -it migratetest_cassandra_1 cqlsh -f migrations/0001_foobar.up.cql

 count
-------
     0

(1 rows)

Warnings :
Aggregation query used without partition key

docker exec -it migratetest_cassandra_1 cqlsh -f migrations/0001_foobar.up.cql  0.14s user 0.01s system 25% cpu 0.563 total

Has anyone seen weird 3 minute pauses with the cassandra migrate driver?

tednaleid avatar Mar 12 '16 20:03 tednaleid

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.

mojotalantikite avatar Apr 12 '16 22:04 mojotalantikite

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:[email protected]/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

shreyderina avatar Oct 24 '16 10:10 shreyderina

This issue is resolved in the latest 1.4.1 version of the Gemnasium fork: https://github.com/gemnasium/migrate/pull/17

nathany avatar Dec 19 '16 20:12 nathany

This is still true

JulienTant avatar Feb 10 '17 12:02 JulienTant

Fyi, The gemnasium fork is in the process of being moved to https://github.com/db-journey.

nathany avatar Feb 13 '17 17:02 nathany

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

mattes avatar Feb 13 '17 17:02 mattes

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.

nathany avatar Feb 13 '17 17:02 nathany

Yeah, sorry, I was just looking at migrate repo. Reached out to him, see what he is up to.

mattes avatar Feb 13 '17 17:02 mattes

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.

mattes avatar Feb 13 '17 17:02 mattes