antietcd 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/anticluster.js CHANGED
@@ -200,13 +200,10 @@ class AntiCluster
200
200
  _resync(followers)
201
201
  {
202
202
  this.synced = false;
203
- if (!this.resync_state)
204
- {
205
- this.resync_state = {
206
- dumps: {},
207
- loads: {},
208
- };
209
- }
203
+ this.resync_state = {
204
+ dumps: {},
205
+ loads: {},
206
+ };
210
207
  const seen = {};
211
208
  for (const f of followers)
212
209
  {
@@ -258,6 +255,7 @@ class AntiCluster
258
255
  // Some dump(s) are still pending
259
256
  return;
260
257
  }
258
+ const resync_state = this.resync_state;
261
259
  this.resync_state.dumps[this.cfg.node_id] = { ...this.antietcd.etctree.dump(), term: this.antietcd.stored_term };
262
260
  let max_term = -1, with_max = [];
263
261
  for (const follower in this.resync_state.dumps)
@@ -290,6 +288,10 @@ class AntiCluster
290
288
  if (this.antietcd.persistence)
291
289
  {
292
290
  await this.antietcd.persistence.persist();
291
+ if (this.resync_state != resync_state)
292
+ {
293
+ return;
294
+ }
293
295
  }
294
296
  this.antietcd.stored_term = this.raft.term;
295
297
  if (this.cfg.use_locks)
package/antietcd.js CHANGED
@@ -20,7 +20,7 @@ const AntiCluster = require('./anticluster.js');
20
20
  const AntiLocker = require('./antilocker.js');
21
21
  const { runCallbacks, de64, b64, RequestError } = require('./common.js');
22
22
 
23
- const VERSION = '1.2.0';
23
+ const VERSION = '1.2.2';
24
24
 
25
25
  class AntiEtcd extends EventEmitter
26
26
  {
@@ -127,7 +127,7 @@ class AntiEtcd extends EventEmitter
127
127
 
128
128
  async _persistAndReplicate(msg)
129
129
  {
130
- if (this.cfg.use_locks && msg.events.length)
130
+ if (this.cfg.use_locks && msg.events && msg.events.length)
131
131
  {
132
132
  this.locker.set_txn_locks(msg.events, msg.header.revision);
133
133
  }
@@ -172,7 +172,7 @@ class AntiEtcd extends EventEmitter
172
172
  this.etctree.compact(revision);
173
173
  }
174
174
  }
175
- if (this.cfg.use_locks && msg.events.length &&
175
+ if (this.cfg.use_locks && msg.events && msg.events.length &&
176
176
  (!this.cluster || this.cluster.raft.state == TinyRaft.LEADER))
177
177
  {
178
178
  // Leader unlocks txn itself, followers wait for feedback from the leader
@@ -496,7 +496,7 @@ class AntiEtcd extends EventEmitter
496
496
  this.api_watches[watch_id] = watch.watch_id;
497
497
  if (watch.events)
498
498
  {
499
- callback(this._encodeMsg({ ...watch, watch_id }));
499
+ callback(this._encodeMsg({ result: { ...watch, watch_id } }));
500
500
  }
501
501
  return watch_id;
502
502
  }
@@ -530,7 +530,7 @@ class AntiEtcd extends EventEmitter
530
530
  if (!data[key])
531
531
  continue;
532
532
  const actions = [];
533
- for (const item of data[actions])
533
+ for (const item of data[key])
534
534
  {
535
535
  const copy = {};
536
536
  let r;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antietcd",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Simplistic etcd replacement based on TinyRaft",
5
5
  "main": "antietcd.js",
6
6
  "scripts": {