[SERVER-32369] Invariant incorrectly with message stringifies its argument Created: 15/Dec/17  Updated: 30/Oct/23  Resolved: 26/Dec/17

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 3.6.9, 3.7.1

Type: Bug Priority: Critical - P2
Reporter: Geert Bosch Assignee: Benety Goh
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
is caused by SERVER-31830 Log values in invariant statements Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.6
Sprint: Repl 2018-01-01
Participants:

 Description   

When testing an invariant with message by actually failing it, I noticed that the invariant includes the source code for the message expression rather than its contents:

2017-12-15T13:35:44.594-0500 F -        [conn1] Invariant failure catalogColl->uuid() != uuid uuid + "," + catalogColl->uuid src/mongo/db/catalog/uuid_catalog.cpp 68

This negates the objective of SERVER-31830, which was to print the actual variable contents. Also, rather than accepting a string, we probably should just accept arguments and dumping them as strings. Otherwise code use to build strings would be inactive untested code.

As this ticket shows, untested inactive code is likely to contain bugs.



 Comments   
Comment by Githook User [ 19/Sep/18 ]

Author:

{'name': 'Suganthi Mani', 'email': 'suganthi.mani@mongodb.com', 'username': 'smani87'}

Message: SERVER-32369 fix invariant message in UUIDCatalog

(cherry picked from commit 7cb2563388f77c7f0fea72811f512321f23096bd)
Branch: v3.6
https://github.com/mongodb/mongo/commit/2275d07b8e653e62bfa3bf505ced27e413e7050f

Comment by Githook User [ 19/Sep/18 ]

Author:

{'name': 'Suganthi Mani', 'email': 'suganthi.mani@mongodb.com', 'username': 'smani87'}

Message: SERVER-32369 evaluate invariant message before passing to invariantFailedWithMsg()

(cherry picked from commit 9348c9f11174019ee1be93b25c3f44d070194472)
Branch: v3.6
https://github.com/mongodb/mongo/commit/a6db66472cd17acc9e8969f98d109142da608940

Comment by Githook User [ 26/Dec/17 ]

Author:

{'username': 'benety', 'name': 'Benety Goh', 'email': 'benety@mongodb.com'}

Message: SERVER-32369 evaluate invariant message before passing to invariantFailedWithMsg()
Branch: master
https://github.com/mongodb/mongo/commit/9348c9f11174019ee1be93b25c3f44d070194472

Comment by Githook User [ 26/Dec/17 ]

Author:

{'username': 'benety', 'name': 'Benety Goh', 'email': 'benety@mongodb.com'}

Message: SERVER-32369 fix invariant message in UUIDCatalog
Branch: master
https://github.com/mongodb/mongo/commit/7cb2563388f77c7f0fea72811f512321f23096bd

Generated at Thu Feb 08 04:30:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.