( sorry for the cross-post to mongodb-user, this forum looks like the better place )
Hello,
I'm seeing some violations of "read what you wrote" with Mongo 4.2.1 and GO driver 1.1.2
This is on my development machine (Ubuntu), there is no cluster, just a single database, and it's quite small (hundreds of documents if that).
It has plenty of memory (32 gigabytes) and a fast disk (NVME). The file system is ext4 (I know XFS is preferred for performance, but there is barely any load here).
What happens is: one GO coroutine issues an update of a small document, setting a integer (Number) to a new value.
A second or so later, another thread does a read and does not see the write. Sometimes.
Repeating the read a few seconds later will then properly read back the new value.
Both threads (GO coroutines) use the same Mongo connection.
I tried to configure a read and a write concern like below, even though it's my understanding that "majority" is the default for both. It did not help.
readConcern := readconcern.Majority()
writeConcern := &writeconcern.WriteConcern{}
writeConcern = writeConcern.WithOptions(
writeconcern.WMajority())
mongoConn, mongoErr := mongo.Connect(mongoCtx, &options.ClientOptions{
Hosts: []string{"localhost"},
ReadConcern: readConcern,
WriteConcern: writeConcern})
From reading the docs*, I'm not clear if casual consistency should be automatically enabled for Mongo 3.6 or newer, or if it's something that needs to be enabled by the application or the driver.
If the former, why would it not be enabled?
If the latter, how do I enable casual consistency with the official GO driver?
[*] https://docs.mongodb.com/manual/core/read-isolation-consistency-recency/#sessions
// Update the folder
_ = model.UpdateFolder(dbFolder,
bson.M{
"seed_update": dbFolder.SeedUpdate,
"unread_count": dbFolder.UnreadCount,
})
// DEBUG check
sr := model.CollFolder.FindOne(context.Background(), bson.M{"_id":dbFolder.Id}, &options.FindOneOptions{})
srFolder := mail.SyncDbFolder{}
sr.Decode(&srFolder)
if srFolder.SeedUpdate != dbFolder.SeedUpdate {
fmt.Printf("*****\n*****\n***** SeedUpdate does not match")
}
model.UpdateFolder:
res, err := model.CollFolder.UpdateOne(context.Background(),
bson.M{"_id": folder.Id},
bson.M{
"$set": values,
},
)fmt.Printf("Updated folder: %d\n", res.ModifiedCount)^^ this prints "Updated folder: 1" not 0and finally the folder struct is defined as (some fields omitted):type SyncDbFolder struct {
Id primitive.ObjectID `bson:"_id"`SeedValidity string `bson:"seed_validity"`
SeedCreate uint64 `bson:"seed_create"`
SeedUpdate uint64 `bson:"seed_update"`
SeedDelete uint64 `bson:"seed_delete"`
UnreadCount uint64 `bson:"unread_count"`
}
Other times, when the large failure does not occur, the "***" printout does not appear either, so the update is written properly.--
You received this message because you are subscribed to the Google Groups "mongodb-go-driver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-go-dri...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-go-driver/a92a17d0-cd85-45df-884a-fc8e32fdaee0%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-...@googlegroups.com.
Hi Kostya,It's very strange that writes aren't being picked up for 10 seconds.
Could you provide some self-contained example code that we could run to try to reproduce the issue?
Also, is the mongod process running with any specific configuration or just "mongod"?