@imqueue/core 3.5.3 → 3.5.4
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/CHANGELOG.md +26 -0
- package/package.json +1 -1
- package/src/RedisQueue.d.ts +18 -0
- package/src/RedisQueue.js +29 -1
package/CHANGELOG.md
CHANGED
|
@@ -157,6 +157,32 @@ release.
|
|
|
157
157
|
|
|
158
158
|
### Fixed
|
|
159
159
|
|
|
160
|
+
- **After the watcher's connection was replaced, delayed messages were released
|
|
161
|
+
up to `watcherCheckDelay` late for the life of the process.** The pattern
|
|
162
|
+
subscription to expiry events and the `pmessage` handler that moves a due
|
|
163
|
+
message onto its queue belong to the connection, not to the queue. A
|
|
164
|
+
reconnect opened a new watcher connection and stopped there: `connect()`
|
|
165
|
+
handed it to `initWatcher()`, which counted the watchers on the broker, found
|
|
166
|
+
the new connection itself, and returned before `watch()` ran. Every other
|
|
167
|
+
process saw the same live watcher and took nothing over, so the fleet fell
|
|
168
|
+
back to the periodic check — 1 s delays measured at up to 5.9 s — until the
|
|
169
|
+
owning process restarted. Nothing was lost and nothing was logged, which is
|
|
170
|
+
what kept it out of sight.
|
|
171
|
+
|
|
172
|
+
Any reconnect of that one connection did it, not only a broker restart: a
|
|
173
|
+
dropped socket, a proxy closing idle connections, a `CLIENT KILL`. A broker
|
|
174
|
+
restart additionally discarded a `notify-keyspace-events` value the queue had
|
|
175
|
+
set at runtime, and nothing set it again.
|
|
176
|
+
|
|
177
|
+
The owner now re-arms the watcher on a reconnect — subscription, handler and
|
|
178
|
+
keyspace-event flags — from both the writer and the watcher reconnect,
|
|
179
|
+
because `watch()` needs both connections and after an outage they come back
|
|
180
|
+
in either order. `watch()` already refuses to arm the same connection twice,
|
|
181
|
+
so whichever arrives second arms it once. A queue that does not own the
|
|
182
|
+
watcher is unchanged. Re-applying the flags issues `CONFIG GET` again, and
|
|
183
|
+
`CONFIG SET` only when a flag is missing; where `CONFIG` is not permitted this
|
|
184
|
+
logs the same `events config error` line as at start-up.
|
|
185
|
+
|
|
160
186
|
- **A joining host whose first subscription attempt failed stayed silent for the
|
|
161
187
|
life of the process.** `RedisQueue.subscribe()` records a handler only after
|
|
162
188
|
the subscribe resolves, so a first failure left that host's handler list
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imqueue/core",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.4",
|
|
4
4
|
"description": "Fast JSON message queue over Redis for inter-service communication in Node.js & TypeScript microservices — the transport layer of the @imqueue framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"message-queue",
|
package/src/RedisQueue.d.ts
CHANGED
|
@@ -854,6 +854,24 @@ export declare class RedisQueue extends EventEmitter<EventMap> implements IMessa
|
|
|
854
854
|
* `notify-keyspace-events` out of band in that case.
|
|
855
855
|
*/
|
|
856
856
|
private ensureKeyspaceEvents;
|
|
857
|
+
/**
|
|
858
|
+
* Re-arms the watcher this queue owns on a connection that replaced the
|
|
859
|
+
* previous one.
|
|
860
|
+
*
|
|
861
|
+
* @remarks
|
|
862
|
+
* The pattern subscription and the `pmessage` handler belong to the
|
|
863
|
+
* socket, not to the queue, so a reconnect that only swaps the connection
|
|
864
|
+
* leaves the owner deaf to expiry events: delayed messages then wait for
|
|
865
|
+
* the periodic check instead of being moved on time, for as long as the
|
|
866
|
+
* process lives. A broker restart also drops a `notify-keyspace-events`
|
|
867
|
+
* set at runtime, which {@link RedisQueue.watch} re-applies.
|
|
868
|
+
*
|
|
869
|
+
* Called from both the writer and the watcher reconnect, because
|
|
870
|
+
* {@link RedisQueue.watch} needs both and after an outage they come back in
|
|
871
|
+
* either order; whichever arrives second arms it. `watch()` is idempotent
|
|
872
|
+
* per connection, so arming twice is not possible.
|
|
873
|
+
*/
|
|
874
|
+
private restoreWatch;
|
|
857
875
|
/**
|
|
858
876
|
* Setups watch a process on delayed messages
|
|
859
877
|
*/
|
package/src/RedisQueue.js
CHANGED
|
@@ -1388,9 +1388,15 @@ let RedisQueue = (() => {
|
|
|
1388
1388
|
break;
|
|
1389
1389
|
case 'writer':
|
|
1390
1390
|
await this.processDelayed(this.key);
|
|
1391
|
+
this.restoreWatch();
|
|
1391
1392
|
break;
|
|
1392
1393
|
case 'watcher':
|
|
1393
|
-
|
|
1394
|
+
if (this.watchOwner) {
|
|
1395
|
+
this.restoreWatch();
|
|
1396
|
+
}
|
|
1397
|
+
else {
|
|
1398
|
+
await this.initWatcher();
|
|
1399
|
+
}
|
|
1394
1400
|
break;
|
|
1395
1401
|
case 'subscription':
|
|
1396
1402
|
await this.restoreSubscription();
|
|
@@ -1824,6 +1830,28 @@ let RedisQueue = (() => {
|
|
|
1824
1830
|
this.verbose(`Adding "${missing}" to keyspace events "${current}"`);
|
|
1825
1831
|
await this.writer.config('SET', NOTIFY_EVENTS_PARAM, current + missing);
|
|
1826
1832
|
}
|
|
1833
|
+
/**
|
|
1834
|
+
* Re-arms the watcher this queue owns on a connection that replaced the
|
|
1835
|
+
* previous one.
|
|
1836
|
+
*
|
|
1837
|
+
* @remarks
|
|
1838
|
+
* The pattern subscription and the `pmessage` handler belong to the
|
|
1839
|
+
* socket, not to the queue, so a reconnect that only swaps the connection
|
|
1840
|
+
* leaves the owner deaf to expiry events: delayed messages then wait for
|
|
1841
|
+
* the periodic check instead of being moved on time, for as long as the
|
|
1842
|
+
* process lives. A broker restart also drops a `notify-keyspace-events`
|
|
1843
|
+
* set at runtime, which {@link RedisQueue.watch} re-applies.
|
|
1844
|
+
*
|
|
1845
|
+
* Called from both the writer and the watcher reconnect, because
|
|
1846
|
+
* {@link RedisQueue.watch} needs both and after an outage they come back in
|
|
1847
|
+
* either order; whichever arrives second arms it. `watch()` is idempotent
|
|
1848
|
+
* per connection, so arming twice is not possible.
|
|
1849
|
+
*/
|
|
1850
|
+
restoreWatch() {
|
|
1851
|
+
if (this.watchOwner) {
|
|
1852
|
+
this.watch();
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1827
1855
|
/**
|
|
1828
1856
|
* Setups watch a process on delayed messages
|
|
1829
1857
|
*/
|