-
Notifications
You must be signed in to change notification settings - Fork 178
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
Bug: Resuming on relate uses wrong index name #196
Comments
Hi @jodevsa Thanks. Do you have any other configuration specified (excluding the connection and auth info)?. If you have |
I'm not even sure how it's possible the index could start with (an id?) appended with an underscore like this |
Is it possible that there is some erroneous data in the oplog (possibly from a previous bad insert) such that the |
If so, maybe this would help:
|
here is the rest of the config, direct-read-namespaces are commented,
direct-read-namespaces is commented and yeah i searched the monstache code trying to figure out what happened nothing adds an ID, i've also checked the related collections i don't have any document with that ID |
tried to reproduce several times, looks like the prefix ID is always "5c976492cf09a2266a829a76" |
It might have been a mistake that got deleted later but was recorded in the oplog. Anyway it seems to saying that (maybe at one point) you have/had a db named |
It should be ignored if you explicitly set the allowed namespaces
|
i'm intrested in more than one collection so i change the regex to |
Now resumes stopped working, live change streams updates still working fine |
Hmm. Maybe try
|
Same tried both |
Actually tested |
Tried to listen to the change stream, this is the output |
Monstache gets the timestamp to resume from in |
? |
Updates and resumes are working fine, the problem is the index is occuring on the real collection not the view and the indexName on elastic is not right |
If you are on MongoDB 4.0+ you can enable using the new change streams API with
Otherwise Monstache defaults to the old method of tailing the oplog (before the api became available). |
If you want to listen to the whole database use
|
Sorry forgot to add that line too, i'm using change-stream-namespaces |
Other thing you can do to work around is add another mapping. I'm not entirely sure why it's need though.
|
actual change stream event
monstache log |
@rwynn same issue |
I don't know where that prefix could be getting added. Here is the code that sets the namespace attribute. https://github.com/rwynn/gtm/blob/development/gtm.go#L168 It should just be joining the 2 fields with a dot. This later flows into Monstache but I don't see how it could be getting the prefix there. |
I just did a quick test on my end in a VM and couldn't get the prefix added with a resume set. You mentioned this was a shared instance of MongoDB? Could this be related to that? Maybe some sort of tenant namespacing? |
really weird, I'm using a mongo shared cluster on atlas |
But listening to the stream using a nodeJS script outputs the correct stream ns: { db: 'db', coll: 'student' }, |
Yeah, I'm not sure why it's working differently. But seems to be consistent with that same ID. |
Are you able to do a find on the underlying |
@rwynn nope |
You could probably work around by adding another relate with the prefix added to the namespace. |
Looks like you can only access the oplog on an M10 or greater in Atlas. |
@jodevsa I created a ticket for this in the MongoDB Atlas support. Will report back if I learn anything. |
@jodevsa By the way, since you said this only triggers with resume on: in that case the change stream is started with the https://docs.mongodb.com/manual/reference/method/db.collection.watch/ |
@rwynn you are right ! when using the resumAfter option, the namespace changes to "5c976492cf09a2266a829a76_db'"
|
good news, this only occur on shared cluster! |
Would you mind writing up some instructions for repeated this with the mongo client? I have a ticket open now and they suspect it might be related to the |
@rwynn yeah sure |
sample output:
|
The following code reproduces the issue, it prints the ns of 2 events from 2 different change streams |
Thanks that’s perfect. I’ll attach it to the ticket. Great find on this issue! |
Awesome |
@jodevsa got an update today that a fix for this on the Atlas side is planned to land in the next couple weeks. They've been able to replicate with your script and it's on their radar. |
@rwynn |
@rwynn Atlas have fixed the issue in the latest maintenance update |
That’s good news. Thanks for the update. |
@jodevsa @rwynn has this issue resurfaced? I am testing a setup now with replay and resume on and in ES an index is created with an id. When doing an update in mongo after all previous documents were synced, then another index with the correct name is created for the newly updated docs. What could be absurd is that I don't think I had this issue a few weeks ago when I ran a first test. I don't remember having seen an index with an prefixed id at that time. I am running monstach in docker (image version 6.3.1) and I am testing with Mongo Atlas M0 (noticed they are at version 4.0.13 now) and ES Cloud 7.0.1. All options are configured via commandline params given to the container. |
@sbeaupre you may want to try to replicate again using just the node code that @jodevsa previously posted to this issue. If you find that the issue has come back it would be helpful if you created a ticket with MongoDB. For reference, the previous ticket that I created with them on March 29th was given case #00558022. You might state that is was fixed in 4.0.10 and seems to have come back now in 4.0.13. |
I can confirm that it is an issue (again). I'll contact mongo support with your reference number |
Hi @rwynn ,
Thanks for your work, really amazing.
When Resuming using the following config, events in the change stream gets indexed to a wrong index name
{"index":{"_index":"5c976492cf09a2266a829a76_db.students","_id":"5c9e4143f37e264e131c84be","
version:4.16.0
This only happens on resumng, works fine when listening to new events in the change stream
Thanks!
The text was updated successfully, but these errors were encountered: