Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Locking

Direct answer

NETCONF locking (lock and unlock operations) gives one session exclusive access to a datastore while it makes changes, preventing other sessions or users from editing at the same time.

When to use this

Use this when preventing concurrent NETCONF edits.

First 30 seconds

1. Lock datastores during changes to prevent conflicts.

2. Always unlock (finally).

3. Handle lock-denied (someone else editing).

4. Short lock duration.

5. Kill stale sessions carefully.

Operational verification

lock → edit → commit → unlock

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
NETCONF / YANG datastore automation
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformNETCONF / YANG datastore automation · Automation implementations are tool and platform specific. Use the adjacent Domain for the technology being automated and this Domain for automation behavior.
Scope / prerequisiteUse this when preventing concurrent NETCONF edits.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Verification path Verify boundary

The negative fixture should deliberately exercise risks such as capability mismatch, namespace drift, wrong datastore, lock contention, partial edit semantics and assuming <ok/> shows final device behavior, choosing the cases most relevant to NETCONF lock/unlock ownership, datastore scope, lock-denied errors, session loss and preventing concurrent writers from assuming transaction safety.

Step 2 Common mistakes Narrow the fault
  • Forgetting to unlock after an error.
  • Not locking when other tools may edit at the same time.
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points
  • lock gives one session exclusive access to a datastore.
  • Always unlock, even after errors.
  • Lock fails if another session holds it.
Key checks
  • <lock target=candidate/running> — exclusive access
  • <unlock> in finally — release
  • Lock-denied handling — retry/wait
ReferenceWhy it matters1 section · depth on demand

What it is

<lock> gives one session exclusive access to a datastore during a multi-step change; <unlock> releases it.

ReferenceImportant terms & boundaries1 section · depth on demand

In depth

Locking prevents other sessions — people on the CLI or other automation — from changing a datastore while a NETCONF change is in progress. Without it, two sources can interleave changes and produce a configuration neither intended.

with m.locked(target="running"):
    m.edit_config(target="running", config=cfg)

A lock fails if another session holds it or if the datastore has uncommitted changes; the error identifies the session ID. Locks are released when the session ends, so a crashed script does not lock the device forever. Keep locks short and never hold them while waiting for human input.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docNETCONF / YANG datastore automation current

Authoritative/upstream documentation reviewed for bounded claims in NETCONF > Locking. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://www.rfc-editor.org/rfc/rfc6241 · confidence 94%
Depth when you need it

Deep reference

Healthy vs suspicious evidence

Output interpretation

For NETCONF lock/unlock ownership, datastore scope, lock-denied errors, session loss and preventing concurrent writers from assuming transaction safety, prefer typed fields and stable IDs over human presentation text.

Confirmation

Confirm action

Continue?