Skip to content

docs(pycubrid): warn that a bare SELECT-then-update is not a safe ODKU fallback - #631

Open
IG-ABHINAV wants to merge 5 commits into
cubrid-lab:mainfrom
IG-ABHINAV:docs/atomic-counter-fallback-626
Open

IG-ABHINAV wants to merge 5 commits into
cubrid-lab:mainfrom
IG-ABHINAV:docs/atomic-counter-fallback-626

Conversation

@IG-ABHINAV

Copy link
Copy Markdown

What & why

Issue #626 points out that the header of fundamentals/pycubrid/13_atomic_counters.py correctly teaches INSERT ... ON DUPLICATE KEY UPDATE hit_count = hit_count + ? as an atomic increment, but then suggests switching to a bare SELECT-then-INSERT/UPDATE if ODKU is unsupported. Without a transaction, locking, or compare-and-swap strategy, two writers can both read the same count and overwrite an increment, or race to insert the same key.

Without a transaction/locking or compare-and-swap strategy, two writers can both read the same count, overwriting an increment or racing to insert the same key.

Closes #626

How

  • Rewrote the recipe's adaptation note so a bare SELECT-then-INSERT/UPDATE is not offered as a drop-in fallback, and a safe alternative is described as needing its own concurrency design (this recipe does not include one).
  • Updated the 13_atomic_counters.py row in fundamentals/pycubrid/README.md to say the same thing.
  • Left the runnable ODKU SQL, golden outputs, and driver requirements unchanged.

Verification

The Makefile check-docs / docs-check targets were run as the equivalent Python commands (make is not installed on this machine). Results:

  1. python3 -m doctest scripts/check_docs_reason.py -v — 6 passed.
  2. python3 -m unittest discover -s tests -p 'test_docs_reason.py' -v — 15 tests, OK.
  3. python3 -m doctest scripts/check_docs_sync.py -v — 25 passed.
  4. python3 -m unittest discover -s tests -p 'test_docs_sync.py' -v — 23 tests, OK.
  5. python3 scripts/check_docs_sync.py — exit 0, OK: every example directory is referenced in README.md and llms.txt.
  6. python3 scripts/check_support_matrix_counts.py — exit 0, counts match.
  7. python3 scripts/check_dependency_floors.py — exit 0, floors match.
  8. python3 -m unittest discover -s tests -p 'test_translation_sync.py' -v — 17 tests, OK.
  9. python3 -m doctest scripts/stage_docs.py -v — 6 passed.
  10. python3 -m unittest discover -s tests -p 'test_stage_docs.py' -v — 21 tests, OK.
  11. python3 -m unittest discover -s tests -p 'test_lint_changelog.py' -v — 24 tests, OK.
  12. python3 scripts/lint_changelog.py — exit 0, OK: no release sections yet; tags v0.1.0, v0.2.0 predate CHANGELOG.md and have none.
  13. In a venv with markdown-it-py==4.2.0 and pytest==9.2.0 from .github/requirements-docs-check.txt:
    • python -m pytest tests/test_check_docs_links.py -q — 201 passed, 4 skipped in 1.01s
    • python scripts/check_docs_links.py — exit 0, OK: 83 Markdown files; local links, anchors, fences and commands resolve

Commit: 058b80f — author:IG-ABHINAV IG-ABHINAV@users.noreply.github.com committer:IG-ABHINAV IG-ABHINAV@users.noreply.github.com

Judgment calls

  • No new SQL, locking example, or performance claim was added, as the issue asked to keep ODKU as the runnable demonstration.
  • CHANGELOG.md and SUPPORT_MATRIX.md were left unchanged: no example was added, renamed, removed, or given new runtime behavior; only comments and the fundamentals README were updated.
  • Live CUBRID was not required for this comment/docs-only change (N/A).

High level description of this Pull-request

See What & why / How above.

Example Details

  • Python/Framework: Python / pycubrid fundamentals
  • Tested against CUBRID version: N/A — documentation/comment change only; no live SQL was run or claimed.

Validation

  • Commands actually executed and their results: see Verification.
  • Checks not executed, reason, and remaining gaps: ruff was not on PATH at first; live CUBRID and make verify were not run because executable SQL and goldens were not changed.
  • Optional additional AI/tool review: N/A

Review and Final Disposition

  • Required GitHub CI at final head: pending
  • Applicable live CUBRID test evidence: N/A — comments and README only; no SQL or golden change.
  • Optional AI review: N/A
  • Finding dispositions: none
  • Open threads and blocking defects: none
  • Maintainer merge decision: pending

Related PRs and Execution Preconditions

Related PRs and precedence: None
Unresolved decision or dependency: None

Related Issues

Closes #626

CHECKLIST:

  • Example has been tested against a live CUBRID instance — N/A, no executable change
  • All table names are prefixed with cookbook_ (unchanged)
  • README with setup and run instructions is included (fundamentals README updated)
  • Python code passes ruff check and ruff format --check — will note in a follow-up comment if needed; only a docstring was edited
  • No hardcoded credentials — environment variables used (unchanged)
  • Tests updated — N/A, no example behavior change, existing goldens untouched
  • Docs updated — recipe comment and fundamentals README; SUPPORT_MATRIX and CHANGELOG unchanged because no example was added, renamed, or removed

…U fallback

Qualify the atomic-counter recipe's adaptation note and README so a
non-atomic read-modify-write is not suggested as a drop-in replacement
for ON DUPLICATE KEY UPDATE.

Fixes cubrid-lab#626

@yeongseon yeongseon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed HEAD 058b80f. The replacement docstring correctly warns that a bare SELECT-then-INSERT/UPDATE cannot replace the SQL-side atomic ODKU increment under concurrency, and README now states the same distinction. No executable behavior changes. Source approved; CI is action_required and #634 overlaps on the same recipe, so merge at most one final treatment and coordinate the competing PR.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: qualify the non-atomic fallback suggested by the atomic-counter recipe

2 participants