[SERVER-54878] Compact can log incorrect value for freedBytes Created: 02/Mar/21  Updated: 23/Jan/24  Resolved: 05/May/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 4.4.0, 4.4.4
Fix Version/s: 4.4.7, 5.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Bruce Lucas (Inactive) Assignee: Gregory Wlodarek
Resolution: Fixed Votes: 0
Labels: newgrad
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.4
Sprint: Execution Team 2021-05-17
Participants:
Case:

 Description   

When compacting a collection that is actively being written it is possible that the collection is larger at the completion of compaction than when it started; I assume that this is an expected outcome. In this case the operation returns a negative number for bytesFreed:

{
	"bytesFreed" : -339968,
	"ok" : 1,
	"$clusterTime" : {
		"clusterTime" : Timestamp(1614690587, 925),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" : NumberLong(0)
		}
	},
	"operationTime" : Timestamp(1614690587, 898)
}

Whereas an absurdly large value is logged for freedBytes:

{"t":{"$date":"2021-03-02T08:09:47.634-05:00"},"s":"I",  "c":"STORAGE",  "id":20286,   "ctx":"conn24","msg":"Compact end","attr":{"namespace":"test.c","freedBytes":18446744073709211648}}

It looks like compactCollection is incorrectly treating the negative signed value as unsigned when it logs it.

Possibly both values should be logged as 0, since logging a negative value may make it appear that compact is malfunctioning.

Also, it would be good to make the command result and the log statement consistent; suggest changing the log statement to use "bytesFreed" as it seems less likely that users will be affected by changing the log statement than by changing the command return.



 Comments   
Comment by Githook User [ 10/May/21 ]

Author:

{'name': 'Gregory Wlodarek', 'email': 'gregory.wlodarek@mongodb.com', 'username': 'GWlodarek'}

Message: SERVER-54878 Compact can log negative value for bytesFreed

(cherry picked from commit c48ddf533938bc4ae85ae120b63c1de0ee290e26)
Branch: v4.4
https://github.com/mongodb/mongo/commit/fd200767a125ac704ebd67630246eccfc2670120

Comment by Githook User [ 05/May/21 ]

Author:

{'name': 'Gregory Wlodarek', 'email': 'gregory.wlodarek@mongodb.com', 'username': 'GWlodarek'}

Message: SERVER-54878 Compact can log negative value for bytesFreed
Branch: master
https://github.com/mongodb/mongo/commit/c48ddf533938bc4ae85ae120b63c1de0ee290e26

Generated at Thu Feb 08 05:34:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.