Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version conflict on collection relation #704

Open
a-jaouen opened this issue Dec 13, 2023 · 0 comments
Open

Version conflict on collection relation #704

a-jaouen opened this issue Dec 13, 2023 · 0 comments

Comments

@a-jaouen
Copy link

a-jaouen commented Dec 13, 2023

Hello,

Thank you very much for your fantastic work! It was a real relief not to have to create that kind of tool by myself :).

I first describe my config (I'll try to be concise), then my issue and finally a solution to mitigate the issue.

Actual config:

monstache version 6.7.16
Go version go1.20.4
MongoDB go driver v1.12.1
Elasticsearch go driver 7.0.31
MongoDB version 6.0.6
Elasticsearch version 8.11.0

I have 2 collections: collA and collB each in its own database belonging to the same MongoDB instance.
I am joining those two collections into one ES index consolidatedIndex, the documents of collB having a field named collAId relating to collA._id
Relation is one to one between those collections.

I defined the relation in monstache.config.toml

[[relate]]
namespace = "dbB.collB"
with-namespace ="dbA.collA"
src-field = "collAId"
match-field = "_id"
match-field-type = "objectId" # `collAId` is a string
keep-src = false

And I use a transformation Javascript plugin to join both collections using findOne on collB.

It happens very often in my project the following:

  1. Insert a document into collA
  2. a few seconds later approximately at the same time:
    a. Insert related document to collB
    b. update the collA document

It happens from time to time (and once it started it will repeat very often), that I get a version conflict and that my data fail to have last document version from collA.

My question: How is version generated by default when collB trigger a change since it relates to collA?
How should I address this issue?

Thank you very much for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant