Skip to content
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
dfb4908
Document configurable PostgreSQL storage design
mmpg-x86 Oct 14, 2026
953c8d2
Initialize pseudoterminals in display tests
mmpg-x86 Oct 15, 2026
ebb23b6
Parse opt-in PostgreSQL storage modes
mmpg-x86 Oct 15, 2026
8cc1137
Add PostgreSQL catalog migration foundation
mmpg-x86 Oct 15, 2026
282da5e
Support PostgreSQL for daemon storage
mmpg-x86 Oct 15, 2026
5ff2a61
Synchronize shared bug catalogs through PostgreSQL
mmpg-x86 Oct 15, 2026
0d7e948
Keep catalog merge bases until local changes are acknowledged
mmpg-x86 Oct 15, 2026
f0ab873
Keep imported discovery links scoped to their producer
mmpg-x86 Oct 15, 2026
1b9ef39
Honor the selected storage backend in database clients
mmpg-x86 Oct 15, 2026
dec5920
Provide OpenSSL dependencies for Linux Nix builds
mmpg-x86 Oct 15, 2026
9d63568
Run PostgreSQL integration coverage in CI
mmpg-x86 Oct 15, 2026
f74127a
Preserve ASCII subsystem scope matching on both backends
mmpg-x86 Oct 15, 2026
1256de8
Redact foreign duplicate history in scoped bug views
mmpg-x86 Oct 15, 2026
0a1ddeb
Bound pending catalog lookups to the requested bug views
mmpg-x86 Oct 15, 2026
67b4b3d
Preserve shared duplicate relationships during concurrent triage
mmpg-x86 Oct 15, 2026
b67bc94
Preserve analysis outcomes across shared catalog outages
mmpg-x86 Oct 15, 2026
44b0051
Recover ordinary PostgreSQL sessions after connection loss
mmpg-x86 Oct 15, 2026
ba8ef01
Keep the libSQL covering index for review statistics
mmpg-x86 Oct 15, 2026
3d64a2d
Exercise PostgreSQL adapter boundaries with deterministic fixtures
mmpg-x86 Oct 15, 2026
4447f1f
Describe PostgreSQL deployment and execution boundaries
mmpg-x86 Oct 15, 2026
56b079b
Keep shared publication scoped to the configured project
mmpg-x86 Oct 15, 2026
f5f686c
Scope PostgreSQL coordination locks to the configured schema
mmpg-x86 Oct 15, 2026
592d15d
Version shared mirror tracking and exclude local bookkeeping
mmpg-x86 Oct 15, 2026
44eb292
Reuse the shared catalog connection and TLS configuration
mmpg-x86 Oct 15, 2026
35b5c79
Discard PostgreSQL sessions after interrupted operations
mmpg-x86 Oct 15, 2026
672dbce
Classify transient catalog failures before refunding attempts
mmpg-x86 Oct 15, 2026
085e67a
Preserve legacy bug identifiers in project catalog namespaces
mmpg-x86 Oct 15, 2026
e875af3
Bound shared catalog synchronization with durable scheduling
mmpg-x86 Oct 15, 2026
490c9dc
Preserve original metadata when importing shared bug history
mmpg-x86 Oct 15, 2026
13fd37c
Match libSQL bug triage behavior on PostgreSQL
mmpg-x86 Oct 15, 2026
66e32d9
Verify the shared catalog readiness contract
mmpg-x86 Oct 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Classify transient catalog failures before refunding attempts
Refund analysis attempts for connection loss, retryable PostgreSQL
errors, canceled sessions and timeouts. Keep configuration, schema,
identity and data errors on the ordinary failure path.

Cover connection refusal and permanent configuration failures without
requiring a live server, preserving the original error chain.

Signed-off-by: Maciej Grochowski <maciej.grochowski@protonmail.com>
  • Loading branch information
