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

NAME

6       mongoc_client_start_session - mongoc_client_start_session()
7

SYNOPSIS

9          mongoc_client_session_t *
10          mongoc_client_start_session (mongoc_client_t *client,
11                                       mongoc_session_opt_t *opts,
12                                       bson_error_t *error)
13
14       Create a session for a sequence of operations.
15
16       Start a session with mongoc_client_start_session, use the session for a
17       sequence of operations and multi-document transactions,  then  free  it
18       with   mongoc_client_session_destroy().  Any  mongoc_cursor_t  or  mon‐
19       goc_change_stream_t using a session must be destroyed before  the  ses‐
20       sion,  and  a  session  must be destroyed before the mongoc_client_t it
21       came from.
22
23       By default, sessions are causally consistent. To disable causal consis‐
24       tency,  before  starting  a  session create a mongoc_session_opt_t with
25       mongoc_session_opts_new() and call  mongoc_session_opts_set_causal_con‐
26       sistency(), then free the struct with mongoc_session_opts_destroy.
27
28       Unacknowledged writes are prohibited with sessions.
29
30       A  mongoc_client_session_t  must  be used by only one thread at a time.
31       Due to session pooling, mongoc_client_start_session may return  a  ses‐
32       sion  that  has been idle for some time and is about to be closed after
33       its idle timeout. Use the session within one minute of acquiring it  to
34       refresh the session and avoid a timeout.
35

PARAMETERS

37       · client: A mongoc_client_t.
38
39       · opts: An optional mongoc_session_opt_t.
40
41       · error: A bson_error_t.
42

RETURNS

44       If   successful,   this   function   returns  a  newly  allocated  mon‐
45       goc_client_session_t  that  should  be  freed  with  mongoc_client_ses‐
46       sion_destroy()  when  no longer in use. On error, returns NULL and sets
47       error.
48

ERRORS

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

AUTHOR

55       MongoDB, Inc
56
58       2017-present, MongoDB, Inc
59
60
61
62
631.16.2                           Feb 25, 2020   MONGOC_CLIENT_START_SESSION(3)
Impressum