﻿# Publish a memory-window key only after its bind boundary

Distinguish posting a type-one memory-window bind from successful completion before distributing the new remote key through another channel.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/rdma-memory-window-bind-key-publication/
Language: en

## The control message outruns the binding

A service allocates a memory window, requests a bind and immediately sends its new remote key over a separate control connection. The peer starts accessing the window before the bind's success is known. This is not solved by observing that the bind call returned successfully. The call and the asynchronous operation have different completion boundaries, and the independent control channel supplies no ordering relationship by itself.

## Allocation creates an unbound object

The [memory-window allocation reference](https://man7.org/linux/man-pages/man3/ibv_alloc_mw.3.html) describes a newly allocated window as unbound. Once bound, it permits access to a subset of a memory region until the applicable invalidation or deallocation. The key can change during binding. Therefore, storing the window pointer and a newly returned key does not establish that the advertised address range, access permissions and key currently form a usable remote capability.

## A successful call only posts the bind

The [type-one bind contract](https://man7.org/linux/man-pages/man3/ibv_bind_mw.3.html) explicitly says the bind does not complete when the function returns. The application should retain the old key and reconcile its local window structure if the later completion reports failure. It distinguishes a send on the same QP, ordered after the bind, from communicating the key by another mechanism before a successful CQ entry is read. That narrow ordering exception must not be extended to an unrelated socket, queue pair or message broker.

## Make publication an explicit state change

Keep the proposed key, region, range, access flags and work identifier in a pending binding record. The independent control plane should publish a usable descriptor only after the matching successful completion is observed. On failure, preserve the old state according to the API contract and prevent a pending descriptor from becoming discoverable. A timeout waiting for completion is uncertainty, not permission to assume success. Type-two windows use different work-request operations and require their own applicable contract.

## Evidence for the publication protocol

An isolated test should delay completion processing while the control channel remains fast, showing that the peer cannot obtain a supposedly usable pending descriptor. Include an unsuccessful bind and verify that the announced key does not silently advance. After a valid success, confirm permitted access to the intended range and correct teardown. Preserve which communication path carried the key; otherwise a test using same-QP ordering cannot validate a production implementation that publishes independently.

## Keep revocation separate

Publishing a key after successful binding does not revoke older descriptors already held elsewhere or prove that all remote operations have quiesced. Window invalidation and region cleanup need their own synchronization and outcome handling; the allocation reference notes that deregistration fails while a window remains bound. The [registration guide](/journal/guide-net-rdma-memory-registration/) explains region lifetime, and [completion interpretation](/journal/guide-net-rdma-completion/) separates posting from execution. The acceptance question here is deliberately narrower: whether independent publication respects the successful bind boundary rather than racing an asynchronous change.
