1MONGOC_SESSION_OPTS_NEW(3) libmongoc MONGOC_SESSION_OPTS_NEW(3)
2
3
4
6 mongoc_session_opts_new - mongoc_session_opts_new()
7
9 mongoc_session_opt_t *
10 mongoc_session_opts_new (void);
11
12 Start a session with mongoc_client_start_session, use the session for a
13 sequence of operations and multi-document transactions, then free it
14 with mongoc_client_session_destroy(). Any mongoc_cursor_t or mon‐
15 goc_change_stream_t using a session must be destroyed before the ses‐
16 sion, and a session must be destroyed before the mongoc_client_t it
17 came from.
18
19 By default, sessions are causally consistent. To disable causal consis‐
20 tency, before starting a session create a mongoc_session_opt_t with
21 mongoc_session_opts_new() and call mongoc_session_opts_set_causal_con‐
22 sistency(), then free the struct with mongoc_session_opts_destroy.
23
24 Unacknowledged writes are prohibited with sessions.
25
26 A mongoc_client_session_t must be used by only one thread at a time.
27 Due to session pooling, mongoc_client_start_session may return a ses‐
28 sion that has been idle for some time and is about to be closed after
29 its idle timeout. Use the session within one minute of acquiring it to
30 refresh the session and avoid a timeout.
31
32 See the example code for mongoc_session_opts_set_causal_consistency.
33
35 A new mongoc_session_opt_t that must be freed with mongoc_ses‐
36 sion_opts_destroy().
37
39 MongoDB, Inc
40
42 2017-present, MongoDB, Inc
43
44
45
46
471.20.0 Nov 18, 2021 MONGOC_SESSION_OPTS_NEW(3)