Add chunk management notes to DESIGN.txt
This commit is contained in:
+39
-14
@@ -137,26 +137,51 @@ Chunk Management:
|
|||||||
servers need to forget some copies. If they are under-replicated,
|
servers need to forget some copies. If they are under-replicated,
|
||||||
some chunk servers need to copy chunks from elsewhere.
|
some chunk servers need to copy chunks from elsewhere.
|
||||||
|
|
||||||
Event 1: A chunk server connects
|
The metadata server holds an authoritative list of hashes that each
|
||||||
If the chunk server is holding some chunks, for each chunk
|
chunk server needs to hold. These lists are enforced periodically and
|
||||||
one of the following must be true:
|
automatically during the state updates, therefore the metadata server
|
||||||
- The chunk is not used by the file system
|
only needs to reorganize the chunks in its in-memory lists. The changes
|
||||||
=> Mark the chunk for removal
|
will propagate over the chunk servers in time. The metadata server's
|
||||||
- The chunk is used and, with this copy, perfectly replicated
|
in-memory representation is the ideal state the system is converging
|
||||||
=> Do nothing
|
to, which means every chunk if always replicated correctly. Given this
|
||||||
- The chunk is used and under-replicated
|
setup, a chunk can only be under-replicated when there are not enough
|
||||||
=> ???
|
chunk servers.
|
||||||
- The chunk is used and over-replicated
|
|
||||||
=> Mark the chunk for removal
|
|
||||||
|
|
||||||
Event 2: A write operation on metadata (adding chunks)
|
Case 1: The first chunk server connects with no chunks
|
||||||
|
CS connects
|
||||||
|
MS accepts
|
||||||
|
CS sends auth message
|
||||||
|
MS validates auth
|
||||||
|
MS requests list of chunks
|
||||||
|
CS sends the chunk list
|
||||||
|
MS notices it's empty
|
||||||
|
|
||||||
|
Case 2: The first chunk server connects with some chunks
|
||||||
|
CS connects
|
||||||
|
MS accepts
|
||||||
|
CS sends auth message
|
||||||
|
MS valudates auth
|
||||||
|
MS requests list of chunks
|
||||||
|
CS sends the chunk list
|
||||||
|
MS iterates over each chunk. For each chunk it determines
|
||||||
|
whether it's useless, under-replicated, over-replicated,
|
||||||
|
or properly replicated.
|
||||||
|
MS adds all useless or over-replicated chunks to the rem_list
|
||||||
|
of the newly connected chunk server. Note that it's only
|
||||||
|
possible for a chunk to be over-replicated by 1, so removing
|
||||||
|
it from the new chunk server will fix the issue.
|
||||||
|
MS If a chunk is under-replicated, it means that there are not
|
||||||
|
enough chunk servers to hold all the replicas, so there is
|
||||||
|
nothing to be done.
|
||||||
|
|
||||||
|
Case 3: Chunk server with some chunks disconnects
|
||||||
TODO
|
TODO
|
||||||
|
|
||||||
Event 3: A chunk server disconnects
|
Event 3: A chunk server disconnects
|
||||||
A number of chunks are lost, but there is a chance the server will come back
|
A number of chunks are lost, but there is a chance the server will come back
|
||||||
in a short while (10s or so).
|
in a short while (10s or so).
|
||||||
|
=> Wait for about 10s. If the chunk server doesn't come back, distribute
|
||||||
TODO
|
its hashes to other chunk servers
|
||||||
|
|
||||||
Event 4: A write operation on metadata occurs (overwriting old chunks)
|
Event 4: A write operation on metadata occurs (overwriting old chunks)
|
||||||
Assuming the write overwrites some chunks:
|
Assuming the write overwrites some chunks:
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ enum {
|
|||||||
|
|
||||||
// Chunk server -> Metadata server
|
// Chunk server -> Metadata server
|
||||||
MESSAGE_TYPE_AUTH,
|
MESSAGE_TYPE_AUTH,
|
||||||
|
MESSAGE_TYPE_CHUNK_LIST,
|
||||||
MESSAGE_TYPE_STATE_UPDATE_ERROR,
|
MESSAGE_TYPE_STATE_UPDATE_ERROR,
|
||||||
MESSAGE_TYPE_STATE_UPDATE_SUCCESS,
|
MESSAGE_TYPE_STATE_UPDATE_SUCCESS,
|
||||||
|
|
||||||
|
|||||||
+26
-6
@@ -768,8 +768,6 @@ static int process_chunk_server_auth(MetadataServer *state,
|
|||||||
if (!binary_read(&reader, NULL, sizeof(MessageHeader)))
|
if (!binary_read(&reader, NULL, sizeof(MessageHeader)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// Read IPv4s
|
|
||||||
{
|
|
||||||
uint32_t num_ipv4;
|
uint32_t num_ipv4;
|
||||||
if (!binary_read(&reader, &num_ipv4, sizeof(num_ipv4)))
|
if (!binary_read(&reader, &num_ipv4, sizeof(num_ipv4)))
|
||||||
return -1;
|
return -1;
|
||||||
@@ -792,10 +790,7 @@ static int process_chunk_server_auth(MetadataServer *state,
|
|||||||
chunk_server->addrs[chunk_server->num_addrs++] = addr;
|
chunk_server->addrs[chunk_server->num_addrs++] = addr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Read IPv6s
|
|
||||||
{
|
|
||||||
uint32_t num_ipv6;
|
uint32_t num_ipv6;
|
||||||
if (!binary_read(&reader, &num_ipv6, sizeof(num_ipv6)))
|
if (!binary_read(&reader, &num_ipv6, sizeof(num_ipv6)))
|
||||||
return -1;
|
return -1;
|
||||||
@@ -818,7 +813,6 @@ static int process_chunk_server_auth(MetadataServer *state,
|
|||||||
chunk_server->addrs[chunk_server->num_addrs++] = addr;
|
chunk_server->addrs[chunk_server->num_addrs++] = addr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// No addresses were wpecified
|
// No addresses were wpecified
|
||||||
if (chunk_server->num_addrs == 0)
|
if (chunk_server->num_addrs == 0)
|
||||||
@@ -833,9 +827,32 @@ static int process_chunk_server_auth(MetadataServer *state,
|
|||||||
// we accept all connections that provide valid address information.
|
// we accept all connections that provide valid address information.
|
||||||
chunk_server->auth = true;
|
chunk_server->auth = true;
|
||||||
|
|
||||||
|
// TODO: Request the chunk list held by this chunk server
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int process_chunk_server_chunk_list(MetadataServer *state,
|
||||||
|
int conn_idx, ByteView msg)
|
||||||
|
{
|
||||||
|
// Iterate over each chunk held by this chunk
|
||||||
|
// server and determine whether it's useless,
|
||||||
|
// under-replicated, over-replicated, or
|
||||||
|
// properly replicated.
|
||||||
|
// Chunks that are useless or over-replicated
|
||||||
|
// are added to the remove list of this chunk
|
||||||
|
// server (note that any given chunk can only
|
||||||
|
// be over-replicated by 1, so removing it from
|
||||||
|
// this chunk server will fix the issue). If
|
||||||
|
// the chunk is under-replicated or properly
|
||||||
|
// replicated, do nothing. Note that it's only
|
||||||
|
// possible for a chunk to be under-replicated
|
||||||
|
// when the number of chunk servers is lower
|
||||||
|
// than the replication factor.
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
static int process_chunk_server_state_update_success(MetadataServer *state,
|
static int process_chunk_server_state_update_success(MetadataServer *state,
|
||||||
int conn_idx, ByteView msg)
|
int conn_idx, ByteView msg)
|
||||||
{
|
{
|
||||||
@@ -948,6 +965,9 @@ process_chunk_server_message(MetadataServer *state,
|
|||||||
case MESSAGE_TYPE_AUTH:
|
case MESSAGE_TYPE_AUTH:
|
||||||
return process_chunk_server_auth(state, conn_idx, msg);
|
return process_chunk_server_auth(state, conn_idx, msg);
|
||||||
|
|
||||||
|
case MESSAGE_TYPE_CHUNK_LIST:
|
||||||
|
return process_chunk_server_chunk_list(state, conn_idx, msg);
|
||||||
|
|
||||||
case MESSAGE_TYPE_STATE_UPDATE_SUCCESS:
|
case MESSAGE_TYPE_STATE_UPDATE_SUCCESS:
|
||||||
return process_chunk_server_state_update_success(state, conn_idx, msg);
|
return process_chunk_server_state_update_success(state, conn_idx, msg);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user