OpenSIPS / opensips-cli

OpenSIPS CLI tool - an interactive command line tool that can be used to control and monitor OpenSIPS servers.
GNU General Public License v3.0
85 stars 48 forks source link

Migrate database error #61

Closed abieuzent closed 4 years ago

abieuzent commented 4 years ago

I'm trying to migrate my database from 2.4 to 3.0 and this error on 2 tables

opensips-cli -x database migrate 2.4_to_3.0 lbsip_glo_in_2_4 lbsip_glo_in_3_0 Password for admin MySQL user (root): Creating database lbsip_glo_in_3_0... ERROR: (_mysql_exceptions.OperationalError) (1136, "Column count doesn't match value count at row 1") [SQL: CALL lbsip_glo_in_2_4.OSIPS_TB_COPY_2_4_TO_3_0('lbsip_glo_in_2_4', 'lbsip_glo_in_3_0', 'clusterer')] (Background on this error at: http://sqlalche.me/e/e3q8) Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context cursor, statement, parameters, context File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute cursor.execute(statement, parameters) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute self.errorhandler(self, exc, value) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler raise errorvalue File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute res = self._query(query) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query db.query(q) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query _mysql.connection.query(self, query) _mysql_exceptions.OperationalError: (1136, "Column count doesn't match value count at row 1")

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/db.py", line 755, in migrate old_db, proc_tb_migrate, old_db, new_db, tb))) File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 988, in execute return meth(self, multiparams, params) File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement distilled_params, File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1248, in _execute_context e, statement, parameters, cursor, context File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception util.raise_from_cause(sqlalchemy_exception, exc_info) File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=cause) File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context cursor, statement, parameters, context File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute cursor.execute(statement, parameters) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute self.errorhandler(self, exc, value) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler raise errorvalue File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute res = self._query(query) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query db.query(q) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query _mysql.connection.query(self, query) sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1136, "Column count doesn't match value count at row 1") [SQL: CALL lbsip_glo_in_2_4.OSIPS_TB_COPY_2_4_TO_3_0('lbsip_glo_in_2_4', 'lbsip_glo_in_3_0', 'clusterer')] (Background on this error at: http://sqlalche.me/e/e3q8) ERROR: Failed to migrate 'clusterer' table data, see above errors! ERROR: (_mysql_exceptions.OperationalError) (1136, "Column count doesn't match value count at row 1") [SQL: CALL lbsip_glo_in_2_4.OSIPS_TB_COPY_2_4_TO_3_0('lbsip_glo_in_2_4', 'lbsip_glo_in_3_0', 'location')] (Background on this error at: http://sqlalche.me/e/e3q8) Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context cursor, statement, parameters, context File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute cursor.execute(statement, parameters) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute self.errorhandler(self, exc, value) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler raise errorvalue File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute res = self._query(query) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query db.query(q) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query _mysql.connection.query(self, query) _mysql_exceptions.OperationalError: (1136, "Column count doesn't match value count at row 1")

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/db.py", line 755, in migrate old_db, proc_tb_migrate, old_db, new_db, tb))) File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 988, in execute return meth(self, multiparams, params) File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement distilled_params, File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1248, in _execute_context e, statement, parameters, cursor, context File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception util.raise_from_cause(sqlalchemy_exception, exc_info) File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=cause) File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context cursor, statement, parameters, context File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute cursor.execute(statement, parameters) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute self.errorhandler(self, exc, value) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler raise errorvalue File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute res = self._query(query) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query db.query(q) File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query _mysql.connection.query(self, query) sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1136, "Column count doesn't match value count at row 1") [SQL: CALL lbsip_glo_in_2_4.OSIPS_TB_COPY_2_4_TO_3_0('lbsip_glo_in_2_4', 'lbsip_glo_in_3_0', 'location')] (Background on this error at: http://sqlalche.me/e/e3q8) ERROR: Failed to migrate 'location' table data, see above errors! Finished copying OpenSIPS table data into database 'lbsip_glo_in_3_0'!

liviuchircu commented 4 years ago

hey @abieuzent - it seems something went wrong with the clusterer and location tables. Did everything else get migrated properly, both tables and their data?

Also, could you please run SHOW CREATE TABLE clusterer and SHOW CREATE TABLE location in your existing lbsip_glo_in_2_4 database and provide the output? Thanks!

abieuzent commented 4 years ago

Hi Liviu,

Yes all other tables are migrated properly with data.

'CREATE TABLE clusterer (

  id int(10) NOT NULL AUTO_INCREMENT,

  cluster_id int(10) NOT NULL,

  node_id int(10) NOT NULL,

  url char(64) NOT NULL,

  state int(1) NOT NULL DEFAULT ''1'',

  ls_seq_no int(10) NOT NULL DEFAULT ''0'',

  top_seq_no int(10) NOT NULL DEFAULT ''0'',

  no_ping_retries int(10) NOT NULL DEFAULT ''3'',

  priority int(10) NOT NULL DEFAULT ''50'',

  sip_addr char(64) DEFAULT NULL,

  description char(64) DEFAULT NULL,

  PRIMARY KEY (id),

  UNIQUE KEY clusterer_idx (cluster_id,node_id)

) ENGINE=InnoDB DEFAULT CHARSET=latin1'

'CREATE TABLE location (

  contact_id bigint(10) unsigned NOT NULL AUTO_INCREMENT,

  username char(64) NOT NULL DEFAULT '''',

  domain char(64) DEFAULT NULL,

  contact char(255) NOT NULL DEFAULT '''',

  received char(255) DEFAULT NULL,

  path char(255) DEFAULT NULL,

  expires datetime NOT NULL DEFAULT ''2020-05-28 21:32:15'',

  q float(10,2) NOT NULL DEFAULT ''1.00'',

  callid char(255) NOT NULL DEFAULT ''Default-Call-ID'',

  cseq int(11) NOT NULL DEFAULT ''13'',

  last_modified datetime NOT NULL DEFAULT ''1900-01-01 00:00:01'',

  flags int(11) NOT NULL DEFAULT ''0'',

  cflags char(255) DEFAULT NULL,

  user_agent char(255) NOT NULL DEFAULT '''',

  socket char(64) DEFAULT NULL,

  methods int(11) DEFAULT NULL,

  sip_instance char(255) DEFAULT NULL,

  attr char(255) DEFAULT NULL,

  PRIMARY KEY (contact_id)

) ENGINE=InnoDB DEFAULT CHARSET=latin1'

Regards

De : Alain BIEUZENT alain.bieuzent@free.fr Date : vendredi 26 juin 2020 à 23:05 À : Alain Bieuzent a.bieuzent@manifone.com Objet : Fwd: [OpenSIPS/opensips-cli] Migrate database error (#61)

Début du message transféré :

Expéditeur: Liviu Chircu notifications@github.com Date: 24 juin 2020 à 18:20:11 UTC+2 Destinataire: OpenSIPS/opensips-cli opensips-cli@noreply.github.com Cc: abieuzent alain.bieuzent@free.fr, Mention mention@noreply.github.com Objet: Rép. : [OpenSIPS/opensips-cli] Migrate database error (#61) Répondre à: OpenSIPS/opensips-cli reply@reply.github.com



hey @abieuzent - it seems something went wrong with the clusterer and location tables. Did everything else get migrated properly, both tables and their data?

Also, could you please run SHOW CREATE TABLE clusterer and SHOW CREATE TABLE location in your existing lbsip_glo_in_2_4 database and provide the output? Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

liviuchircu commented 4 years ago

Perfect! Out of curiosity, how did you create your 2.4 database tables? Because both clusterer and location seem to be in the 2.3 format. Did you migrate them from 2.3 using the opensipsdbctl migrate tool?

abieuzent commented 4 years ago

I Believe, yes i migrate from 2.3 to 2.4 with opensipsctl tools, but now i have a doubt …

Thanks for your reply

De : Liviu Chircu notifications@github.com Répondre à : OpenSIPS/opensips-cli reply@reply.github.com Date : lundi 29 juin 2020 à 13:41 À : OpenSIPS/opensips-cli opensips-cli@noreply.github.com Cc : abieuzent alain.bieuzent@free.fr, Mention mention@noreply.github.com Objet : Re: [OpenSIPS/opensips-cli] Migrate database error (#61)

Perfect! Out of curiosity, how did you create your 2.4 database tables? Because both clusterer and location seem to be in the 2.3 format. Did you migrate them from 2.3 using the opensipsdbctl migrate tool?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

liviuchircu commented 4 years ago

I did a test with the 2.4 opensipsdbctl create and opensipsdbctl migrate commands, with both the location and clusterer tables being created just fine. I suggest we file this one under the "X files" topic and close it -- if you manage to reproduce this issue again using the standard tools/procedures, please re-open.

Cheers!