1. 程式人生 > 實用技巧 >MongoDB——4.4版本因果一致性會話

MongoDB——4.4版本因果一致性會話

mongodb官網原文:

Collections to Support Sessions

New in version 3.6.

Starting in MongoDB 3.6, theconfigdatabase contains theinternalcollections to supportcausally consistent sessionsfor standalones, replica sets, and sharded clusters and retryable writes andtransactionsfor replica sets and sharded clusters.

WARNING

Do not manually modify or drop these collections.

To access these collections for amongodormongosinstance, connectmongoshell to the instance.

config.system.sessions

Thesystem.sessionscollection stores session records that are available to all members of the deployment.

When a user creates a session on a

mongodormongosinstance, the record of the session initially exists only in-memory on the instance. Periodically, the instance will sync its cached sessions to thesystem.sessionscollection; at which time, they are visible to all members of the deployment.

To view records in thesystem.sessionscollection, use

$listSessions.

WARNING

Do not manually modify or drop thesystem.sessionscollection.

In a sharded cluster, thesystem.sessionscollection is sharded.

  • When adding a shard to the sharded cluster, if the shard to add already contains its ownsystem.sessionscollection, MongoDB drops the new shard’ssystem.sessionscollection during the add process.
  • Starting in version 4.4 (and 4.2.7), MongoDB automatically splits thesystem.sessionscollection into at least 1024 chunks and distributes the chunks uniformly across shards in the cluster.
config.transactions

Thetransactionscollection stores records used to supportretryable writesandtransactionsfor replica sets and sharded clusters.

WARNING

Do not manually modify or drop thetransactionscollection.

ConfigServer中,config庫中的system.sessions集合,是3.6版本新增的內部集合,為支援“因果一致性會話”服務。

自4.4版本起,system.sessions集合自動分片,並至少設定了1024個大塊,這些大塊均勻地分發至叢集中的各個分片。