Java SDK 1.1.1 - Avoid runtime exceptions during deletion
Hello,
I´ve big issues with those synchronous implementation of couchbase requests in the JAVA Api. Unfortunately I can never just find out, in what state the server actually is.
My singleton implementation of the client holds the connection. And because there is no possibility for me to get the delta between old and new data, I have to flush/delete the bucket and create a new one.
Because I have an huge amount of data, flushing the bucket forces Runtime Exceptions due to request timeouts after 60 seconds and is not usable.
After the connected client has nothing to do for hours (lets say 6h - and this is the only reasonable answer to me), I just instanciate a ClusterManager to delete the bucket. The deletetion after this period of "sleeping" always ends with
java.lang.RuntimeException: Http Error: 500 Reason: Internal Server Error Details: No reason given
Of course, the Admin API describes this timeout http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-admin-resta..., but how to check if it is deleted or not?
The most upsetting thing about is, that the bucket is deleted actually and there is no way to create the bucket in the next step.
Because when I handle this exception, I´ll try to create the bucket again through a fresh instance of ClusterManager and always got this error
java.lang.RuntimeException: Http Error: 503 Reason: Service Unavailable Details: No reason given
So please tell me, how the hack will my application ever be available, if this part fails every night and I have to restart my application to have a connected client????? Is the server in a sleep mode after a while and how do I avoid this? I mean, as long as my client has a connection, this should never happen... This is a show stopper for an productive environment.
Thanks
Regards,
A.
Hi Mike,
thank you for your response. For the moment I tried out an other solution which actually works for the case.
But to help you I want to highlight, that I only recieved those errors when:
1. There was an established connection in my client to the bucket.
2. The client had nothing to do for a few hours because the other bucket was used as the productive one, it also could be that both weren´t used.
3. Deleting failed after exactly 30 seconds (maybe it would run through without the request timeout).
4. Recreation failed because deletion was not complete (Bucket is still deleting or warming up or server is warming up, etc.) and there is no way to find out a buckets state during/before/after those operations.
Hope it will help to reproduce the error.
Best,
alemar
First off I wouldn't recommend flushing buckets especially if you have a lot of data. The reason is that flush happens asynchronously on the server so even though the server responds quickly it may actually take a lot of time to delete the data from disk and during this time operations that happen after you send the flush have to wait until after the flush actually finishes on the server. You may be wondering why we have the flush capability if it can cause problems and the reasons are to remain compatible with the memcached protocol and also because the feature has less overhead when writing small application tests against the server. Anyways, in most cases we encourage users not to use the functionality if the can avoid.
I can see that after trying flush you then tried to do the recommended thing and delete and recreate the bucket, but your running into a few issues with runtime exceptions. The only time I have run into this issue is when I have been creating and deleting buckets really fast. For example, when we switched our unit tests off of flush and moved to deleting and recreating buckets we were doing this process many times per second. What I did was wrote this class which I have linked below.
https://github.com/couchbase/couchbase-java-client/blob/master/src/test/...
I think this should help you out, but in my mind this should just work out of the box for you and you shouldn't have to use the code I provided above. While I haven't heard of this issue happening frequently it is something I would like to see fixed so I have also filed an issue below for this problem. You can follow it to see our progress. Please also let me know if you have any questions about the code I linked to above or if you run into any problems with it. I will also add an example file where I used the code.
https://github.com/couchbase/couchbase-java-client/blob/master/src/test/...
http://www.couchbase.com/issues/browse/MB-7709
- Mike