mmpg-x86 committed Oct 15, 2026
commit 672dbce9a0ba1e6645007174918626a4eaac1d58
92 changes: 90 additions & 2 deletions src/db/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,64 @@ impl SharedCatalog {
#[error("Shared bug catalog is unavailable")]
struct SharedCatalogUnavailable;

fn retryable_postgres_error(error: &tokio_postgres::Error) -> bool {
use tokio_postgres::error::SqlState;
error.is_closed()
|| error.code().is_some_and(|code| {
code.code().starts_with("08")
|| [
SqlState::ADMIN_SHUTDOWN,
SqlState::CRASH_SHUTDOWN,
SqlState::CANNOT_CONNECT_NOW,
SqlState::QUERY_CANCELED,
SqlState::TOO_MANY_CONNECTIONS,
SqlState::T_R_SERIALIZATION_FAILURE,
SqlState::T_R_DEADLOCK_DETECTED,
]
.contains(code)
})
}

fn catalog_error(error: anyhow::Error) -> anyhow::Error {
let retryable = error.chain().any(|cause| {
if let Some(error) = cause.downcast_ref::<crate::storage::Error>() {
match error {
crate::storage::Error::Canceled => return true,
crate::storage::Error::Postgres(error) => return retryable_postgres_error(error),
_ => {}
}
}
if let Some(error) = cause.downcast_ref::<tokio_postgres::Error>()
&& retryable_postgres_error(error)
{
return true;
}
if cause.is::<tokio::time::error::Elapsed>() {
return true;
}
cause.downcast_ref::<std::io::Error>().is_some_and(|error| {
matches!(
error.kind(),
std::io::ErrorKind::ConnectionRefused
| std::io::ErrorKind::ConnectionReset
| std::io::ErrorKind::ConnectionAborted
| std::io::ErrorKind::NotConnected
| std::io::ErrorKind::TimedOut
| std::io::ErrorKind::UnexpectedEof
| std::io::ErrorKind::BrokenPipe
| std::io::ErrorKind::NetworkDown
| std::io::ErrorKind::NetworkUnreachable
| std::io::ErrorKind::HostUnreachable
)
})
});
if retryable {
error.context(SharedCatalogUnavailable)
} else {
error
}
}

#[derive(Clone, Serialize, Deserialize, PartialEq)]
struct Record {
bugid: String,
Expand Down Expand Up @@ -206,7 +264,7 @@ impl Database {
Ok::<_, anyhow::Error>(guard)
}
.await
.context(SharedCatalogUnavailable)
.map_err(catalog_error)
} else {
self.conn.dedup_lock().await
}
Expand Down Expand Up @@ -1081,7 +1139,11 @@ mod tests {

#[tokio::test]
async fn catalog_failure_defers_claim_without_spending_attempts() -> Result<()> {
let db = local_mirror().await?;
let mut db = local_mirror().await?;
Arc::get_mut(db.shared.as_mut().context("shared mode")?)
.context("exclusive test configuration")?
.settings
.postgres_url = Some("postgresql://test@127.0.0.1:1/unavailable".into());
let bug: NewBug = serde_json::from_value(json!({
"bugid": format!("sashiko-{}", uuid::Uuid::new_v4()), "title": "catalog unavailable"
}))?;
Expand Down Expand Up @@ -1116,6 +1178,32 @@ mod tests {
Ok(())
}

#[tokio::test]
async fn catalog_configuration_errors_are_not_refunded_as_outages() -> Result<()> {
let db = local_mirror().await?;
let error = db
.lock_bug_dedup()
.await
.err()
.context("missing configuration")?;
assert!(!Database::is_shared_catalog_failure(&error));
for kind in [
std::io::ErrorKind::ConnectionReset,
std::io::ErrorKind::TimedOut,
] {
assert!(Database::is_shared_catalog_failure(&catalog_error(
std::io::Error::from(kind).into()
)));
}
assert!(!Database::is_shared_catalog_failure(&catalog_error(
anyhow::anyhow!("Unsupported shared catalog format")
)));
assert!(!Database::is_shared_catalog_failure(&catalog_error(
std::io::Error::from(std::io::ErrorKind::NotFound).into()
)));
Ok(())
}

#[tokio::test]
async fn failed_outcome_publication_keeps_success_and_releases_claim() -> Result<()> {
let db = local_mirror().await?;
Expand Down