Skip to content
Prev Previous commit
Next Next commit
add upgrade guide
  • Loading branch information
haohuaijin committed Apr 24, 2026
commit 344b52f47353da294e6ea8e5200728387a4d0da3
54 changes: 54 additions & 0 deletions docs/source/library-user-guide/upgrading/54.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,57 @@ impl Default for MyTreeNode {
}
}
```

### `MemoryPool` now requires `'static` (adds `Any` as a supertrait)

To enable downcasting of `dyn MemoryPool` to concrete pool types (via
`is::<T>()` / `downcast_ref::<T>()`), the `MemoryPool` trait now has `Any`
as a supertrait:

```rust,ignore
// Before
pub trait MemoryPool: Send + Sync + std::fmt::Debug + Display { ... }

// After
pub trait MemoryPool: Any + Send + Sync + std::fmt::Debug + Display { ... }
```

Because `Any` is only implemented for `'static` types, this implicitly adds a
`'static` bound to every `MemoryPool` implementor.

**Who is affected:**

- Users who implement a custom `MemoryPool` whose type carries a lifetime
parameter or borrows state (e.g. `struct MyPool<'a> { inner: &'a State }`).
Existing implementations that are already `'static` (the common case) need
no changes.

**Migration guide:**

Replace borrowed references with owned handles so the pool type becomes
`'static`. The typical fix is to swap `&'a T` for `Arc<T>` (or `Rc<T>`, or an
owned value):

```rust,ignore
// Before — not 'static, no longer compiles
struct MyPool<'a> {
inner: &'a SomeState,
}

impl<'a> MemoryPool for MyPool<'a> { ... }

// After — owned handle makes MyPool: 'static
struct MyPool {
inner: Arc<SomeState>,
}

impl MemoryPool for MyPool { ... }
```

If the borrowed state truly cannot be made `'static`, you can wrap the
borrowed pool in a `'static` adapter that the pool consumer owns — for
example, store the underlying state in an `Arc` owned by the adapter, or
move the borrow behind an interior-mutability primitive such as `Arc<Mutex<_>>`
or `Arc<OnceLock<_>>`.

See [PR #21803](https://github.com/apache/datafusion/pull/21803) for details.
Loading