Skip to content

Commit 4e331c8

Browse files
nipunn1313Convex, Inc.
authored and
Convex, Inc.
committed
Format showing the occ read stacks a bit better (#36216)
When hitting a system OCC - this lets you get the exact stacktrace of the read that leads to the OCC. GitOrigin-RevId: e14040d16219a0b288bbba056b649859bdea73b0
1 parent cdfbdbf commit 4e331c8

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

crates/database/src/database.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -2234,22 +2234,22 @@ impl ConflictingReadWithWriteSource {
22342234
current_writer.0.as_deref().unwrap_or("unknownwriter")
22352235
);
22362236

2237-
let formatted = if let Some(stack_traces) = self.read.stack_traces {
2238-
format!(
2239-
"{msg}. Displaying {}/{} stack traces of relevant reads. Increase \
2240-
NUM_READ_SET_STACKS for more:\n{}",
2237+
let formatted = format!(
2238+
"{msg}. Use RUST_BACKTRACE=1 READ_SET_CAPTURE_BACKTRACES=true to find trace of \
2239+
relevant reads"
2240+
);
2241+
2242+
if let Some(stack_traces) = self.read.stack_traces {
2243+
tracing::error!(
2244+
"Displaying {}/{} stack traces of relevant reads. Increase NUM_READ_SET_STACKS \
2245+
for more:",
22412246
cmp::min(*NUM_READ_SET_STACKS, stack_traces.len()),
22422247
stack_traces.len(),
2243-
stack_traces
2244-
.iter()
2245-
.take(*NUM_READ_SET_STACKS)
2246-
.join(&format!("\nRead of {index} occured at\n"))
2247-
)
2248-
} else {
2249-
format!(
2250-
"{msg}. Use RUST_BACKTRACE=1 READ_SET_CAPTURE_BACKTRACES=true to find trace of \
2251-
relevant reads"
2252-
)
2248+
);
2249+
2250+
for stack_trace in stack_traces.iter().take(*NUM_READ_SET_STACKS) {
2251+
tracing::error!("Read of {index} occurred at {stack_trace}");
2252+
}
22532253
};
22542254
anyhow::anyhow!(formatted).context(ErrorMetadata::system_occ())
22552255
}

0 commit comments

Comments
 (0)