1MONGOC_BASIC_TROUBLESHOOTING(3) libmongoc MONGOC_BASIC_TROUBLESHOOTING(3)
2
3
4
6 The following is a short list of things to check when you have a prob‐
7 lem.
8
9 • Did you call mongoc_init() in main()? If not, you will likely see a
10 segfault.
11
12 • Have you leaked any clients or cursors as can be found with mon‐
13 goc-stat <PID>?
14
15 • Have packets been delivered to the server? See egress bytes from mon‐
16 goc-stat <PID>.
17
18 • Does ASAN show any leaks? Ensure you call mongoc_cleanup() at the end
19 of your process to cleanup lingering allocations from the MongoDB C
20 driver.
21
22 • If compiling your own copy of MongoDB C Driver, consider using the
23 cmake option -DENABLE_TRACING=ON to enable function tracing and hex
24 dumps of network packets to STDERR and STDOUT.
25
27 The MongoDB C Driver comes with an optional and unique feature to help
28 developers and sysadmins troubleshoot problems in production. Perfor‐
29 mance counters are available for each process using the C Driver. If
30 available, the counters can be accessed outside of the application
31 process via a shared memory segment. The counters may be used graph
32 statistics about your application process easily from tools like Munin
33 or Nagios. For example, the command watch --interval=0.5 -d mon‐
34 goc-stat $PID may be used to monitor an application.
35
36 Performance counters are only available on Linux platforms and macOS
37 arm64 platforms that support shared memory segments. On supported
38 platforms, they are enabled by default. Applications can be built
39 without the counters by specifying the cmake option -DENABLE_SHM_COUN‐
40 TERS=OFF. Additionally, if performance counters are already compiled,
41 they can be disabled at runtime by specifying the environment variable
42 MONGOC_DISABLE_SHM.
43
44 Performance counters keep track of the following:
45
46 • Active and Disposed Cursors
47
48 • Active and Disposed Clients, Client Pools, and Socket Streams.
49
50 • Number of operations sent and received, by type.
51
52 • Bytes transferred and received.
53
54 • Authentication successes and failures.
55
56 • Number of wire protocol errors.
57
58 NOTE:
59 An operation is considered "sent" when one or more bytes of the cor‐
60 responding message is written to the stream, regardless of whether
61 the entire message is successfully written or if the operation ulti‐
62 mately succeeds or fails. This does not include bytes that may be
63 written during the stream connection process, such as TLS handshake
64 messages.
65
66 To access counters for a given process, simply provide the process id
67 to the mongoc-stat program installed with the MongoDB C Driver.
68
69 $ mongoc-stat 22203
70 Operations : Egress Total : The number of sent operations. : 13247
71 Operations : Ingress Total : The number of received operations. : 13246
72 Operations : Egress Queries : The number of sent Query operations. : 13247
73 Operations : Ingress Queries : The number of received Query operations. : 0
74 Operations : Egress GetMore : The number of sent GetMore operations. : 0
75 Operations : Ingress GetMore : The number of received GetMore operations. : 0
76 Operations : Egress Insert : The number of sent Insert operations. : 0
77 Operations : Ingress Insert : The number of received Insert operations. : 0
78 Operations : Egress Delete : The number of sent Delete operations. : 0
79 Operations : Ingress Delete : The number of received Delete operations. : 0
80 Operations : Egress Update : The number of sent Update operations. : 0
81 Operations : Ingress Update : The number of received Update operations. : 0
82 Operations : Egress KillCursors : The number of sent KillCursors operations. : 0
83 Operations : Ingress KillCursors : The number of received KillCursors operations. : 0
84 Operations : Egress Msg : The number of sent Msg operations. : 0
85 Operations : Ingress Msg : The number of received Msg operations. : 0
86 Operations : Egress Reply : The number of sent Reply operations. : 0
87 Operations : Ingress Reply : The number of received Reply operations. : 13246
88 Cursors : Active : The number of active cursors. : 1
89 Cursors : Disposed : The number of disposed cursors. : 13246
90 Clients : Active : The number of active clients. : 1
91 Clients : Disposed : The number of disposed clients. : 0
92 Streams : Active : The number of active streams. : 1
93 Streams : Disposed : The number of disposed streams. : 0
94 Streams : Egress Bytes : The number of bytes sent. : 794931
95 Streams : Ingress Bytes : The number of bytes received. : 589694
96 Streams : N Socket Timeouts : The number of socket timeouts. : 0
97 Client Pools : Active : The number of active client pools. : 1
98 Client Pools : Disposed : The number of disposed client pools. : 0
99 Protocol : Ingress Errors : The number of protocol errors on ingress. : 0
100 Auth : Failures : The number of failed authentication requests. : 0
101 Auth : Success : The number of successful authentication requests. : 0
102
104 Think you've found a bug? Want to see a new feature in the MongoDB C
105 driver? Please open a case in our issue management tool, JIRA:
106
107 • Create an account and login.
108
109 • Navigate to the CDRIVER project.
110
111 • Click Create Issue - Please provide as much information as possible
112 about the issue type and how to reproduce it.
113
114 Bug reports in JIRA for all driver projects (i.e. CDRIVER, CSHARP,
115 JAVA) and the Core Server (i.e. SERVER) project are public.
116
118 MongoDB, Inc
119
121 2017-present, MongoDB, Inc
122
123
124
125
1261.25.1 Nov 08, 2023 MONGOC_BASIC_TROUBLESHOOTING(3)