Merge pull request #2998 from tnull/2024-04-fix-potential-lock-race-in-CM-write