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
13 a sequence of operations and multi-document transactions, then free it
14 with mongoc_client_session_destroy(). Any mongoc_cursor_t or
15 mongoc_change_stream_t using a session must be destroyed before the
16 session, 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
22 mongoc_session_opts_set_causal_consistency(), then free the struct with
23 mongoc_session_opts_destroy().
24
25 Unacknowledged writes are prohibited with sessions.
26
27 A mongoc_client_session_t must be used by only one thread at a time.
28 Due to session pooling, mongoc_client_start_session() may return a ses‐
29 sion that has been idle for some time and is about to be closed after
30 its idle timeout. Use the session within one minute of acquiring it to
31 refresh the session and avoid a timeout.
32
33 See the example code for mongoc_session_opts_set_causal_consistency().
34
36 A new mongoc_session_opt_t that must be freed with
37 mongoc_session_opts_destroy().
38
40 MongoDB, Inc
41
43 2017-present, MongoDB, Inc
44
45
46
47
481.23.1 Oct 20, 2022 MONGOC_SESSION_OPTS_NEW(3)