fastmonkeys / stellar

Fast database snapshot and restore tool for development
MIT License
3.86k stars 119 forks source link

Trying to create database with name too long for MySQL #11

Closed phacops closed 9 years ago

phacops commented 10 years ago

Stellar generates a database name for the snapshot and the name is simply too long. It should be only 32 characters long.

Here is the backtrace:

(stellar)phacops@panda:~/code/snapshots$ stellar snapshot
Snapshotting database inventory_production
Traceback (most recent call last):
  File "/home/phacops/env/stellar/bin/stellar", line 9, in <module>
    load_entry_point('stellar==0.3.1', 'console_scripts', 'stellar')()
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/stellar/command.py", line 225, in main
    stellar()
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/click/core.py", line 572, in __call__
    return self.main(*args, **kwargs)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/click/core.py", line 552, in main
    rv = self.invoke(ctx)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/click/core.py", line 893, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/click/core.py", line 744, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/click/core.py", line 388, in invoke
    return callback(*args, **kwargs)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/stellar/command.py", line 51, in snapshot
    app.create_snapshot(name, before_copy=before_copy)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/stellar/app.py", line 114, in create_snapshot
    table.get_table_name('master')
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/stellar/operations.py", line 50, in copy_database
    create_database(raw_conn, to_database)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/stellar/operations.py", line 31, in create_database
    '%s%s' % (raw_conn.engine.url, database)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/sqlalchemy_utils/functions/database.py", line 215, in create_database
    engine.execute(text)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1752, in execute
    return connection.execute(statement, *multiparams, **params)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 721, in execute
    return self._execute_text(object, multiparams, params)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 870, in _execute_text
    statement, parameters
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 958, in _execute_context
    context)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1160, in _handle_dbapi_exception
    exc_info
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 199, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 951, in _execute_context
    context)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 436, in do_execute
    cursor.execute(statement, parameters)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/pymysql/cursors.py", line 132, in execute
    result = self._query(query)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/pymysql/cursors.py", line 271, in _query
    conn.query(q)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/pymysql/connections.py", line 726, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/pymysql/connections.py", line 861, in _read_query_result
    result.read()
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/pymysql/connections.py", line 1064, in read
    first_packet = self.connection._read_packet()
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/pymysql/connections.py", line 826, in _read_packet
    packet.check_error()
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/pymysql/connections.py", line 370, in check_error
    raise_mysql_exception(self._data)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/pymysql/err.py", line 116, in raise_mysql_exception
    _check_mysql_exception(errinfo)
  File "/home/phacops/env/stellar/local/lib/python2.7/site-packages/pymysql/err.py", line 112, in _check_mysql_exception
    raise InternalError(errno, errorvalue)
sqlalchemy.exc.InternalError: (InternalError) (1059, u"Identifier name 'stellar_inventory_production_b2351a3af7a734da97aca294f9128206_master' is too long") "CREATE DATABASE stellar_inventory_production_b2351a3af7a734da97aca294f9128206_master CHARACTER SET = 'utf8'" ()
(stellar)phacops@panda:~/code/snapshots$ 
elsurudo commented 10 years ago

+1

It would be nice if the project name would be used for the prefix, but instead, it seems to use the database name, which may be long (and which I can't do anything about!).

kevinjalbert commented 10 years ago

+1 I have the exact same issue, which prevents me from using this for local development.

reksc commented 10 years ago

I get "Incorrect database name" error, I think that for the same reason.

MySQL 5.6.17

rossmcf commented 10 years ago

+1 Same here.

sqlalchemy.exc.InternalError: (InternalError) (1059, u"Identifier name 'stellar_e2e_commerce_20140908142810_156566042c1a91f25d2e3f7bf4d41845_master' is too long") "CREATE DATABASE stellar_e2e_commerce_20140908142810_156566042c1a91f25d2e3f7bf4d41845_master CHARACTER SET = 'utf8'" ()
mechastorm commented 10 years ago

Any news on this? I also get the same error

sqlalchemy.exc.ProgrammingError: (ProgrammingError) (1102, u"Incorrect database name 'stellar_bxxxxxxxx_byyyyyy_cdaef62f069a8d0c1afef86f193e1590_master'") "CREATE DATABASE stellar_bxxxxxxxx_byyyyyy_cdaef62f069a8d0c1afef86f193e1590_master CHARACTER SET = 'utf8'" ()