forked from Furumi/furumi-web
fix: continue lyrics backfill after malformed LRCLIB responses
This commit is contained in:
1 parent
12f21583f8
commit
98dc902ca2
3 files changed
+161
-58
No files matched your search
+9
-7
@@ -38,15 +38,17 @@ saved. Requests and provider search results are never sent from the browser.
|
|||||||
Successful and empty searches are cached durably, shared across equal metadata
|
Successful and empty searches are cached durably, shared across equal metadata
|
||||||
signatures. A completed content binding is skipped on later runs. Changing
|
signatures. A completed content binding is skipped on later runs. Changing
|
||||||
title, main artist, album or rounded duration makes the content eligible again.
|
title, main artist, album or rounded duration makes the content eligible again.
|
||||||
Network failures, malformed responses and HTTP errors remain retryable with
|
Malformed search records are skipped individually. If an incomplete response
|
||||||
exponential backoff. A durable service cooldown stops the run on such errors;
|
yields no usable match, or the request fails for an individual track, that
|
||||||
`Retry-After` is honored with jitter. A transaction advisory lock prevents
|
signature is deferred for retry with exponential backoff and the run advances
|
||||||
overlapping enrichment runs. Cancelled runs release the lock, and completed
|
to the next track. Connection failures and HTTP 429/503 persist a service-wide
|
||||||
lookup results survive interruption before attachment to content.
|
cooldown and pause the run. Numeric `Retry-After` delays receive jitter.
|
||||||
|
A transaction advisory lock prevents overlapping runs. Cancelled runs release
|
||||||
|
the lock, and completed lookup results survive interruption before attachment.
|
||||||
|
|
||||||
Manual runs bypass saved global cooldown and individual retry delays, while
|
Manual runs bypass saved global cooldown and individual retry delays, while
|
||||||
still skipping completed searches. A fresh API failure stops the run and saves
|
still skipping completed searches. A deferred track is eligible again on the
|
||||||
backoff for subsequent automatic runs; request throttling remains in effect.
|
next manual run. Request throttling remains in effect.
|
||||||
|
|
||||||
## Manual editing and playback
|
## Manual editing and playback
|
||||||
|
|
||||||
|
|||||||
+130
-44
@@ -24,6 +24,17 @@ struct Candidate {
|
|||||||
signature: String,
|
signature: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Candidate {
|
||||||
|
fn log_context(&self) -> String {
|
||||||
|
format!(
|
||||||
|
"track {:?}, artist {:?}, audio {}",
|
||||||
|
self.title.chars().take(120).collect::<String>(),
|
||||||
|
self.artist.chars().take(120).collect::<String>(),
|
||||||
|
self.hash
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Signature changes automatically invalidate a previous positive or negative lookup.
|
// Signature changes automatically invalidate a previous positive or negative lookup.
|
||||||
const CANDIDATES: &str = r#"WITH candidates AS (
|
const CANDIDATES: &str = r#"WITH candidates AS (
|
||||||
SELECT DISTINCT ON(m.sha256_hash) m.sha256_hash::text AS hash,t.title::text,
|
SELECT DISTINCT ON(m.sha256_hash) m.sha256_hash::text AS hash,t.title::text,
|
||||||
@@ -41,6 +52,7 @@ LEFT JOIN furumusic__lyrics_binding b ON b.audio_sha256=c.hash
|
|||||||
LEFT JOIN furumusic__lyrics_lookup l ON l.signature=c.signature
|
LEFT JOIN furumusic__lyrics_lookup l ON l.signature=c.signature
|
||||||
WHERE (b.signature IS DISTINCT FROM c.signature OR l.signature IS NULL OR l.status='retry')
|
WHERE (b.signature IS DISTINCT FROM c.signature OR l.signature IS NULL OR l.status='retry')
|
||||||
AND ($2 OR l.retry_at IS NULL OR l.retry_at<=now())
|
AND ($2 OR l.retry_at IS NULL OR l.retry_at<=now())
|
||||||
|
AND ($3::text IS NULL OR c.hash > $3)
|
||||||
ORDER BY c.hash LIMIT $1"#;
|
ORDER BY c.hash LIMIT $1"#;
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
@@ -99,15 +111,20 @@ async fn enrich(ctx: &JobContext, log: &mut JobLog) -> Result<()> {
|
|||||||
let mut processed = 0;
|
let mut processed = 0;
|
||||||
let mut requests = 0;
|
let mut requests = 0;
|
||||||
let mut found = 0;
|
let mut found = 0;
|
||||||
loop {
|
let mut deferred = 0;
|
||||||
|
let mut cursor: Option<String> = None;
|
||||||
|
'scan: loop {
|
||||||
let batch = sqlx::query_as::<_, Candidate>(CANDIDATES)
|
let batch = sqlx::query_as::<_, Candidate>(CANDIDATES)
|
||||||
.bind(BATCH_SIZE)
|
.bind(BATCH_SIZE)
|
||||||
.bind(manual)
|
.bind(manual)
|
||||||
|
.bind(cursor.as_deref())
|
||||||
.fetch_all(&ctx.pool)
|
.fetch_all(&ctx.pool)
|
||||||
.await?;
|
.await?;
|
||||||
if batch.is_empty() {
|
if batch.is_empty() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Advance past deferred rows even when a manual run ignores retry_at.
|
||||||
|
cursor = batch.last().map(|track| track.hash.clone());
|
||||||
for track in batch {
|
for track in batch {
|
||||||
let (config, _) = crate::config::AppConfig::load_with_db(&ctx.db).await;
|
let (config, _) = crate::config::AppConfig::load_with_db(&ctx.db).await;
|
||||||
if !config.lyrics_enrichment_enabled {
|
if !config.lyrics_enrichment_enabled {
|
||||||
@@ -128,7 +145,7 @@ async fn enrich(ctx: &JobContext, log: &mut JobLog) -> Result<()> {
|
|||||||
Ok(Vec::new())
|
Ok(Vec::new())
|
||||||
} else {
|
} else {
|
||||||
requests += 1;
|
requests += 1;
|
||||||
let result = lookup(&client, &track).await;
|
let result = lookup(&client, &track, log).await;
|
||||||
tokio::time::sleep(std::time::Duration::from_millis(1100)).await;
|
tokio::time::sleep(std::time::Duration::from_millis(1100)).await;
|
||||||
result
|
result
|
||||||
};
|
};
|
||||||
@@ -140,13 +157,24 @@ async fn enrich(ctx: &JobContext, log: &mut JobLog) -> Result<()> {
|
|||||||
versions
|
versions
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
let delay = error.retry_after.unwrap_or(300).max(30);
|
let delay = error.retry_after.unwrap_or(300).clamp(30, 31_536_000);
|
||||||
// Persist service-wide cooldown, including Retry-After, across runs.
|
save_retry(&ctx.pool, &track.signature, delay).await?;
|
||||||
for signature in [track.signature.as_str(), "_lrclib_cooldown"] {
|
let action = if error.service_unavailable {
|
||||||
save_retry(&ctx.pool, signature, delay).await?;
|
save_retry(&ctx.pool, "_lrclib_cooldown", delay).await?;
|
||||||
|
"paused run and saved service cooldown"
|
||||||
|
} else {
|
||||||
|
"deferred track and continued"
|
||||||
|
};
|
||||||
|
log.warn(&format!(
|
||||||
|
"LRCLIB /api/search for {}: {}; {action} (retry delay at least {delay}s).",
|
||||||
|
track.log_context(),
|
||||||
|
error.message
|
||||||
|
));
|
||||||
|
deferred += 1;
|
||||||
|
if error.service_unavailable {
|
||||||
|
break 'scan;
|
||||||
}
|
}
|
||||||
log.info(&format!("LRCLIB temporarily unavailable ({}); saved retry state and stopped requests.",error.message));
|
continue;
|
||||||
return Ok(());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -163,7 +191,7 @@ async fn enrich(ctx: &JobContext, log: &mut JobLog) -> Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info(&format!(
|
log.info(&format!(
|
||||||
"Lyrics complete: {processed} content items, {found} found, {requests} API lookups."
|
"Lyrics run summary: {processed} content items completed, {found} found, {deferred} deferred, {requests} API lookups."
|
||||||
));
|
));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -220,7 +248,7 @@ struct Record {
|
|||||||
id: i64,
|
id: i64,
|
||||||
track_name: String,
|
track_name: String,
|
||||||
artist_name: String,
|
artist_name: String,
|
||||||
album_name: String,
|
album_name: Option<String>,
|
||||||
duration: Option<f64>,
|
duration: Option<f64>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
instrumental: bool,
|
instrumental: bool,
|
||||||
@@ -230,38 +258,38 @@ struct Record {
|
|||||||
struct LookupError {
|
struct LookupError {
|
||||||
message: String,
|
message: String,
|
||||||
retry_after: Option<u64>,
|
retry_after: Option<u64>,
|
||||||
}
|
service_unavailable: bool,
|
||||||
impl From<anyhow::Error> for LookupError {
|
|
||||||
fn from(e: anyhow::Error) -> Self {
|
|
||||||
Self {
|
|
||||||
message: e.to_string(),
|
|
||||||
retry_after: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_json<T: serde::de::DeserializeOwned>(
|
impl LookupError {
|
||||||
client: &Client,
|
fn bad_response(message: String) -> Self {
|
||||||
endpoint: &str,
|
Self {
|
||||||
query: &[(&str, String)],
|
message,
|
||||||
) -> std::result::Result<Option<T>, LookupError> {
|
retry_after: None,
|
||||||
get_json_url(client, &format!("https://lrclib.net/api/{endpoint}"), query).await
|
service_unavailable: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_json_url<T: serde::de::DeserializeOwned>(
|
async fn get_json_url<T: serde::de::DeserializeOwned>(
|
||||||
client: &Client,
|
client: &Client,
|
||||||
url: &str,
|
url: &str,
|
||||||
query: &[(&str, String)],
|
query: &[(&str, String)],
|
||||||
) -> std::result::Result<Option<T>, LookupError> {
|
) -> std::result::Result<T, LookupError> {
|
||||||
let mut response = client
|
let mut response = client
|
||||||
.get(url)
|
.get(url)
|
||||||
.query(query)
|
.query(query)
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
.map_err(|e| LookupError::from(anyhow::Error::from(e)))?;
|
.map_err(|error| LookupError {
|
||||||
|
service_unavailable: error.is_connect(),
|
||||||
|
message: format!("request failed: {}", error.without_url()),
|
||||||
|
retry_after: None,
|
||||||
|
})?;
|
||||||
if !response.status().is_success() {
|
if !response.status().is_success() {
|
||||||
return Err(LookupError {
|
return Err(LookupError {
|
||||||
message: format!("HTTP {}", response.status()),
|
message: format!("HTTP {}", response.status()),
|
||||||
|
service_unavailable: matches!(response.status().as_u16(), 429 | 503),
|
||||||
retry_after: response
|
retry_after: response
|
||||||
.headers()
|
.headers()
|
||||||
.get("retry-after")
|
.get("retry-after")
|
||||||
@@ -270,19 +298,28 @@ async fn get_json_url<T: serde::de::DeserializeOwned>(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = Vec::new();
|
||||||
while let Some(chunk) = response
|
while let Some(chunk) = response.chunk().await.map_err(|error| {
|
||||||
.chunk()
|
LookupError::bad_response(format!(
|
||||||
.await
|
"reading response body failed: {}",
|
||||||
.map_err(|e| LookupError::from(anyhow::Error::from(e)))?
|
error.without_url()
|
||||||
{
|
))
|
||||||
|
})? {
|
||||||
if bytes.len() + chunk.len() > MAX_API_BYTES {
|
if bytes.len() + chunk.len() > MAX_API_BYTES {
|
||||||
return Err(anyhow::anyhow!("oversized LRCLIB response").into());
|
return Err(LookupError::bad_response(format!(
|
||||||
|
"response exceeds {MAX_API_BYTES} bytes"
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
bytes.extend_from_slice(&chunk);
|
bytes.extend_from_slice(&chunk);
|
||||||
}
|
}
|
||||||
serde_json::from_slice(&bytes)
|
serde_json::from_slice(&bytes).map_err(|error| {
|
||||||
.map(Some)
|
LookupError::bad_response(format!(
|
||||||
.map_err(|e| LookupError::from(anyhow::Error::from(e)))
|
"invalid JSON search array ({} bytes, {:?} error at line {}, column {})",
|
||||||
|
bytes.len(),
|
||||||
|
error.classify(),
|
||||||
|
error.line(),
|
||||||
|
error.column()
|
||||||
|
))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
fn normalized(value: &str) -> String {
|
fn normalized(value: &str) -> String {
|
||||||
value
|
value
|
||||||
@@ -302,7 +339,7 @@ fn version(mut record: Record) -> Option<LyricsVersion> {
|
|||||||
// JSON permits NUL, but PostgreSQL text/JSONB cannot represent it. Provider
|
// JSON permits NUL, but PostgreSQL text/JSONB cannot represent it. Provider
|
||||||
// texts occasionally contain these invisible bytes; remove them before
|
// texts occasionally contain these invisible bytes; remove them before
|
||||||
// parsing LRC or writing either the lookup cache or the content binding.
|
// parsing LRC or writing either the lookup cache or the content binding.
|
||||||
record.album_name.retain(|c| c != '\0');
|
let album = without_nul(record.album_name.unwrap_or_default());
|
||||||
record.plain_lyrics = record.plain_lyrics.map(without_nul);
|
record.plain_lyrics = record.plain_lyrics.map(without_nul);
|
||||||
record.synced_lyrics = record.synced_lyrics.map(without_nul);
|
record.synced_lyrics = record.synced_lyrics.map(without_nul);
|
||||||
let synced = record
|
let synced = record
|
||||||
@@ -310,10 +347,10 @@ fn version(mut record: Record) -> Option<LyricsVersion> {
|
|||||||
.filter(|v| !crate::lyrics::parse_lrc(v).is_empty());
|
.filter(|v| !crate::lyrics::parse_lrc(v).is_empty());
|
||||||
let value = LyricsVersion {
|
let value = LyricsVersion {
|
||||||
id: format!("lrclib:{}", record.id),
|
id: format!("lrclib:{}", record.id),
|
||||||
label: if record.album_name.is_empty() {
|
label: if album.is_empty() {
|
||||||
"LRCLIB".into()
|
"LRCLIB".into()
|
||||||
} else {
|
} else {
|
||||||
format!("LRCLIB · {}", record.album_name)
|
format!("LRCLIB · {album}")
|
||||||
},
|
},
|
||||||
source: "lrclib".into(),
|
source: "lrclib".into(),
|
||||||
source_id: Some(record.id.to_string()),
|
source_id: Some(record.id.to_string()),
|
||||||
@@ -332,16 +369,45 @@ fn without_nul(mut text: String) -> String {
|
|||||||
async fn lookup(
|
async fn lookup(
|
||||||
client: &Client,
|
client: &Client,
|
||||||
track: &Candidate,
|
track: &Candidate,
|
||||||
|
log: &mut JobLog,
|
||||||
) -> std::result::Result<Vec<LyricsVersion>, LookupError> {
|
) -> std::result::Result<Vec<LyricsVersion>, LookupError> {
|
||||||
let query = vec![
|
let query = vec![
|
||||||
("track_name", track.title.clone()),
|
("track_name", track.title.clone()),
|
||||||
("artist_name", track.artist.clone()),
|
("artist_name", track.artist.clone()),
|
||||||
];
|
];
|
||||||
// Search returns all text representations in one request; no per-result fetches.
|
// Search returns all text representations in one request; no per-result fetches.
|
||||||
let records: Vec<Record> = get_json(client, "search", &query)
|
let values: Vec<serde_json::Value> =
|
||||||
.await?
|
get_json_url(client, "https://lrclib.net/api/search", &query).await?;
|
||||||
.unwrap_or_default();
|
let (records, rejected, first_rejected) = decode_records(values);
|
||||||
Ok(select_versions(records, track))
|
let versions = select_versions(records, track);
|
||||||
|
if let Some(index) = first_rejected {
|
||||||
|
let detail =
|
||||||
|
format!("skipped {rejected} malformed search records (first at index {index})");
|
||||||
|
if versions.is_empty() {
|
||||||
|
return Err(LookupError::bad_response(detail));
|
||||||
|
}
|
||||||
|
log.warn(&format!(
|
||||||
|
"LRCLIB /api/search for {}: {detail}.",
|
||||||
|
track.log_context()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
Ok(versions)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn decode_records(values: Vec<serde_json::Value>) -> (Vec<Record>, usize, Option<usize>) {
|
||||||
|
let mut records = Vec::new();
|
||||||
|
let mut rejected = 0;
|
||||||
|
let mut first_rejected = None;
|
||||||
|
for (index, value) in values.into_iter().enumerate() {
|
||||||
|
match serde_json::from_value(value) {
|
||||||
|
Ok(record) => records.push(record),
|
||||||
|
Err(_) => {
|
||||||
|
rejected += 1;
|
||||||
|
first_rejected.get_or_insert(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(records, rejected, first_rejected)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_versions(records: Vec<Record>, track: &Candidate) -> Vec<LyricsVersion> {
|
fn select_versions(records: Vec<Record>, track: &Candidate) -> Vec<LyricsVersion> {
|
||||||
@@ -354,7 +420,9 @@ fn select_versions(records: Vec<Record>, track: &Candidate) -> Vec<LyricsVersion
|
|||||||
r.synced_lyrics
|
r.synced_lyrics
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.is_some_and(|v| !crate::lyrics::parse_lrc(v).is_empty()),
|
.is_some_and(|v| !crate::lyrics::parse_lrc(v).is_empty()),
|
||||||
normalized(&r.album_name) == normalized(&track.album),
|
r.album_name
|
||||||
|
.as_deref()
|
||||||
|
.is_some_and(|album| normalized(album) == normalized(&track.album)),
|
||||||
!r.instrumental,
|
!r.instrumental,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
@@ -376,6 +444,24 @@ fn select_versions(records: Vec<Record>, track: &Candidate) -> Vec<LyricsVersion
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
#[test]
|
||||||
|
fn malformed_search_records_do_not_discard_valid_neighbors() {
|
||||||
|
let (records, rejected, first_rejected) = decode_records(vec![
|
||||||
|
serde_json::json!({"id": 1, "trackName": null, "artistName": "Artist"}),
|
||||||
|
serde_json::json!({"id": 2, "trackName": "Song", "artistName": "Artist",
|
||||||
|
"albumName": null, "duration": 100, "plainLyrics": "Words"}),
|
||||||
|
serde_json::json!({"id": 3, "trackName": "Song", "artistName": "Artist",
|
||||||
|
"syncedLyrics": ["wrong type"]}),
|
||||||
|
serde_json::Value::Null,
|
||||||
|
]);
|
||||||
|
assert_eq!(rejected, 3);
|
||||||
|
assert_eq!(first_rejected, Some(0));
|
||||||
|
let lyrics = version(records.into_iter().next().unwrap()).unwrap();
|
||||||
|
assert_eq!(lyrics.id, "lrclib:2");
|
||||||
|
assert_eq!(lyrics.label, "LRCLIB");
|
||||||
|
assert_eq!(lyrics.plain_text.as_deref(), Some("Words"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn nullable_duration_does_not_discard_valid_search_results() {
|
fn nullable_duration_does_not_discard_valid_search_results() {
|
||||||
let track = Candidate {
|
let track = Candidate {
|
||||||
@@ -420,7 +506,7 @@ mod tests {
|
|||||||
id: 1,
|
id: 1,
|
||||||
track_name: "SONG".into(),
|
track_name: "SONG".into(),
|
||||||
artist_name: "Artist".into(),
|
artist_name: "Artist".into(),
|
||||||
album_name: "Album".into(),
|
album_name: Some("Album".into()),
|
||||||
duration: Some(102.0),
|
duration: Some(102.0),
|
||||||
instrumental: false,
|
instrumental: false,
|
||||||
plain_lyrics: Some("words".into()),
|
plain_lyrics: Some("words".into()),
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ use sqlx::Connection;
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn http_misses_throttling_and_invalid_bodies_are_distinguished() {
|
async fn http_misses_throttling_and_invalid_bodies_are_distinguished() {
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
for (status, body, retry, success) in [
|
for (status, body, retry, success, cooldown) in [
|
||||||
("200 OK", "[]", None, true),
|
("200 OK", "[]", None, true, false),
|
||||||
("404 Not Found", "{}", None, false),
|
("404 Not Found", "{}", None, false, false),
|
||||||
("429 Too Many Requests", "{}", Some(7200), false),
|
("429 Too Many Requests", "{}", Some(7200), false, true),
|
||||||
("503 Service Unavailable", "{}", Some(30), false),
|
("503 Service Unavailable", "{}", Some(30), false, true),
|
||||||
("200 OK", "not JSON", None, false),
|
("200 OK", "not JSON", None, false, false),
|
||||||
|
("200 OK", "{}", None, false, false),
|
||||||
|
("200 OK", "null", None, false, false),
|
||||||
] {
|
] {
|
||||||
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
|
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||||
let url = format!("http://{}", listener.local_addr().unwrap());
|
let url = format!("http://{}", listener.local_addr().unwrap());
|
||||||
@@ -26,10 +28,11 @@ async fn http_misses_throttling_and_invalid_bodies_are_distinguished() {
|
|||||||
stream.read(&mut bytes).await.unwrap();
|
stream.read(&mut bytes).await.unwrap();
|
||||||
stream.write_all(response.as_bytes()).await.unwrap();
|
stream.write_all(response.as_bytes()).await.unwrap();
|
||||||
});
|
});
|
||||||
let result = get_json_url::<Vec<Record>>(&Client::new(), &url, &[]).await;
|
let result = get_json_url::<Vec<serde_json::Value>>(&Client::new(), &url, &[]).await;
|
||||||
assert_eq!(result.is_ok(), success, "{status}");
|
assert_eq!(result.is_ok(), success, "{status}");
|
||||||
if let Err(error) = result {
|
if let Err(error) = result {
|
||||||
assert_eq!(error.retry_after, retry);
|
assert_eq!(error.retry_after, retry);
|
||||||
|
assert_eq!(error.service_unavailable, cooldown);
|
||||||
}
|
}
|
||||||
server.await.unwrap();
|
server.await.unwrap();
|
||||||
}
|
}
|
||||||
@@ -85,6 +88,7 @@ async fn postgres_cache_retry_content_binding_and_manual_versions() {
|
|||||||
sqlx::query_as::<_, Candidate>(CANDIDATES)
|
sqlx::query_as::<_, Candidate>(CANDIDATES)
|
||||||
.bind(200)
|
.bind(200)
|
||||||
.bind(false)
|
.bind(false)
|
||||||
|
.bind(None::<&str>)
|
||||||
.fetch_all(&pool)
|
.fetch_all(&pool)
|
||||||
};
|
};
|
||||||
assert!(is_manual_run(&pool, 1).await.unwrap());
|
assert!(is_manual_run(&pool, 1).await.unwrap());
|
||||||
@@ -136,6 +140,7 @@ async fn postgres_cache_retry_content_binding_and_manual_versions() {
|
|||||||
sqlx::query_as::<_, Candidate>(CANDIDATES)
|
sqlx::query_as::<_, Candidate>(CANDIDATES)
|
||||||
.bind(200)
|
.bind(200)
|
||||||
.bind(true)
|
.bind(true)
|
||||||
|
.bind(None::<&str>)
|
||||||
.fetch_all(&pool)
|
.fetch_all(&pool)
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -172,6 +177,7 @@ async fn postgres_cache_retry_content_binding_and_manual_versions() {
|
|||||||
let manual_candidates = sqlx::query_as::<_, Candidate>(CANDIDATES)
|
let manual_candidates = sqlx::query_as::<_, Candidate>(CANDIDATES)
|
||||||
.bind(200)
|
.bind(200)
|
||||||
.bind(true)
|
.bind(true)
|
||||||
|
.bind(None::<&str>)
|
||||||
.fetch_all(&pool)
|
.fetch_all(&pool)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -180,6 +186,15 @@ async fn postgres_cache_retry_content_binding_and_manual_versions() {
|
|||||||
2,
|
2,
|
||||||
"manual runs bypass per-content retry delays"
|
"manual runs bypass per-content retry delays"
|
||||||
);
|
);
|
||||||
|
let remaining = sqlx::query_as::<_, Candidate>(CANDIDATES)
|
||||||
|
.bind(200)
|
||||||
|
.bind(true)
|
||||||
|
.bind(&manual_candidates[0].hash)
|
||||||
|
.fetch_all(&pool)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(remaining.len(), 1);
|
||||||
|
assert_eq!(remaining[0].hash, manual_candidates[1].hash);
|
||||||
sqlx::query("UPDATE furumusic__lyrics_lookup SET retry_at=now()-interval '1 second'")
|
sqlx::query("UPDATE furumusic__lyrics_lookup SET retry_at=now()-interval '1 second'")
|
||||||
.execute(&pool)
|
.execute(&pool)
|
||||||
.await
|
.await
|
||||||
|
|||||||
Reference in new issue
Block a user