AIStor Files
Operate

Ownership and Fencing

One node runs each cell of an export. A lease enforces it, and fencing stops a node that lost it.

AIStor splits each export into cells, and one node runs each cell. AIStor decides which node. A lease on each cell enforces it, so two nodes never write the same cell, even after a mistake.

How the lease works

Each cell's lease is an object in the bucket, next to the export's data. The node that runs the cell is its owner. The owner:

  1. Takes the lease before it serves the cell.
  2. Stamps an ownership generation on everything it writes. The generation increases each time a node takes the cell.
  3. Renews its leases every 6 seconds. One write covers every cell it runs.
  4. Fences a cell when it cannot renew within the lease term, or when another node took the lease.

The lease term is 30 seconds by default. To change it, see Change how fast cells move.

A second gateway cannot take a lease that the owner renews. It does not serve the cell instead.

What fenced means

A fenced cell refuses every change. Clients get stale file handle errors (ESTALE) on writes to files in it. Reads still come from the node's local copy, which may be out of date. The node discards buffered writes that had not yet reached AIStor.

A cell is fenced for one of two reasons:

  • The node could not reach AIStor for longer than the lease term.
  • Another node took the cell.

Fencing is deliberate. A node that cannot confirm it still owns a cell must stop changing it, or two nodes could write one namespace.

Detect a fenced export

  • mc files export list myaistor --status fenced lists fenced exports.
  • mc files export cells shows fenced for each fenced cell.
  • The metric minio_files_lease_fenced is 1. Page on it. See Monitoring.

Respond to a fenced export

When the node reaches the other nodes again, one of three things happens to each cell:

  • No other node used the cell meanwhile: the node takes it back and serves it, by itself.
  • Another node took the cell: that node serves it, and this node gives it up.
  • The node cannot take the cell back: it stays fenced. Follow these steps. If another node took the cell, do not restart AIStor on this node: the cell would still not start here. See Start-up errors. Otherwise:

Fix the cause. Usually the node lost its connection to AIStor. Check the network and the AIStor log on that node.

Restart AIStor on that node. AIStor stops the gateway and starts it again. The node takes its cells' leases again and serves.

Have clients remount if they still get ESTALE.

After a crash

A node that stops without a clean shutdown keeps its cells' leases until they run out. AIStor gives its cells to other nodes after 15 seconds. Another node serves a cell once its lease has gone unrenewed for the lease term plus 3 seconds, and takes it at a new generation. See If a node is lost.