Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating replication from script causes replication status to hang on 'Starting Up' #49

Closed
philipobrien opened this issue Nov 4, 2014 · 3 comments

Comments

@philipobrien
Copy link

I have a simple bash script to which I pass either the option create or delete as the first argument, and the second argument will be the name of the couchbase bucket (and corresponding elasticsearch index) that the XDCR should be configured for.

#!/usr/bin/env bash

INDEX=$2

if [ $1 = "create" ]; then
    echo creating index ${INDEX}
    indexResult=$(curl -s -XPUT "http://localhost:9200/${INDEX}" -d '{"index":{"analysis":{"analyzer":{"default":{"type":"whitespace","tokenizer":"whitespace"}}}}}')

    if [[ ${indexResult} == *true* ]]; then
        echo created index successfully
    fi

    echo creating bucket ${INDEX}
    bucketResult=$(sudo /opt/couchbase/bin/couchbase-cli bucket-create -c 127.0.0.1:8091 --bucket=${INDEX} --bucket-type=couchbase --bucket-ramsize=100 --bucket-replica=0 -u admin -p password)

    if [[ ${bucketResult} == *SUCCESS* ]]; then
        echo created bucket successfully
    fi

    curl -v -X POST -u admin:password http://localhost:8091/controller/createReplication -d fromBucket=${INDEX} -d toCluster=elasticsearch -d toBucket=${INDEX} -d replicationType=continuous -d type=capi

fi

This seems to work correctly in that the couchbase UI shows the following

image

The replication status hangs on Starting Up, but if I were to simply click Settings and Save without changing anything the status switches to Replicating

image

@mschoch
Copy link
Contributor

mschoch commented Nov 4, 2014

I tested starting a replication here with the same curl command (with a few names changed obviously) and mine did seem to transition to replicating on its own.

My first guess is that you need to wait a little bit after creating the bucket. I believe it is not entirely synchronous, and there still may be some bucket set up going on. Then when you start the replication, the bucket exists enough that it is a valid option, but perhaps its still too soon for a valid transition to the replicating state.

I would suggest trying what I did, just run the last curl command on its own, long after the index and bucket are created just to confirm that you see the same behavior as me. Then, if that works, try putting a modest sleep call between the bucket creation and replication start. (I am not aware of any other endpoint you could poll to be sure its ready, but you could ask this on Couchbase list).

Also, I tested against 3.0.0.

@philipobrien
Copy link
Author

Right you were, I ran the bash script (without the xdcr command), and pasted the xdcr into the terminal almost straight away. The status transitioned straight into replicating. I'll throw in the sleep call for the moment, and if I find a suitable endpoint to poll I'll update here. Thanks

@philipobrien
Copy link
Author

OK, turns out there is an easy fix, just use the --wait option when creating a bucket, which will wait for bucket create to complete before returning.

bucketResult=$(sudo /opt/couchbase/bin/couchbase-cli bucket-create --wait -c 127.0.0.1:8091 --bucket=${INDEX} --bucket-type=couchbase --bucket-ramsize=100 --bucket-replica=0 -u admin -p password)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants