diff --git a/p4cmds.txt b/p4cmds.txt index a5ae2118394adc9e747ab1acdb978873aca39565..7187cf164dc0f74f3d337a8c0132e8b93fd8ab52 100644 --- a/p4cmds.txt +++ b/p4cmds.txt @@ -13,7 +13,7 @@ go run cli.go -s :5001 path last E go run cli.go -s :5001 path last EM go run cli.go -s :5001 path last EMW -Echo +echo echo Test 3 killall ubiserver sleep 5 @@ -58,10 +58,14 @@ go run cli.go -a -s :5002 put ~/down/sampledis-7.2.1 go run cli.go -s :5001 list | wc ; go run cli.go -s :5002 list | wc go run cli.go -s :5001 list | wc ; go run cli.go -s :5002 list | wc go run cli.go -s :5001 list | wc ; go run cli.go -s :5002 list | wc +go run cli.go -s :5001 list | wc ; go run cli.go -s :5002 list | wc +go run cli.go -s :5001 list | wc ; go run cli.go -s :5002 list | wc +killall ubiserver echo echo Test 7 docker compose up + go run cli.go -s :5001 list | wc; go run cli.go -s :5002 list | wc; go run cli.go -s :5003 list | wc go run cli.go -s :5001 put sampledir go run cli.go -s :5001 list | wc ; go run cli.go -s :5002 list | wc ; go run cli.go -s :5003 list | wc diff --git a/p5.md b/p5.md index 56dcae53a025af67dd6eb6748c9dbd0f350d42c1..fa4a37c0fd769e422706996aaf12cb4287c9daec 100644 --- a/p5.md +++ b/p5.md @@ -1,5 +1,5 @@ # RAFT -**v1.0** +**v1.1** ## Due: Nov 19, 2023, 11:59:59 pm ## Setup @@ -35,7 +35,7 @@ committing client operations. - **Slow followers:** i.e. followers that are behind and need to be "caught up" to the leader's log state. We will implement slow followers by "pausing" containers use the command `docker compose -pause <hostname>`, and later un-pausing them. +pause <hostname>`, and later un-pausing them. ## Command Syntax and Observable Output @@ -65,37 +65,27 @@ Your server may print anything with the `-d` flag. Without this flag, however, it should print at most one line acknowledging when startup is complete, and then only the following output: ---- -At each heartbeat the leader should print: -``` -AE [<match index array>] ci:<commit index>, <log len>[<term>-"<cmd>",....] -``` -For example, your leader might print out: -``` -AE [-1 -1] ci:4, 5[8-"L0",8-"one",8-"two",9-"L1",10-"L1"] -``` -The matchindex is an integer slice described as in Figure 2. A -null/nil or "no match" is signified w/ a -1. `ci` is the current -leader commit index. The number before the left bracket ('[') is the +- `AE ci:<commit index>, <log len>[<term>-"<cmd>",....]`: Leader +should print at each heartbeat. +The number before the left bracket ('[') is the current log length. The entire log is then printed, surrounded by brackets. Entries have format `<term>-"<cmd>"`, and are separated by -commas. - ---- -Followers should print the same, but use " " instead of "AE". - ---- -When a follower converts to candidacy it should print out -"election" alone on a line. - ---- -During catchup, a server should print a single line for each time it -goes backwards: -``` -lastLogIndex <index> <(address:port) -``` - ---- +commas.<br><br> +Example: `AE ci:1, 3[2-"L-2-2",2-"one",2-"two"]` + +- Followers should print the same, but use " " instead of "AE". +- `leader term <leader id>`: Should be printed alone on a line when a server becomes + leader. +<br><br>Example: `leader term 1` + +- `catchup <server> trying PrevLogIndex <last log index of server>`: +Should be printed during catchup each time the leader decrements its +match for a server and retries an *AppendEntries* with a smaller log index. +Note that occasionally messages are buffered for paused containers in +docker, and then delivered when the container is unpaused. The number +of catchup messages you see might therefore be lower than expected. +<br><br> +Example: `catchup raft1:7000 trying PrevLogIndex 3` There should be **no other output**, and this output must be followed exactly. @@ -103,42 +93,56 @@ There should be **no other output**, and this output must be followed exactly. ## Details -- Use whatever timeouts you want during debugging, but you should use those in the startup file when submitting. +- Use whatever timeouts you want during debugging, but you should use + those in the startup file when submitting, i.e: +- Upon becoming leader, your server should insert a "leader +announcement" command `"L<term>-<id>"`, where term is the new election +term, and id is the new leader's id. +- I am using the following timers/timeouts: + - minElectionTimeout = 3000 * time.Millisecond + - maxElectionTimeout = 6000 * time.Millisecond + - heartbeatInterval = 1000 * time.Millisecond + - `context` timeouts for RPC are one second ## Testing. +You can debug w/ local processes, your choice, but **I will just test +the servers in docker compose**. I will use **my** `Dockerfile` and +`compose.yaml` file. + +Note that the following relies on your committing the "leader announcement" from above. + **Test 1 (10 pts)** -Two servers. -- Two-server election, both have to agree. -- Submit a command and verify that the client does not return until - the command has been committed and applied. +- Bring up three servers +- Election +- "leader announcement" command committed **Test 2 (10 pts)** -Continuing the above... -- Kill the leader and immediately restart; the follower must - become the new leader because it's log is more up-to-date. -- Commit another command and power-cycle the leader again, again verifying - that the follower, with it's more up-to-date log, become leader. +- commit more commands **Test 3 (10 pts)** -Three servers. +- pause a follower +- commit some commands +- unpause the follower and see it catch up **Test 4 (10 pts)** -Compose w/ three servers. +- pause the leader +- new election, new leader announcement +- commit more commands +- unpause old leader, watch it catch up **Test 5 (10 pts)** -Compose w/ three servers: -- pause a follower, verify that the commands can still be committed -- unpause the follower, verify that the follower catches up +- bring up w/ five servers +- test pausing followers, leaders as above -**Test 6 (10 pts)** -Compose w/ three servers: -- pause the leader, verify that the commands can still be committed - after new election -- unpause the previous leader, verify that it rejoins, reverts to a follower, catches up -**Test 7 (10 pts)** -Compose w/ five servers. +## Things that should not be seen +*Committed commands being lost for any reason*. This most commonly arises +when leaders change. Ensure that new leaders are at +least as up-to-date as prior leaders (**leader +selection**). + +