Skip to content

Conversation

@yutaro-sakamoto
Copy link
Contributor

@yutaro-sakamoto yutaro-sakamoto commented Aug 19, 2025

This pull request adds file-locking and record-locking of indexed files.

File Lock

The specifications of flie-locking of indexed files are bellow.

  • While a process opened an indexed file with OUTPUT mode, other process cannot open the indexed file.
    • If a process attempts to open an indexed file locked by other process, the runtime sets the file status to 61.
  • While a process opened an indexed file, other process cannot open the indexed file with OUTPUT mode.
    • If a process, which specifies OUTPUT mode, attempts to open an indexed file locked by other process, the runtime sets the file status to 61.
  • If the above two conditions are not met, processes can open the same indexed file.

LOCK MODE clauses in SELECT clauses

  • The compiler allows AUTOMATIC or MANUAL in LOCK MODE clauses of SELECT clauses. The default value of LOCK MODE is MANUAL and the compiler uses the default value if the LOCK MODE clauses are omitted.
    • -lock-mode-automatic, a new command line option, changes the default value of LOCK MODE to AUTOMATIC.

Record Lock

  • If a process opened an indexed file with I-O mode and run READ statements specifying neither WITH LOCK nor WITH NO LOCK,
    • If the LOCK MODE is MANUAL, the runtime does not attempt to lock the record
    • If the LOCK MODE is AUTOMATIC, the runtime lock attempts to locks the record
  • If a process opened an indexed file with I-O mode and run READ statements specifying WITH LOCK, the runtime attempts to lock the record.
  • If a process opened an indexed file with I-O mode and run READ statements specifying WITH NO LOCK, the runtime does not attempt to lock locks the record.
  • WRITE, DELETE and REWRITE statements fails if another process has locked the record.
  • If a process fails to run any I/O operations to indexed files because of record locks, the runtime sets the file status to 51.
  • OPEN, CLOSE, READ, WRITE, DELETE and REWRITE statements release the record lock which the process acquired in the past.

@yutaro-sakamoto yutaro-sakamoto marked this pull request as ready for review August 19, 2025 01:47
Copilot AI review requested due to automatic review settings August 19, 2025 01:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request implements comprehensive file-locking and record-locking functionality for indexed files in the COBOL system. It adds multi-process synchronization capabilities to prevent data corruption and ensure consistency when multiple processes access the same indexed files simultaneously.

  • Implements file-level locking to control access modes (preventing multiple OUTPUT mode access)
  • Adds record-level locking with MANUAL/AUTOMATIC modes and WITH LOCK/WITH NO LOCK clauses
  • Introduces extensive test coverage for various concurrency scenarios

Reviewed Changes

Copilot reviewed 28 out of 30 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/run.src/miscellaneous.at Adds test for opening invalid formatted indexed files
tests/indexed-lock.src/*.at Comprehensive test suite for file and record locking scenarios
tests/indexed-lock.at Main test orchestrator for indexed file locking tests
tests/Makefile.in, tests/Makefile.am Build configuration updates to include new test suite
tests/.gitignore Git ignore rules for new test artifacts
libcobj/.../IndexedCursor.java Complete rewrite of cursor implementation for better concurrency support
Comments suppressed due to low confidence (1)

tests/indexed-lock.src/access-different-record.at:1

  • The word 'rewrited' should be 'rewritten' - the past tense of rewrite is rewritten.
AT_SETUP([Record locking of indexed files (different records)])

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

yutaro-sakamoto and others added 2 commits August 19, 2025 01:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@yutaro-sakamoto yutaro-sakamoto merged commit f984a89 into opensourcecobol:develop Aug 21, 2025
145 checks passed
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.

2 participants