Navigation Menu

Skip to content

Commit

Permalink
Update "accept_messages_newer_than" timestamp before absorbing.
Browse files Browse the repository at this point in the history
Because "system.absorb-data.end" can be forwarded before all restore messages are completely processed.
Restarting while restoring can stop the operation.
  • Loading branch information
piroor committed Apr 21, 2015
1 parent 1593ab1 commit adad427
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
13 changes: 12 additions & 1 deletion bin/droonga-engine-absorb-data
Expand Up @@ -44,6 +44,12 @@ module Droonga
puts ""
puts "Absorbing..."

succeeded = update_accept_messages_newer_than_timestamp
unless succeeded
do_cancel
return false
end

succeeded = absorb

if succeeded
Expand Down Expand Up @@ -238,7 +244,10 @@ module Droonga
end

puts ""
true
end

def update_accept_messages_newer_than_timestamp
timestamp = source_node_serf.last_processed_message_timestamp
unless timestamp
$stderr.puts("Couldn't get the time stamp of " +
Expand All @@ -248,9 +257,11 @@ module Droonga
if timestamp and not timestamp.empty?
puts "The timestamp of the last processed message in the source node: #{timestamp}"
puts "Setting effective message timestamp for the destination node..."
response = destination_node_serf.send_query("accept_messages_newer_than",
destination_node_serf.ensure_restarted do
destination_node_serf.send_query("accept_messages_newer_than",
"node" => destination_node.to_s,
"timestamp" => timestamp)
end
end
true
end
Expand Down
9 changes: 6 additions & 3 deletions bin/droonga-engine-join
Expand Up @@ -66,14 +66,14 @@ module Droonga
do_join
register_to_existing_nodes
set_source_node_role
update_accept_messages_newer_than_timestamp
if should_copy?
successed = copy_data
unless successed
do_cancel
return false
end
end
set_effective_message_timestamp
reset_source_node_role
reset_joining_node_role
puts("Done.")
Expand Down Expand Up @@ -317,7 +317,7 @@ module Droonga
true
end

def set_effective_message_timestamp
def update_accept_messages_newer_than_timestamp
timestamp = source_node_serf.last_processed_message_timestamp
unless timestamp
$stderr.puts("Couldn't get the time stamp of " +
Expand All @@ -327,10 +327,13 @@ module Droonga
if timestamp and not timestamp.empty?
puts "The timestamp of the last processed message in the source node: #{timestamp}"
puts "Setting effective message timestamp for the destination node..."
response = joining_node_serf.send_query("accept_messages_newer_than",
joining_node_serf.ensure_restarted do
joining_node_serf.send_query("accept_messages_newer_than",
"node" => joining_node.to_s,
"timestamp" => timestamp)
end
end
true
end

def register_to_existing_nodes
Expand Down

0 comments on commit adad427

Please sign in to comment.