-
Notifications
You must be signed in to change notification settings - Fork 16
Check if storage is working when returning the response to a faucet healthcheck request. #1189
Check if storage is working when returning the response to a faucet healthcheck request. #1189
Conversation
I think this should do the job. If only the remove steps fails (unlikely) then subsequent inserts would not actually write to disk anymore because if the key is already in the index it doesn't insert it again until it has received the grants and is removed. This could be avoided by using a random key instead. /// Add an element to the persistent index.
///
/// Returns `true` if the element was inserted or `false` if it was already in the index.
fn insert(&mut self, key: UserPubKey) -> Result<bool, FaucetError> {
if self.index.contains_key(&key) {
// If the key is already in the index, we don't have to persist anything.
return Ok(false);
}
... Another concern would be the faucet becoming unresponsive if the Overall I think it may reduce problems or alert us earlier so I'd be happy to try like this. I'd be curious to get @jbearer's opinion though. |
I don't think lock contention is a big problem. The time this healthcheck endpoint spends with the lock is nothing compared to how long it takes to build a transaction. Plus the healthcheck is only called every few seconds, I believe. If only the remove step fails, then we will actually end up sending a grant to the default address, which wastes a small amount of funds and time, but it's not too bad given that this should be extremely rare. And when we send the grant to the default address, we will remove it from the queue, so subsequent healthchecks will start doing the correct thing again. Only suggestion is I think we should log something at ERROR level if either of these writes fails, so that if the healthcheck fails we will know why, and especially if only one of the writes fails, we will know it happened. |
83f952f
to
5b62743
Compare
Right, done in 5b62743. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Closes #1186.
I am not sure if the storage requests are neutral.
Also I have an error when I run the tests locally. Something similar to the error described in #1179.