1MONGOC_CLIENT_START_SESSION(3)     libmongoc    MONGOC_CLIENT_START_SESSION(3)
2
3
4

SYNOPSIS

6          mongoc_client_session_t *
7          mongoc_client_start_session (mongoc_client_t *client,
8                                       mongoc_session_opt_t *opts,
9                                       bson_error_t *error)
10
11       Create a session for a sequence of operations.
12
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

PARAMETERS

35client: A mongoc_client_t.
36
37opts: An optional mongoc_session_opt_t.
38
39error: A bson_error_t.
40

RETURNS

42       If   successful,   this   function   returns    a    newly    allocated
43       mongoc_client_session_t      that      should     be     freed     with
44       mongoc_client_session_destroy() when no longer in use.  On  error,  re‐
45       turns NULL and sets error.
46

ERRORS

48       This  function can fail if the driver is not built with crypto support,
49       if opts is misconfigured, or if the session is configured with  options
50       that the server does not support.
51

AUTHOR

53       MongoDB, Inc
54
56       2017-present, MongoDB, Inc
57
58
59
60
611.25.1                           Nov 08, 2023   MONGOC_CLIENT_START_SESSION(3)
Impressum