Skip to content

rethinkdb reconnection#21

Open
molnarzs wants to merge 8 commits intodeepstreamIO:masterfrom
garlictech:master
Open

rethinkdb reconnection#21
molnarzs wants to merge 8 commits intodeepstreamIO:masterfrom
garlictech:master

Conversation

@molnarzs
Copy link
Copy Markdown

For an uws issue, the rethinkdb instance in our cluster assigned to a deepstream instance sometimes crases. In such case, the deepstream instance cannot recover: it logs the lost connection then game over.

In this PR I have added some configurable reconnection logic (see the readme). If you don't specify the new config parameters, then deepstream should behave as before, however, when you do it, and the plugin is able to recognize the lost rethinkdb connection, then it will try to reconnect, then re-execute the failed operation.

Which means that the deepstream instance gets another, working rethinkdb instance from the cluster and completes the operation. Otherwise, it stays in the failed status as before.

@molnarzs molnarzs changed the title retinkdb reconnection rethinkdb reconnection Jul 18, 2018
Comment thread src/connector.js
this._splitChar = options.splitChar || null
this._tableMatch = this._splitChar ?
new RegExp('^(\\w+)' + this._escapeRegExp(this._splitChar)) :
null
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.
Too many errors. (21% scanned).

Comment thread src/connector.js
this._defaultTable = options.defaultTable || 'deepstream_records'
this._splitChar = options.splitChar || null
this._tableMatch = this._splitChar ?
new RegExp('^(\\w+)' + this._escapeRegExp(this._splitChar)) :
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed double and single quotes.

Comment thread src/connector.js
this._reconnectCount = this._connection.reconnectCount
this._tableManager = new TableManager(this._connection)
this._defaultTable = options.defaultTable || 'deepstream_records'
this._splitChar = options.splitChar || null
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

Comment thread src/connector.js
this._connection = new Connection(options, this._onConnection.bind(this))
this._reconnectCount = this._connection.reconnectCount
this._tableManager = new TableManager(this._connection)
this._defaultTable = options.defaultTable || 'deepstream_records'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed double and single quotes.
Missing semicolon.

Comment thread src/connector.js
this._options = options
this._connection = new Connection(options, this._onConnection.bind(this))
this._reconnectCount = this._connection.reconnectCount
this._tableManager = new TableManager(this._connection)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

Comment thread src/connector.js
*/
constructor(options) {
super()
this.isReady = false
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

Comment thread src/connector.js
* @constructor
*/
constructor(options) {
super()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

Comment thread src/connector.js
*
* database specifies which database to use. Defaults to 'deepstream'
* defaultTable specifies which table records will be stored in that don't specify a table. Defaults to deepstream_records
* splitChar specifies a character that separates the record's id from the table it should be stored in. defaults to null
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long.

Comment thread src/connector.js
* Please note the three additional, optional keys:
*
* database specifies which database to use. Defaults to 'deepstream'
* defaultTable specifies which table records will be stored in that don't specify a table. Defaults to deepstream_records
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long.

Comment thread src/connector.js
* for instance will create a user table and store it in it. This will allow for more sophisticated queries as
* well as speed up read operations since there are less entries to look through
*
* @param {Object} options rethinkdb driver options. See rethinkdb.com/api/javascript/#connect
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long.

Comment thread test/multi-tableSpec.js

it( 'deletes dsTestA', ( done ) => {
conn = cacheConnector._connection.get()
conn = cacheConnector._connection.connection
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.


it( 'deletes dsTestA', ( done ) => {
const conn = storageConnector._connection.get()
const conn = storageConnector._connection.connection
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Missing semicolon.

setTimeout(() => cacheConnector.get('someValue', (error, value) => {
expect(error).to.equal(null)
expect(value).to.deep.equal(data)
done()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.
Too many errors. (27% scanned).

expect(error.msg).to.equal("Connection is closed.")
setTimeout(() => cacheConnector.get('someValue', (error, value) => {
expect(error).to.equal(null)
expect(value).to.deep.equal(data)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

}).then(cacheConnector.get('someValue', (error) => {
expect(error.msg).to.equal("Connection is closed.")
setTimeout(() => cacheConnector.get('someValue', (error, value) => {
expect(error).to.equal(null)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

setTimeout(() => cacheConnector.set('someValue', data, (error) => {
expect(error).to.equal(null)
done()
}), 1500)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

expect(error.msg).to.equal("Connection is closed.")
setTimeout(() => cacheConnector.set('someValue', data, (error) => {
expect(error).to.equal(null)
done()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

}).then(cacheConnector.set('someValue', data, (error) => {
expect(error.msg).to.equal("Connection is closed.")
setTimeout(() => cacheConnector.set('someValue', data, (error) => {
expect(error).to.equal(null)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

noreplyWait: true
}).then(cacheConnector.set('someValue', data, (error) => {
expect(error.msg).to.equal("Connection is closed.")
setTimeout(() => cacheConnector.set('someValue', data, (error) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').

cacheConnector._connection._connection.close({
noreplyWait: true
}).then(cacheConnector.set('someValue', data, (error) => {
expect(error.msg).to.equal("Connection is closed.")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed double and single quotes.
Missing semicolon.

@yasserf yasserf force-pushed the master branch 2 times, most recently from 10d57d3 to e6ad910 Compare April 12, 2020 04:16
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

Successfully merging this pull request may close these issues.

2 participants