503 error for bucket-flush
When I try to flush a Couchbase bucket using couchbase-cli, I get a 503 error:
$ bin/couchbase-cli bucket-flush -c localhost:8091 -u Administrator -p password --bucket=sessions
ERROR: unable to bucket-flush; please check your username (-u) and password (-p); (503) Service Unavailable ERROR: command: bucket-flush: localhost:8091, No JSON object could be decoded
The error is not cause by an authentication failure; I double-checked using ngrep.
Can't I use couchbase-cli bucket-flush on Couchbase buckets? Thanks.
Yes, it fails repeteadly. The REST request that fails is:
POST /pools/default/buckets/sessions/controller/doFlush HTTP/1.1. Host: localhost:8091. Accept-Encoding: identity. Content-type: application/x-www-form-urlencoded. Authorization: Basic QWRtaW5pc3RyYXRvcjoxMjM0NTY=.
Are you able to access the admin console and flush the bucket using that? Also, can you run the following command and paste the output here.
/opt/couchbase/bin/cbstats localhost:11210 all | grep flush
I'm confused. I checked the documentation to learn how to flush via admin console (which I couldn't find) and noticed this:
As of Couchbase 1.6 bucket flushing via REST API is not supported. Flushing via Couchbase SDKs as of Couchbase Server 1.8.1 is disabled by default.
couchbase-cli uses the REST API, doesn't it? If it's not supported, why is there a bucket-flush command in couchbase-cli?
Here's the output of cbstats localhost:11210 all | grep flush:
cmd_flush: 0 ep_flush_all: false ep_flush_duration: 0 ep_flush_duration_highwat: 0 ep_flush_duration_total: 0 ep_flush_preempts: 0 ep_flusher_deduplication: 0 ep_flusher_state: running ep_flusher_todo: 0 ep_item_flush_expired: 0 ep_item_flush_failed: 0
Does this fail repeatedly? I have noticed that from time to time a command sent to the rest API will return this, but if I retry I will end up getting a success message. Also, we use the same rest API from the admin console so there is actually no difference from sending the rest call from the cli as long as you supply all of the correct parameters.