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