Make dir auths not serve consensus or microdescs while voting
Sebastian and Sina and I are running an experimental patch which makes us respond with a "503 busy" to consensus fetches and to microdesc fetches, during the period :48 through :59.5 each hour.
The goal is to work harder to get a handle on the overload issues stemming from #33018 (closed), by clearing the dir auths of distracting bandwidth-soaking operations during the critical voting time.
I've made a patch:
diff --git a/src/feature/dirauth/dirvote.c b/src/feature/dirauth/dirvote.c
index a1f9bb28ae..4b8a33c6be 100644
--- a/src/feature/dirauth/dirvote.c
+++ b/src/feature/dirauth/dirvote.c
@@ -2839,6 +2839,17 @@ get_detached_signatures_from_pending_consensuses(pending_consensus_t *pending,
return signatures;
}
+/** Return 1 if we are inside the voting interval -- two minutes before
+ * starting, or two minutes after the missing-signatures phase. In theory
+ * I want the end condition to be not the missing sigs phase, but the
+ * actual posting of the consensus, but I didn't do that. */
+int
+dir_auth_during_voting_interval(time_t now)
+{
+ return now >= voting_schedule.voting_starts - 120 &&
+ now < voting_schedule.fetch_missing_signatures + 120;
+}
+
/**
* Entry point: Take whatever voting actions are pending as of <b>now</b>.
*
diff --git a/src/feature/dirauth/dirvote.h b/src/feature/dirauth/dirvote.h
index 4f48e45dc3..2bca06365d 100644
--- a/src/feature/dirauth/dirvote.h
+++ b/src/feature/dirauth/dirvote.h
@@ -88,6 +88,7 @@ extern const char DIRVOTE_OPTIONAL_FLAGS[];
*/
#ifdef HAVE_MODULE_DIRAUTH
+int dir_auth_during_voting_interval(time_t now);
time_t dirvote_act(const or_options_t *options, time_t now);
void dirvote_free_all(void);
diff --git a/src/feature/dircache/dircache.c b/src/feature/dircache/dircache.c
index 207ea6698b..f5195cc918 100644
--- a/src/feature/dircache/dircache.c
+++ b/src/feature/dircache/dircache.c
@@ -929,6 +929,17 @@ handle_get_current_consensus(dir_connection_t *conn,
goto done;
}
+ /* experimental feature to stop answering consensus and desc fetches
+ * during the consensus voting internal. */
+ if (dir_auth_during_voting_interval(now)) {
+ log_info(LD_DIRSERV,
+ "Client asked for network status lists, but we're in "
+ "the voting interval. Sending 503 Dir busy.");
+ write_short_http_response(conn, 503, "Directory voting, try again later");
+ geoip_note_ns_response(GEOIP_REJECT_BUSY);
+ goto done;
+ }
+
conn->spool = smartlist_new();
clear_spool = 1;
{
@@ -1126,6 +1137,17 @@ handle_get_microdesc(dir_connection_t *conn, const get_handler_args_t *args)
write_short_http_response(conn, 404, "Not found");
goto done;
}
+
+ /* experimental feature to stop answering consensus and desc fetches
+ * during the consensus voting internal. */
+ if (dir_auth_during_voting_interval(approx_time())) {
+ log_info(LD_DIRSERV,
+ "Client asked for microdescs, but we're in "
+ "the voting interval. Sending 503 Dir busy.");
+ write_short_http_response(conn, 503, "Directory voting, try again later");
+ goto done;
+ }
+
if (connection_dir_is_global_write_low(TO_CONN(conn), size_guess)) {
log_info(LD_DIRSERV,
"Client asked for server descriptors, but we've been "
and once I have a ticket number here I'll make a branch and post it.