Skip to content

Conversation

@bobbai00
Copy link
Contributor

This PR fixes the issue of FileDocumentSpec. Two test cases were written incorrectly.

The Behavior of the Bug

Two test cases occasionally fail in FileDocumentSpec. One is for concurrently writing to the same file document, and the other is for concurrently reading from one file document. The failure occurs due to race conditions where multiple threads access the file without proper synchronization.

How the Fix is Done

  • Concurrent Writes: The fix ensures all threads share the same FileDocument instance, allowing ReentrantReadWriteLock to properly synchronize write access, preventing race conditions.

  • Concurrent Reads: The fix ensures that multiple threads can safely read from the file after the write operation is complete, using the same instance to coordinate access.

@bobbai00 bobbai00 added the fix label Oct 22, 2024
@bobbai00 bobbai00 requested a review from Yicong-Huang October 22, 2024 01:21
@bobbai00 bobbai00 self-assigned this Oct 22, 2024
Copy link
Contributor

@Yicong-Huang Yicong-Huang left a comment

Choose a reason for hiding this comment

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

I have some questions regarding the expected functionality.

@bobbai00 bobbai00 requested a review from Yicong-Huang October 22, 2024 02:25
Copy link
Contributor

@Yicong-Huang Yicong-Huang left a comment

Choose a reason for hiding this comment

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

Good to unblock the CI. Need to revisit for more thorough concurrency tests.

@bobbai00 bobbai00 merged commit 917678a into master Oct 24, 2024
@bobbai00 bobbai00 deleted the jiadong-fix-file-ducment-spec branch October 24, 2024 14:01
bobbai00 added a commit that referenced this pull request Oct 24, 2024
This PR fixes the issue of `FileDocumentSpec`. Two test cases were
written incorrectly.

## The Behavior of the Bug

Two test cases occasionally fail in `FileDocumentSpec`. One is for
concurrently writing to the same file document, and the other is for
concurrently reading from one file document. The failure occurs due to
race conditions where multiple threads access the file without proper
synchronization.

## How the Fix is Done

- **Concurrent Writes**: The fix ensures all threads share the same
`FileDocument` instance, allowing `ReentrantReadWriteLock` to properly
synchronize write access, preventing race conditions.
  
- **Concurrent Reads**: The fix ensures that multiple threads can safely
read from the file after the write operation is complete, using the same
instance to coordinate access.
PurelyBlank pushed a commit that referenced this pull request Dec 4, 2024
This PR fixes the issue of `FileDocumentSpec`. Two test cases were
written incorrectly.

## The Behavior of the Bug

Two test cases occasionally fail in `FileDocumentSpec`. One is for
concurrently writing to the same file document, and the other is for
concurrently reading from one file document. The failure occurs due to
race conditions where multiple threads access the file without proper
synchronization.

## How the Fix is Done

- **Concurrent Writes**: The fix ensures all threads share the same
`FileDocument` instance, allowing `ReentrantReadWriteLock` to properly
synchronize write access, preventing race conditions.
  
- **Concurrent Reads**: The fix ensures that multiple threads can safely
read from the file after the write operation is complete, using the same
instance to coordinate access.
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