Skip to content

Commit

Permalink
CBQE-0: RQG:: Fix index build issues when there is no index to build
Browse files Browse the repository at this point in the history
Change-Id: I8c8573133f242bcc18a7746a5b698e6e3d8cf694
Reviewed-on: http://review.couchbase.org/51376
Reviewed-by: Parag Agarwal <agarwal.parag@gmail.com>
Tested-by: Parag Agarwal <agarwal.parag@gmail.com>
  • Loading branch information
Parag Agarwal authored and knotking committed May 22, 2015
1 parent 65fa145 commit 07b7259
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions pytests/rqg/test_rqg.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,22 +723,23 @@ def _generate_secondary_indexes_during_initialize(self, index_map = {}):
self.log.info(ex)
raise
# Run Build Query
try:
build_query = "BUILD INDEX on {0}({1}) USING GSI".format(table_name,",".join(build_index_list))
actual_result = self.n1ql_helper.run_cbq_query(query = build_query, server = self.n1ql_server)
self.log.info(actual_result)
except Exception, ex:
self.log.info(ex)
raise
# Monitor till the index is built
tasks = []
try:
for index_name in build_index_list:
tasks.append(self.async_monitor_index(bucket = table_name, index_name = index_name))
for task in tasks:
task.result()
except Exception, ex:
self.log.info(ex)
if build_index_list != None and len(build_index_list) > 0:
try:
build_query = "BUILD INDEX on {0}({1}) USING GSI".format(table_name,",".join(build_index_list))
actual_result = self.n1ql_helper.run_cbq_query(query = build_query, server = self.n1ql_server)
self.log.info(actual_result)
except Exception, ex:
self.log.info(ex)
raise
# Monitor till the index is built
tasks = []
try:
for index_name in build_index_list:
tasks.append(self.async_monitor_index(bucket = table_name, index_name = index_name))
for task in tasks:
task.result()
except Exception, ex:
self.log.info(ex)

def _generate_secondary_indexes_in_batches(self, batches):
defer_mode = str({"defer_build":True})
Expand All @@ -760,25 +761,26 @@ def _generate_secondary_indexes_in_batches(self, batches):
self.log.info(ex)
raise
# Run Build Query
try:
build_query = "BUILD INDEX on {0}({1}) USING GSI".format(table_name,",".join(build_index_list))
actual_result = self.n1ql_helper.run_cbq_query(query = build_query, server = self.n1ql_server)
self.log.info(actual_result)
except Exception, ex:
self.log.info(ex)
raise
# Monitor till the index is built
tasks = []
try:
for info in batches:
table_name = info["bucket"]
for index_name in info["indexes"]:
if index_name in build_index_list:
tasks.append(self.async_monitor_index(bucket = table_name, index_name = index_name))
for task in tasks:
task.result()
except Exception, ex:
self.log.info(ex)
if build_index_list != None and len(build_index_list) > 0:
try:
build_query = "BUILD INDEX on {0}({1}) USING GSI".format(table_name,",".join(build_index_list))
actual_result = self.n1ql_helper.run_cbq_query(query = build_query, server = self.n1ql_server)
self.log.info(actual_result)
except Exception, ex:
self.log.info(ex)
raise
# Monitor till the index is built
tasks = []
try:
for info in batches:
table_name = info["bucket"]
for index_name in info["indexes"]:
if index_name in build_index_list:
tasks.append(self.async_monitor_index(bucket = table_name, index_name = index_name))
for task in tasks:
task.result()
except Exception, ex:
self.log.info(ex)

def async_monitor_index(self, bucket, index_name = None):
monitor_index_task = self.cluster.async_monitor_index(
Expand Down

0 comments on commit 07b7259

Please sign in to comment.