[SERVER-71053] Fix dataSize can be negative and incorrect on rollback Created: 03/Nov/22  Updated: 29/Oct/23  Resolved: 04/Nov/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.2.0-rc0, 6.0.5, 6.0.6, 5.0.22, 4.4.26

Type: Bug Priority: Major - P3
Reporter: Yujin Kang Park Assignee: Yujin Kang Park
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Problem/Incident
causes SERVER-74303 Add a sizeStorer call to the onRollba... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.3, v6.0, v5.0, v4.4
Sprint: Execution Team 2022-11-14
Participants:
Linked BF Score: 4

 Description   

if (_sizeInfo->dataSize.fetchAndAdd(amount) < 0)
_sizeInfo->dataSize.store(std::max(amount, int64_t(0))); 

Value is checked before adding, and clamping is done only if the previous value was negative, so the value can still be negative.

Additionally, similar to SERVER-63585 with fast count, data size can be incorrect after a rollback due to a race. We should allow dataSize to be negative internally and clamp only in the getter.



 Comments   
Comment by Githook User [ 06/Oct/23 ]

Author:

{'name': 'Yu Jin Kang Park', 'email': 'yujin.kang@mongodb.com', 'username': 'ykangpark'}

Message: SERVER-71053 Fix WiredTigerRecordStore dataSize inconsistent

(cherry picked from commit 556bf6acd152734c99160bf5cc4f4bb362b5235c)
Branch: v4.4
https://github.com/mongodb/mongo/commit/a49dffc0b7d109ea775cdcdc4d9d6a38dd144124

Comment by Githook User [ 04/Oct/23 ]

Author:

{'name': 'Yu Jin Kang Park', 'email': 'yujin.kang@mongodb.com', 'username': 'ykangpark'}

Message: SERVER-71053 Fix WiredTigerRecordStore dataSize inconsistent

(cherry picked from commit 556bf6acd152734c99160bf5cc4f4bb362b5235c)
Branch: v5.0
https://github.com/mongodb/mongo/commit/640479b965b03a9f6f0fbc039a15cd042fc869ea

Comment by Githook User [ 20/Mar/23 ]

Author:

{'name': 'Yu Jin Kang Park', 'email': 'yujin.kang@mongodb.com', 'username': 'ykangpark'}

Message: SERVER-71053 Fix WiredTigerRecordStore dataSize inconsistent

(cherry picked from commit 556bf6acd152734c99160bf5cc4f4bb362b5235c)
Branch: v6.0
https://github.com/mongodb/mongo/commit/b4bfe675c0f077a3907d85ec7f8fd998e9f41d02

Comment by Githook User [ 25/Jan/23 ]

Author:

{'name': 'Yu Jin Kang Park', 'email': 'yujin.kang@mongodb.com', 'username': 'ykangpark'}

Message: SERVER-71053 Fix WiredTigerRecordStore dataSize inconsistent

(cherry picked from commit 556bf6acd152734c99160bf5cc4f4bb362b5235c)
Branch: v6.0
https://github.com/mongodb/mongo/commit/4fedf80d4847e2f668ed5db555bf8e6551bf95d2

Comment by Liubov Molchanova [ 12/Jan/23 ]

Requesting a backport for v6.0 as the issue reoccurred in BFG-1746327

Comment by Githook User [ 03/Nov/22 ]

Author:

{'name': 'Yu Jin Kang Park', 'email': 'yujin.kang@mongodb.com', 'username': 'ykangpark'}

Message: SERVER-71053 Fix WiredTigerRecordStore dataSize inconsistent
Branch: master
https://github.com/mongodb/mongo/commit/556bf6acd152734c99160bf5cc4f4bb362b5235c

Generated at Thu Feb 08 06:17:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.