Deleting Project space from locally installed commcarehq


(Demisew Abera) #1

I was trying to delete test project space from locally installed commcarehq server. I have a lot of duplicate and test projects.

i tried with a command:

./manage delete_domain <domain-name>

But it’s not working. projects are still displaying


(Simon Kelly) #2

Where is the project still displaying? It could be that it’s not getting removed from Elasticsearch or some Redis cache. If you aren’t running pillows locally then the domain won’t be removed from ES.

Have you tried reindexing your ES domain index:

$ ./manage.py ptop_reindexer_v2 domain --cleanup

(Demisew Abera) #3

yes simon i have applied the command

./manage.py ptop_reindexer_v2 domain --cleanup

deleted projects stiil exists
Admin->Admin Reports->Project space List

I also restarted elasticsearch redis and couchdb2


(Simon Kelly) #4

Interesting, if you ran the reindex and the domain is still there then it means it’s still in Couch. You can verify that by checking the domain view: http://localhost:5984/commcarehq__domains/_design/domain/_view/domains?reduce=false

If it is indeed still in Couch then try running the delete command again.

We don’t often delete domains so it’s possible that there is a bug in that command.


(Demisew Abera) #5

yes i tried to delete with the following cmd: ./manage.py delete_domain echis-test then i got the following error.
File "/home/cchq/www/echis/releases/2019-03-01_15.13/python_env/local/lib/python2.7/site-packages/requests/models.py", line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 413 Client Error: Request Entity Too Large for url: http://172.19.3.41:25984/commcarehq__apps/_bulk_docs Sentry is attempting to send 1 pending error messages

When i tried to delete with a command:
./manage.py hard_delete_forms_and_cases_in_domain echis-test it completed successfully. But after that domains still existed on couchdb.

curl http://localhost:25984/commcarehq__domains/_design/domain/_view/domains?reduce=false

{"total_rows":14,"offset":0,"rows":[ {"id":"0aac8a73d05bf1ec84b935cc28063891","key":"echis-prod","value":null}, {"id":"3bffd0d42ceaabc145c9468153d95711","key":"echis-staging","value":null}, {"id":"57fd2aad42e470550d0325dfed1a94b3","key":"echis-test","value":null}


(Simon Kelly) #6

Can you give more of the stacktrace for the error so I can see where it came from.

Have you tried doing the delete domain command again after running hard_delete_forms_and_cases_in_domain?

Also the hard_delete_forms_and_cases_in_domain only deletes forms and cases that have been tagged as deleted. It won’t delete normal forms or cases.


(Demisew Abera) #7

Yes I have tried hard_delete_forms_and_cases_in_domain completed without error.

2019-03-13 09:29:24,381 INFO Hard deleting forms... Started at 2019-03-13 09:29:24 Processing [..................................................] 0/0 100% 0:00:00.000092 elapsed Finished at 2019-03-13 09:29:24 Elapsed time: 0:00:00 2019-03-13 09:29:24,387 INFO Hard deleting cases... Started at 2019-03-13 09:29:24 Processing [..................................................] 0/0 100% 0:00:00.000079 elapsed Finished at 2019-03-13 09:29:24 Elapsed time: 0:00:00 2019-03-13 09:29:24,400 INFO Done.

This is an output when i run the following command ./manage.py delete_domain echis-test

Deleting domain echis-test Traceback (most recent call last): File "./manage.py", line 173, in <module> execute_from_command_line(sys.argv) File "/home/cchq/www/echis/releases/2019-03-01_15.13/python_env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line utility.execute() File "/home/cchq/www/echis/releases/2019-03-01_15.13/python_env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/cchq/www/echis/releases/2019-03-01_15.13/python_env/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "/home/cchq/www/echis/releases/2019-03-01_15.13/python_env/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute output = self.handle(*args, **options) File "/home/cchq/www/echis/releases/2019-03-01_15.13/corehq/apps/domain/management/commands/delete_domain.py", line 44, in handle domain_obj.delete() File "/home/cchq/www/echis/releases/2019-03-01_15.13/corehq/apps/domain/models.py", line 934, in delete self._pre_delete() File "/home/cchq/www/echis/releases/2019-03-01_15.13/corehq/apps/domain/models.py", line 954, in _pre_delete iter_bulk_delete(db, related_doc_ids, chunksize=500) File "/home/cchq/www/echis/releases/2019-03-01_15.13/corehq/ex-submodules/dimagi/utils/couch/database.py", line 104, in iter_bulk_delete database.bulk_delete(doc_dicts) File "/home/cchq/www/echis/releases/2019-03-01_15.13/python_env/local/lib/python2.7/site-packages/couchdbkit/client.py", line 652, in delete_docs return self.bulk_save(docs, use_uuids=False, **params) File "/home/cchq/www/echis/releases/2019-03-01_15.13/python_env/local/lib/python2.7/site-packages/couchdbkit/client.py", line 599, in save_docs res.raise_for_status() File "/home/cchq/www/echis/releases/2019-03-01_15.13/python_env/local/lib/python2.7/site-packages/requests/models.py", line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 413 Client Error: Request Entity Too Large for url: http://172.19.3.41:25984/commcarehq__apps/_bulk_docs Sentry is attempting to send 1 pending error messages Waiting up to 10 seconds Press Ctrl-C to quit 2019-03-13 09:34:09,572 ERROR [u'HTTPError: 413 Client Error: Request Entity Too Large for url: http://172.19.3.41:25984/commcarehq__apps/_bulk_docs', u' File "manage.py", line 173, in <module>', u' File "django/core/management/__init__.py", line 364, in execute_from_command_line', u' File "django/core/management/__init__.py", line 356, in execute', u' File "django/core/management/base.py", line 283, in run_from_argv', u' File "django/core/management/base.py", line 330, in execute', u' File "corehq/apps/domain/management/commands/delete_domain.py", line 44, in handle', u' File "corehq/apps/domain/models.py", line 934, in delete', u' File "corehq/apps/domain/models.py", line 954, in _pre_delete', u' File "dimagi/utils/couch/database.py", line 104, in iter_bulk_delete', u' File "couchdbkit/client.py", line 652, in delete_docs', u' File "couchdbkit/client.py", line 599, in save_docs', u' File "requests/models.py", line 940, in raise_for_status']