Skip to content

Conversation

@jamengual
Copy link
Contributor

Summary

This PR adds comprehensive documentation for Atlantis's locking mechanisms, providing the definitive reference for understanding how locks prevent race conditions and ensure safe concurrent Terraform operations.

Documentation Overview

The guide documents all three lock types:

  1. Project Locks (Database-Persisted)

    • Prevents concurrent plan/apply on same project+workspace
    • Survives server restarts
    • Key format: {repo}/{path}/{workspace}
  2. Working Directory Locks (In-Memory)

    • Prevents concurrent filesystem operations
    • Automatic cleanup via defer
    • Key format: {repo}/{pullNum}/{workspace}/{path}
  3. Apply Command Locks (Global)

    • System-wide apply control
    • Emergency maintenance capability

What's Included

Why This Documentation?

Current state:

  • Locking behavior scattered across code comments
  • Users struggle with "workspace locked" errors
  • No single reference for lock interactions
  • Historical context (PR docs(adr): Project Locks 0002 #3345 ADR) not easily accessible

This guide provides:

  • Single authoritative reference
  • Quick error resolution lookup
  • Understanding of lock hierarchy
  • Context for ongoing improvements

File Location

ATLANTIS_LOCKING_COMPREHENSIVE_GUIDE.md (root directory)

Alternative locations to consider:

  • docs/locking-mechanisms.md
  • docs/architecture/locking.md

Open to suggestions on best location.

Related

Test Plan

  • Documentation accuracy verified against codebase
  • All code references include correct file paths and line numbers
  • Error messages match actual implementation
  • Workflows tested against current behavior

🤖 Generated with Claude Code

This comprehensive guide documents Atlantis's three-tiered locking system:
- Project Locks (database-persisted)
- Working Directory Locks (in-memory)
- Apply Command Locks (global)

Includes:
- Detailed architecture analysis
- Lock interaction workflows
- Troubleshooting guide with error messages
- Best practices with code examples
- Historical context (PR #3345, issues #5722, #2200)
- Developer reference with testing patterns

The documentation is based on deep analysis of the codebase,
including all lock implementations, database layers, and
concurrency patterns.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants