A SnapshotUnavailable error was encountered while reading in a transaction

hello, I use mongo-go-driver to connect mongo,an error was encountered while reading in a transaction.
error message:
(SnapshotUnavailable) Unable to read from a snapshot due to pending collection catalog changes; please retry the operation. Snapshot timestamp is Timestamp(1660749105, 13). Collection minimum is Timestamp(1660749106, 16)

mongodb 4.2.3

Hey @zheng_connor, thanks for the question!

Searching for that error message, I found a seemingly relevant ticket SERVER-41532, which suggests that the error can happen when trying to read data in a transaction with read concern “Snapshot” from a MongoDB sharded cluster.

A few questions to help me understand your use case better:

  • Is your MongoDB deployment a sharded cluster? If not, what is the topology (e.g. standalone, replica set, sharded cluster)?
  • When the error happened, did you recently make changes to any databases or collections (e.g. added, removed, renamed)?
  • Can you reproduce the error reliably or only intermittently? If you can reproduce the error reliably, what are the steps needed to reproduce the error?

Unfortunately the above ticket has no resolution, so it’s not clear if updating to a newer server version would resolve the problem. The fix suggested in the ticket is to retry the transaction, which will likely resolve the issue.

1 Like

· mongo three node replica-set, version: 4.2.3
· there are many request to add data, each request to do the following:

  1. start transaction
  2. search something in collection A
  3. insert data into collection B
  4. commit

when doing request operations concurrently, errors in the problem may occur when reading collection A

· collection A and B already exist
· when the above request is executed, there is no data change in collection A

@Matt_Dale hello,What are the solutions to the above problems?