From b05b6e13c53b75a7a3cd6bcb7cdfd2ff05516195 Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Fri, 6 Mar 2026 15:16:21 +0000 Subject: [PATCH] Add more verbosity for panic inside `summaries_for_anchors_with_payloads` (#50940) (cherry-pick to preview) (#50942) Cherry-pick of #50940 to preview ---- We are seeing the timestamp comparison fail in an unexpected way, e.g. https://zed-dev.sentry.io/issues/7293482758/events/c7f7eab3f8f2463f879d4889a80d623e, where it seems like `text::Anchor::is_max` should be returning true but it apparently isn't. Add some more information when this panic happens to understand what's going on. Release Notes: - N/A Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Co-authored-by: Cole Miller Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> --- crates/text/src/anchor.rs | 4 ++-- crates/text/src/text.rs | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/text/src/anchor.rs b/crates/text/src/anchor.rs index 63e0570e91ef08dfce02fbbca25e97ee7519dc0a..5c4cce0f11d7db7b7593631e796c0f5e3d50adab 100644 --- a/crates/text/src/anchor.rs +++ b/crates/text/src/anchor.rs @@ -15,8 +15,8 @@ pub struct Anchor { // we store the replica id and sequence number of the timestamp inline // to avoid the alignment of our fields from increasing the size of this struct // This saves 8 bytes, by allowing replica id, value and bias to occupy the padding - timestamp_replica_id: clock::ReplicaId, - timestamp_value: clock::Seq, + pub(crate) timestamp_replica_id: clock::ReplicaId, + pub(crate) timestamp_value: clock::Seq, /// The byte offset into the text inserted in the operation /// at `timestamp`. diff --git a/crates/text/src/text.rs b/crates/text/src/text.rs index a5bdbe443bbaa4723c8d3104bfed28e4c2fe8fdb..a991a72df40c502a90aa0b82191b37c54b3f8de2 100644 --- a/crates/text/src/text.rs +++ b/crates/text/src/text.rs @@ -2379,13 +2379,22 @@ impl BufferSnapshot { anchor ); }; + // TODO verbose debug because we are seeing is_max return false unexpectedly, + // remove this once that is understood and fixed assert_eq!( insertion.timestamp, anchor.timestamp(), - "invalid insertion for buffer {}@{:?} and anchor {:?}", + "invalid insertion for buffer {}@{:?}. anchor: {:?}, {:?}, {:?}, {:?}, {:?}. timestamp: {:?}, offset: {:?}, bias: {:?}", self.remote_id(), self.version, - anchor + anchor.timestamp_replica_id, + anchor.timestamp_value, + anchor.offset, + anchor.bias, + anchor.buffer_id, + anchor.timestamp() == clock::Lamport::MAX, + anchor.offset == u32::MAX, + anchor.bias == Bias::Right, ); fragment_cursor.seek_forward(&Some(&insertion.fragment_id), Bias::Left);