Use Shard::OwnerRetryStrategy instead of Shard::RetryStrategy to prevent segmentation faults

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0
    • Affects Version/s: 8.3.0-rc0
    • Component/s: None
    • None
    • Catalog and Routing
    • Fully Compatible
    • ALL
    • CAR Team 2025-10-27
    • 200
    • 🟩 Routing and Topology
    • None
    • None
    • None
    • None
    • None
    • None

      The Shard::RetryStrategy is tipically used in request callbacks to determine whether a failed request needs to be retried. To make this decision, Shard::RetryStrategy holds a raw pointer to a Shard object, which it uses to call the Shard::isRetriableError() method.

      However, Shard::RetryStrategy doesn't own the shard object, it merely holds a reference. This means the pointer can become invalid if the actual Shard owner is destroyed.

      In most cases, we ensure that the shard's lifetime matches the command's lifetime, maintaining its validity throughout execution. However, this is not always enough, as request callbacks can still be triggered after the requester has been interrupted.

      To prevent invalid references and ensure safe ownership, the shard should be stored directly within the retry strategy. For this reason, we should use Shard::OwnerRetryStrategy instead of Shard::RetryStrategy.

            Assignee:
            Silvia Surroca
            Reporter:
            Silvia Surroca
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: