Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Appengine how to delete all entities in a namespace - Java

I use namespace for managing multitenancy. I need to know if there is an easy way to delete all the entities.

I know I can use mapreduce but all the examples I have seen invoke the mapper from the servlet config but I need to pass on the namespace string dynamically when a user chooses to close account.

like image 319
cloudpre Avatar asked Oct 07 '22 21:10

cloudpre


2 Answers

I think this feature is available just for the Python side, unluckily for the Java runtime the feature-request is still Open.

like image 186
systempuntoout Avatar answered Oct 10 '22 11:10

systempuntoout


After research, mapreduce cannot be invoked with namespace in entity search. This could have been the best route.

The only way is to

  • Create a task queue to delete entire namespace
  • Fetch all kinds in a namespace. Use deferred tasks to delete each kind
  • For each kind, fetch entities (keys only). You can do a batch delete. This may timeout if you have lot and lot of entities. But since you are getting only the keys and doing a batch delete - I do not see that to be an issue. Otherwise, you can a backend and point this task so that it does not timeout.
like image 28
cloudpre Avatar answered Oct 10 '22 09:10

cloudpre