
The three-way hand-off has a problem: there's no way to arrange for the state of the migration to be unambiguous in case of failure. If the final "disconnect" message is lost (as in, the destination never receives it whether it is sent by the sender or not), the destination has no option but to quit with an error status and let a human sort it out. However, at that point we can either arrange to have a .INCOMPLETE file still on disc or not - and it doesn't matter which we choose, we can still end up with dataloss by picking a specific calamity to have befallen the sender. Given this, it makes sense to fall back to a simpler protocol: just send all the data, then send a "disconnect" message. This has the same downside that we need a human to sort out specific failure cases, but combined with --unlink before sending "disconnect" (see next patch) it will always be possible for a human to disambiguate, whether the destination quit with an error status or not.
26 lines
625 B
Ruby
Executable File
26 lines
625 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
# encoding: utf-8
|
|
|
|
# Open a server, accept a client, then we expect a single write
|
|
# followed by an entrust. However, we disconnect after the write so
|
|
# the entrust will fail. We don't expect a reconnection: the sender
|
|
# can't reliably spot a failed send.
|
|
|
|
require 'flexnbd/fake_dest'
|
|
include FlexNBD
|
|
|
|
addr, port, src_pid = *ARGV
|
|
server = FakeDest.new( addr, port )
|
|
client = server.accept
|
|
|
|
client.write_hello
|
|
req = client.read_request
|
|
data = client.read_data( req[:len] )
|
|
|
|
Process.kill("STOP", src_pid.to_i)
|
|
client.write_reply( req[:handle], 0 )
|
|
client.close
|
|
Process.kill("CONT", src_pid.to_i)
|
|
|
|
exit(0)
|