Compare commits

2 Commits

Author SHA1 Message Date
cuddle-please
dbb79e60b8 chore(release): 0.2.0
All checks were successful
continuous-integration/drone/push Build is passing
2025-09-25 09:07:34 +00:00
4527ee7829 feat: truly cancel if revision isn't as expected
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: kjuulh <contact@kjuulh.io>
2025-09-25 11:07:14 +02:00
2 changed files with 6 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.2.0] - 2025-09-25 ## [0.2.0] - 2025-09-25
### Added ### Added
- truly cancel if revision isn't as expected
- reset after failure - reset after failure
- print as well - print as well
- add publish - add publish

View File

@@ -87,16 +87,20 @@ impl BackendEdge for PostgresBackend {
FROM noleader_leaders FROM noleader_leaders
WHERE WHERE
key = $1 key = $1
AND revision = $2
AND heartbeat >= now() - interval '60 seconds' AND heartbeat >= now() - interval '60 seconds'
LIMIT 1; LIMIT 1;
", ",
) )
.bind(&key.0) .bind(&key.0)
.bind(self.revision.load(Ordering::Relaxed) as i64)
.fetch_optional(&self.db().await?) .fetch_optional(&self.db().await?)
.await .await
.context("get noleader key")?; .context("get noleader key")?;
let Some(val) = rec else { let Some(val) = rec else {
self.revision.store(0, Ordering::Relaxed);
anyhow::bail!("key doesn't exist, we've lost leadership status") anyhow::bail!("key doesn't exist, we've lost leadership status")
}; };
@@ -105,6 +109,7 @@ impl BackendEdge for PostgresBackend {
let Ok(id) = uuid::Uuid::parse_str(&val.value) else { let Ok(id) = uuid::Uuid::parse_str(&val.value) else {
tracing::warn!("value is not a valid uuid: {}", val.value); tracing::warn!("value is not a valid uuid: {}", val.value);
self.revision.store(0, Ordering::Relaxed);
return Ok(LeaderValue::Unknown); return Ok(LeaderValue::Unknown);
}; };