[SERVER-51492] write_unit_of_work has circular typeinfo dependency to service_context Created: 12/Oct/20  Updated: 06/Dec/22  Resolved: 09/Jul/21

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

Type: Bug Priority: Major - P3
Reporter: Daniel Moody Assignee: Backlog - Service Architecture
Resolution: Won't Do Votes: 0
Labels: servicearch-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-49798 Enforce correct library graph for ubs... Closed
Assigned Teams:
Service Arch
Operating System: ALL
Steps To Reproduce:

To reproduce on ubuntu 18.04 work station, remove the LIBDEPS_TAG attached to the write_unit_of_work library in the SConscript as shown by this patch diff:

diff --git a/src/mongo/db/storage/SConscript b/src/mongo/db/storage/SConscript
index d8fc600d89..ef2aed6791 100644
--- a/src/mongo/db/storage/SConscript
+++ b/src/mongo/db/storage/SConscript
@@ -359,9 +359,7 @@ env.Library(
         '$BUILD_DIR/mongo/util/fail_point',
         'recovery_unit_base',
     ],
-    LIBDEPS_TAGS=[
-        'libdeps-cyclic-typeinfo'
-    ],
+
 
 )

Then build with this SCons invocation:

python3 ./buildscripts/scons.py --variables-files=etc/scons/mongodbtoolchain_v3_clang.vars --dbg=on --opt=on --sanitize=undefined --ssl --enable-free-mon=on -j200 --separate-debug --install-action=hardlink --jlink=0.25 --cache-debug=scons_cache.log --debug=time --build-tools=next CCACHE=ccache ICECC=icecc --implicit-cache --build-fast-and-loose=on --link-model=dynamic install-unittests install-unittests-debug

You should see a build failure like this:

Linking build/optdebug/mongo/db/storage/libwrite_unit_of_work.so | LibdepLinter: Missing typeinfo definitions: undefined symbol: typeinfo for mongo::OperationContext (build/optdebug/mongo/db/storage/libwrite_unit_of_work.so)

Participants:
Story Points: 4

 Description   

The library write_unit_of_work needs typeinfo for mongo::OperationContext in UBSAN builds, but if the library, service_context, which contains the definition of that typeinfo is linked to it, this caused a circular dependency between the two librarys.

 

We need to extract the typeinfo definition into its own library that both write_unit_of_work and service_context can link, and any other librarys that need the mongo::OperationContext typeinfo defined.

Acceptance Criteria:

Remove dependency of service_context on write_unit_of_work via constructor actions or other decoupling mechanisms. 
Verify that we have removed the circular dependency mentioned in the repro. 

 


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