1MONGOC_SESSION_OPT_T(3) libmongoc MONGOC_SESSION_OPT_T(3)
2
3
4
5 #include <mongoc/mongoc.h>
6
7 typedef struct _mongoc_session_opt_t mongoc_session_opt_t;
8
10 Start a session with mongoc_client_start_session(), use the session for
11 a sequence of operations and multi-document transactions, then free it
12 with mongoc_client_session_destroy(). Any mongoc_cursor_t or
13 mongoc_change_stream_t using a session must be destroyed before the
14 session, and a session must be destroyed before the mongoc_client_t it
15 came from.
16
17 By default, sessions are causally consistent. To disable causal consis‐
18 tency, before starting a session create a mongoc_session_opt_t with
19 mongoc_session_opts_new() and call
20 mongoc_session_opts_set_causal_consistency(), then free the struct with
21 mongoc_session_opts_destroy().
22
23 Unacknowledged writes are prohibited with sessions.
24
25 A mongoc_client_session_t must be used by only one thread at a time.
26 Due to session pooling, mongoc_client_start_session() may return a ses‐
27 sion that has been idle for some time and is about to be closed after
28 its idle timeout. Use the session within one minute of acquiring it to
29 refresh the session and avoid a timeout.
30
31 See the example code for mongoc_session_opts_set_causal_consistency().
32
34 MongoDB, Inc
35
37 2017-present, MongoDB, Inc
38
39
40
41
421.25.1 Nov 08, 2023 MONGOC_SESSION_OPT_T(3)