[Groonga-commit] droonga/droonga-engine at cb07b81 [master] Rescue unexpected exceptions while joining

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Mar 26 20:11:58 JST 2015


YUKI Hiroshi	2015-03-26 20:11:58 +0900 (Thu, 26 Mar 2015)

  New Revision: cb07b815397a4e41c80a2382f24a7c8bdbbe4f92
  https://github.com/droonga/droonga-engine/commit/cb07b815397a4e41c80a2382f24a7c8bdbbe4f92

  Message:
    Rescue unexpected exceptions while joining

  Modified files:
    bin/droonga-engine-join
    lib/droonga/data_absorber.rb

  Modified: bin/droonga-engine-join (+20 -3)
===================================================================
--- bin/droonga-engine-join    2015-03-26 19:49:08 +0900 (d12a8dd)
+++ bin/droonga-engine-join    2015-03-26 20:11:58 +0900 (bc4865f)
@@ -43,13 +43,21 @@ class JoinCommand
     puts ""
 
     set_node_role
-    update_existing_nodes
+    begin
+    register_to_existing_nodes
     do_join
     copy_data unless @options["no-copy"]
     set_effective_message_timestamp
     reset_node_role
     puts("Done.")
     exit(true)
+    rescue Exception => exception
+      puts("Unexpected exception: #{exception.message}")
+      puts(exception.backtrace.join("\n"))
+      unregister_from_existing_nodes
+      reset_node_role
+      exit(false)
+    end
   end
 
   private
@@ -238,8 +246,8 @@ class JoinCommand
     end
   end
 
-  def update_existing_nodes
-    puts("Update existing hosts in the cluster...")
+  def register_to_existing_nodes
+    puts("Register new node to existing hosts in the cluster...")
     run_remote_command(source_node, "add_replicas",
                        "cluster_id" => source_cluster_id,
                        "dataset" => @options[:dataset],
@@ -247,6 +255,15 @@ class JoinCommand
     wait_until_restarted(source_node)
   end
 
+  def unregister_from_existing_nodes
+    puts("Unregister new node from existing hosts in the cluster...")
+    run_remote_command(source_node, "remove_replicas",
+                       "cluster_id" => source_cluster_id,
+                       "dataset" => @options[:dataset],
+                       "hosts"   => [@options[:host]])
+    wait_until_restarted(source_node)
+  end
+
   def trap_signals
     trap(:TERM) do
       do_cancel

  Modified: lib/droonga/data_absorber.rb (+2 -1)
===================================================================
--- lib/droonga/data_absorber.rb    2015-03-26 19:49:08 +0900 (1657ab5)
+++ lib/droonga/data_absorber.rb    2015-03-26 20:11:58 +0900 (71474e4)
@@ -207,7 +207,8 @@ module Droonga
     def source_tables
       response = source_client.request("dataset" => @dataset,
                                        "type"    => "table_list")
-      body = response["body"][1]
+      message_body = response["body"]
+      body = message_body[1]
       tables = body[1..-1]
       tables.collect do |table|
         table[1]
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index