Skip to content

Fix concurrent read lock bug in StampedWriterPreferredLock#11453

Merged
MarcosZyk merged 1 commit intoapache:masterfrom
Cpaulyz:fix_StampedLock
Nov 2, 2023
Merged

Fix concurrent read lock bug in StampedWriterPreferredLock#11453
MarcosZyk merged 1 commit intoapache:masterfrom
Cpaulyz:fix_StampedLock

Conversation

@Cpaulyz
Copy link
Contributor

@Cpaulyz Cpaulyz commented Nov 1, 2023

Description

Fix issues in concurrent scenarios, for example:

  1. Thread A successfully acquire write lock
  2. Thread B acquire read lock and wait
  3. Thread A release write lock
  4. Thread C successfully acquire write lock

At this time, Thread B may be waked up and try to get read lock. So it's necessary to judge (prior ? writeCnt : writeCnt + writeWait) > 0 again. Otherwise, there are one writer and one reader holding lock.

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