MONGOC_SESSION_OPTS_NEW(3)
π MONGOC_SESSION_OPTS_NEW(3) π
okay bestie, welcome to the libmongoc manual page for making a fresh session-options struct. this is the little setup object you use when you want to tweak session behavior before the session even starts. iconic behavior, honestly π
β¨ SYNOPSIS β¨
mongoc_session_opt_t *
mongoc_session_opts_new (void);
so here's the whole lifecycle, and yes it matters: start a session with mongoc_client_start_session(), use that session for a sequence of operations and multi-document transactions, then free it with mongoc_client_session_destroy(). π«Ά
tiny-but-huge order check: anymongoc_cursor_tormongoc_change_stream_tthat's using a session must be destroyed before the session, and a session must be destroyed before themongoc_client_tit came from. no skipping the cleanup queue, bestie π
by default, sessions are causally consistent. to disable causal consistency, do it before starting a session: create a mongoc_session_opt_t with mongoc_session_opts_new(), call mongoc_session_opts_set_causal_consistency(), then free the struct with mongoc_session_opts_destroy(). slay, but in the correct order β¨
unacknowledged writes are prohibited with sessions. that's the rule, no cap π
a mongoc_client_session_t must be used by only one thread at a time. and because of session pooling, mongoc_client_start_session() may return a session that has been idle for some time and is about to be closed after its idle timeout. use the session within one minute of acquiring it to refresh the session and avoid a timeout. literally set a timer if you have to β³
also: see the example code for mongoc_session_opts_set_causal_consistency(). iykyk π
π RETURNS π
a new mongoc_session_opt_t β and it must be freed with mongoc_session_opts_destroy(). don't leave it hanging, bestie π
π«Ά AUTHOR π«Ά
MongoDB, Inc
π COPYRIGHT π
2009-present, MongoDB, Inc.
kisses and clean teardown, this was libmongoc version 2.5.6, dated Oct 09, 2026, page MONGOC_SESSION_OPTS_NEW(3) πβ¨
π¦ where this page comes from
- epel 10: mongo-c-driver-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms