Skip to content

Commit b4eb450

Browse files
nipunn1313Convex, Inc.
authored and
Convex, Inc.
committed
Deserialize persistence globals to bytes, then value (#34587)
Mysql library panics if it hits recursion limit. Now it will give anyhow Error instead, avoiding crashing the whole conductor. GitOrigin-RevId: b0e5b6d953c873c4cab3602623410a9827b9f948
1 parent 36742ae commit b4eb450

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: crates/mysql/src/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,8 @@ impl<RT: Runtime> MySqlReader<RT> {
561561
let ts: i64 = row.get(1).unwrap();
562562
let ts = Timestamp::try_from(ts)?;
563563
let table_b: Vec<u8> = row.get(2).unwrap();
564-
let json_value: serde_json::Value = row.get(3).unwrap();
564+
let json_value: Vec<u8> = row.get(3).unwrap();
565+
let json_value: JsonValue = serde_json::from_slice(&json_value)?;
565566
let deleted: bool = row.get(4).unwrap();
566567
let table = TabletId(table_b.try_into()?);
567568
let document_id = InternalDocumentId::new(table, internal_id);
@@ -816,7 +817,8 @@ impl<RT: Runtime> MySqlReader<RT> {
816817
table_b.ok_or_else(|| {
817818
anyhow::anyhow!("Dangling index reference for {:?} {:?}", key, ts)
818819
})?;
819-
let json_value: serde_json::Value = row.get(8).unwrap();
820+
let json_value: Vec<u8> = row.get(8).unwrap();
821+
let json_value: JsonValue = serde_json::from_slice(&json_value)?;
820822
anyhow::ensure!(
821823
json_value != serde_json::Value::Null,
822824
"Index reference to deleted document {:?} {:?}",
@@ -1133,7 +1135,8 @@ impl<RT: Runtime> PersistenceReader for MySqlReader<RT> {
11331135

11341136
let row = row_stream.try_next().await?;
11351137
let value = row.map(|r| -> anyhow::Result<JsonValue> {
1136-
let json_value: serde_json::Value = r.get(0).unwrap();
1138+
let json_value: Vec<u8> = r.get(0).unwrap();
1139+
let json_value = serde_json::from_slice(&json_value)?;
11371140
Ok(json_value)
11381141
});
11391142
value.transpose()

0 commit comments

Comments
 (0)