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

reconnect helper for change streams #6799

vkarpov15 opened this Issue Aug 1, 2018 · 4 comments


None yet
2 participants

vkarpov15 commented Aug 1, 2018

Re: #6741, change streams currently fail when there's a replica set failover. We should have some mechanism in place to handle this case. @mbroadst what are your thoughts?

@vkarpov15 vkarpov15 added this to the 5.3 milestone Aug 1, 2018

vkarpov15 added a commit that referenced this issue Aug 1, 2018


This comment has been minimized.

mbroadst commented Aug 1, 2018

@vkarpov15 change streams were designed explicitly to support handling failover, see: Perhaps you are running into a non-resumable error case? We would need more information about the specific error scenario, and ideally a reproducible case would help us resolve this very quickly.


This comment has been minimized.


vkarpov15 commented Aug 5, 2018

@mbroadst I can repro this consistently in mongoose by running rs.stepDown() in the shell while the below script is running:

const assert = require('assert');
const mongoose = require('mongoose');
mongoose.set('debug', true);

const GITHUB_ISSUE = `gh6741`;
const connectionString = `mongodb://localhost:27017/${ GITHUB_ISSUE }`;
const { Schema } = mongoose;

run().then(() => console.log('done')).catch(error => console.error(error.stack));

async function run() {
  await mongoose.connect(connectionString, { useNewUrlParser: true, replicaSet: 'rs' });
  await mongoose.connection.dropDatabase();

  await mongoose.connection.createCollection('Foo');
  const M = mongoose.model('Foo', new Schema({ name: String }), 'Foo');
  let changeStream ='change', change => console.log(change));

Do you need a driver-only script or is this enough to get you started?


This comment has been minimized.

mbroadst commented Aug 8, 2018

@vkarpov15 that's enough for me, and yeah it looks like there's a bug here. Our resume logic is only presently tested when using the change stream as a cursor, not as a stream. I made NODE-1617 to track this, we'll get on a fix ASAP.

@vkarpov15 vkarpov15 modified the milestones: 5.3, 5.2.9, 5.2.10 Aug 11, 2018


This comment has been minimized.


vkarpov15 commented Aug 27, 2018

Should be fixed by #6920

@vkarpov15 vkarpov15 closed this Aug 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment