thelastpickle / cassandra-medusa

Apache Cassandra Backup and Restore Tool
Apache License 2.0
263 stars 142 forks source link

error during restore-cluster with "--use-sstableloader" option #509

Open kaushalkumar opened 2 years ago

kaushalkumar commented 2 years ago

Project board link

Hi - We are trying to restore cassandra data store cluster using medusa's restore-cluster command. The command fails with the error as "AttributeError: 'NoneType' object has no attribute 'new_session'".

We are using the following command for restore. Can you please check and let us know where are we going wrong.

Version: [cqlsh 5.0.1 | Cassandra 3.11.11 | CQL spec 3.4.4 | Native protocol v4], Medusa [0.13.3]

Command: sudo medusa restore-cluster --backup-name=data1 --host-list=/root/host-mapping.csv --use-sstableloader

Error Stack:

[2022-07-22 02:12:52,872] ERROR: This error happened during the cluster restore: 'NoneType' object has no attribute 'new_session'
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/medusa/restore_cluster.py", line 71, in orchestrate
    restore.execute()
  File "/usr/local/lib/python3.6/site-packages/medusa/restore_cluster.py", line 154, in execute
    self._restore_data()
  File "/usr/local/lib/python3.6/site-packages/medusa/restore_cluster.py", line 349, in _restore_data
    self._restore_schema()
  File "/usr/local/lib/python3.6/site-packages/medusa/restore_cluster.py", line 411, in _restore_schema
    with self.session_provider.new_session() as session:
AttributeError: 'NoneType' object has no attribute 'new_session'

┆Issue is synchronized with this Jira Story by Unito

adejanovski commented 2 years ago

There's a bug indeed. The code path where the host-list is provided doesn't initialize the session_provider object. In the meantime, you can use a seed node instead of a host-list, which will compute the mapping for you.

adejanovski commented 2 years ago

The fix will be to use any of the provided target hosts as seed node to connect to the cluster, and initialize the session_provider.

kaushalkumar commented 2 years ago

Hi @adejanovski - Thanks for suggesting the workaround. There was one observation - The hostname mapping was created by medusa. Although the source and target hostnames were same, still the mapping was in different order.

[2022-07-27 09:12:52,017] INFO: About to restore on node2-dc1.domain.com using {'source': ['node3-dc1.domain.com'], 'seed': True} as backup source
[2022-07-27 09:12:52,018] INFO: About to restore on node1-dc1.domain.com using {'source': ['node1-dc1.domain.com'], 'seed': True} as backup source
[2022-07-27 09:12:52,018] INFO: About to restore on node3-dc1.domain.com using {'source': ['node2-dc1.domain.com'], 'seed': False} as backup source