@hoshinotatsuya/pg-replica-sync 0.2.2 → 0.3.0
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 +8 -0
- package/README.md +1 -1
- package/dist/compare-lsn.d.mts +3 -3
- package/dist/compare-lsn.d.ts +3 -3
- package/dist/compare-lsn.js +3 -3
- package/dist/constants/exclusion-reason.constant.d.mts +12 -12
- package/dist/constants/exclusion-reason.constant.d.ts +12 -12
- package/dist/constants/exclusion-reason.constant.d.ts.map +1 -1
- package/dist/constants/exclusion-reason.constant.js +12 -12
- package/dist/constants/exclusion-reason.constant.js.map +1 -1
- package/dist/constants/node-role.constant.d.mts +1 -1
- package/dist/constants/node-role.constant.d.ts +1 -1
- package/dist/constants/node-role.constant.d.ts.map +1 -1
- package/dist/constants/node-role.constant.js +1 -1
- package/dist/constants/node-role.constant.js.map +1 -1
- package/dist/constants/probe-sql.constant.d.mts +25 -25
- package/dist/constants/probe-sql.constant.d.ts +25 -25
- package/dist/constants/probe-sql.constant.js +25 -25
- package/dist/constants/replica-sync-defaults.constant.d.mts +26 -26
- package/dist/constants/replica-sync-defaults.constant.d.ts +26 -26
- package/dist/constants/replica-sync-defaults.constant.d.ts.map +1 -1
- package/dist/constants/replica-sync-defaults.constant.js +26 -26
- package/dist/constants/replica-sync-defaults.constant.js.map +1 -1
- package/dist/constants/route-reason.constant.d.mts +13 -13
- package/dist/constants/route-reason.constant.d.ts +13 -13
- package/dist/constants/route-reason.constant.d.ts.map +1 -1
- package/dist/constants/route-reason.constant.js +13 -13
- package/dist/constants/route-reason.constant.js.map +1 -1
- package/dist/constants/token-format.constant.d.mts +11 -11
- package/dist/constants/token-format.constant.d.ts +11 -11
- package/dist/constants/token-format.constant.d.ts.map +1 -1
- package/dist/constants/token-format.constant.js +11 -11
- package/dist/constants/token-format.constant.js.map +1 -1
- package/dist/constants/wal-format.constant.d.mts +6 -6
- package/dist/constants/wal-format.constant.d.ts +6 -6
- package/dist/constants/wal-format.constant.d.ts.map +1 -1
- package/dist/constants/wal-format.constant.js +6 -6
- package/dist/constants/wal-format.constant.js.map +1 -1
- package/dist/decode-canonical-base64url.d.mts +1 -1
- package/dist/decode-canonical-base64url.d.ts +1 -1
- package/dist/decode-canonical-base64url.d.ts.map +1 -1
- package/dist/decode-canonical-base64url.js +1 -1
- package/dist/decode-canonical-base64url.js.map +1 -1
- package/dist/deep-freeze.d.mts +7 -7
- package/dist/deep-freeze.d.ts +7 -7
- package/dist/deep-freeze.js +9 -9
- package/dist/deep-freeze.js.map +1 -1
- package/dist/destroy-client.d.mts +3 -3
- package/dist/destroy-client.d.ts +3 -3
- package/dist/destroy-client.js +3 -3
- package/dist/evaluate-replica.d.mts +3 -3
- package/dist/evaluate-replica.d.ts +3 -3
- package/dist/evaluate-replica.js +3 -3
- package/dist/format-lsn.d.mts +1 -1
- package/dist/format-lsn.d.ts +1 -1
- package/dist/format-lsn.d.ts.map +1 -1
- package/dist/format-lsn.js +2 -2
- package/dist/format-lsn.js.map +1 -1
- package/dist/invalid-lsn.error.d.mts +1 -1
- package/dist/invalid-lsn.error.d.ts +1 -1
- package/dist/invalid-lsn.error.d.ts.map +1 -1
- package/dist/invalid-lsn.error.js +2 -2
- package/dist/invalid-lsn.error.js.map +1 -1
- package/dist/invalid-replica-sync-options.error.d.mts +1 -1
- package/dist/invalid-replica-sync-options.error.d.ts +1 -1
- package/dist/invalid-replica-sync-options.error.d.ts.map +1 -1
- package/dist/invalid-replica-sync-options.error.js +1 -1
- package/dist/invalid-replica-sync-options.error.js.map +1 -1
- package/dist/lag-bytes.d.mts +3 -3
- package/dist/lag-bytes.d.ts +3 -3
- package/dist/lag-bytes.js +3 -3
- package/dist/lsn-or-null.d.mts +1 -1
- package/dist/lsn-or-null.d.ts +1 -1
- package/dist/lsn-or-null.d.ts.map +1 -1
- package/dist/lsn-or-null.js +1 -1
- package/dist/lsn-or-null.js.map +1 -1
- package/dist/notify.d.mts +7 -7
- package/dist/notify.d.ts +7 -7
- package/dist/notify.js +8 -8
- package/dist/notify.js.map +1 -1
- package/dist/parse-lsn.d.mts +3 -3
- package/dist/parse-lsn.d.ts +3 -3
- package/dist/parse-lsn.js +3 -3
- package/dist/probe-connection-closed.error.d.mts +1 -1
- package/dist/probe-connection-closed.error.d.ts +1 -1
- package/dist/probe-connection-closed.error.d.ts.map +1 -1
- package/dist/probe-connection-closed.error.js +2 -2
- package/dist/probe-connection-closed.error.js.map +1 -1
- package/dist/probe-connection.d.mts +20 -20
- package/dist/probe-connection.d.ts +20 -20
- package/dist/probe-connection.d.ts.map +1 -1
- package/dist/probe-connection.js +25 -25
- package/dist/probe-connection.js.map +1 -1
- package/dist/probe-timeout.error.d.mts +1 -1
- package/dist/probe-timeout.error.d.ts +1 -1
- package/dist/probe-timeout.error.d.ts.map +1 -1
- package/dist/probe-timeout.error.js +2 -2
- package/dist/probe-timeout.error.js.map +1 -1
- package/dist/read-node-state.d.mts +3 -3
- package/dist/read-node-state.d.ts +3 -3
- package/dist/read-node-state.js +4 -4
- package/dist/read-node-state.js.map +1 -1
- package/dist/replica-router.d.mts +133 -133
- package/dist/replica-router.d.ts +133 -133
- package/dist/replica-router.d.ts.map +1 -1
- package/dist/replica-router.js +162 -162
- package/dist/replica-router.js.map +1 -1
- package/dist/require-integer.d.mts +1 -1
- package/dist/require-integer.d.ts +1 -1
- package/dist/require-integer.d.ts.map +1 -1
- package/dist/require-integer.js +3 -3
- package/dist/require-integer.js.map +1 -1
- package/dist/secret-weakness.d.mts +13 -13
- package/dist/secret-weakness.d.ts +13 -13
- package/dist/secret-weakness.js +16 -16
- package/dist/secret-weakness.js.map +1 -1
- package/dist/smallest-period.d.mts +4 -4
- package/dist/smallest-period.d.ts +4 -4
- package/dist/smallest-period.js +4 -4
- package/dist/sql-state-of.d.mts +6 -6
- package/dist/sql-state-of.d.ts +6 -6
- package/dist/sql-state-of.js +6 -6
- package/dist/state-cache.d.mts +14 -14
- package/dist/state-cache.d.ts +14 -14
- package/dist/state-cache.d.ts.map +1 -1
- package/dist/state-cache.js +15 -15
- package/dist/state-cache.js.map +1 -1
- package/dist/timeline-of.d.mts +2 -2
- package/dist/timeline-of.d.ts +2 -2
- package/dist/timeline-of.js +2 -2
- package/dist/to-error.d.mts +1 -1
- package/dist/to-error.d.ts +1 -1
- package/dist/to-error.d.ts.map +1 -1
- package/dist/to-error.js +1 -1
- package/dist/to-error.js.map +1 -1
- package/dist/token-codec.d.mts +10 -10
- package/dist/token-codec.d.ts +10 -10
- package/dist/token-codec.js +31 -31
- package/dist/token-codec.js.map +1 -1
- package/dist/token-lsn.d.mts +13 -13
- package/dist/token-lsn.d.ts +13 -13
- package/dist/token-lsn.js +13 -13
- package/dist/transaction-not-committed.error.d.mts +2 -2
- package/dist/transaction-not-committed.error.d.ts +2 -2
- package/dist/transaction-not-committed.error.d.ts.map +1 -1
- package/dist/transaction-not-committed.error.js +3 -3
- package/dist/transaction-not-committed.error.js.map +1 -1
- package/dist/transaction-not-open.error.d.mts +5 -5
- package/dist/transaction-not-open.error.d.ts +5 -5
- package/dist/transaction-not-open.error.js +6 -6
- package/dist/transaction-not-open.error.js.map +1 -1
- package/dist/types/cache-entry.type.d.mts +4 -4
- package/dist/types/cache-entry.type.d.ts +4 -4
- package/dist/types/clock.type.d.mts +3 -3
- package/dist/types/clock.type.d.ts +3 -3
- package/dist/types/confirm-event.type.d.mts +3 -3
- package/dist/types/confirm-event.type.d.ts +3 -3
- package/dist/types/decoded-token.type.d.mts +2 -2
- package/dist/types/decoded-token.type.d.ts +2 -2
- package/dist/types/evaluated.type.d.mts +1 -1
- package/dist/types/evaluated.type.d.ts +1 -1
- package/dist/types/evaluated.type.d.ts.map +1 -1
- package/dist/types/exclusion.type.d.mts +1 -1
- package/dist/types/exclusion.type.d.ts +1 -1
- package/dist/types/exclusion.type.d.ts.map +1 -1
- package/dist/types/node-state.type.d.mts +13 -13
- package/dist/types/node-state.type.d.ts +13 -13
- package/dist/types/node-state.type.d.ts.map +1 -1
- package/dist/types/not-a-pool.type.d.mts +5 -5
- package/dist/types/not-a-pool.type.d.ts +5 -5
- package/dist/types/probe-event.type.d.mts +1 -1
- package/dist/types/probe-event.type.d.ts +1 -1
- package/dist/types/probe-event.type.d.ts.map +1 -1
- package/dist/types/probe-outcome.type.d.mts +1 -1
- package/dist/types/probe-outcome.type.d.ts +1 -1
- package/dist/types/probe-outcome.type.d.ts.map +1 -1
- package/dist/types/probe-sample.type.d.mts +1 -1
- package/dist/types/probe-sample.type.d.ts +1 -1
- package/dist/types/probe-sample.type.d.ts.map +1 -1
- package/dist/types/replica-node.type.d.mts +7 -7
- package/dist/types/replica-node.type.d.ts +7 -7
- package/dist/types/replica-requirement.type.d.mts +2 -2
- package/dist/types/replica-requirement.type.d.ts +2 -2
- package/dist/types/replica-router-options.type.d.mts +25 -25
- package/dist/types/replica-router-options.type.d.ts +25 -25
- package/dist/types/replica-router-options.type.d.ts.map +1 -1
- package/dist/types/route-decision.type.d.mts +5 -5
- package/dist/types/route-decision.type.d.ts +5 -5
- package/dist/types/route-decision.type.d.ts.map +1 -1
- package/dist/types/router-observer.type.d.mts +5 -5
- package/dist/types/router-observer.type.d.ts +5 -5
- package/dist/types/router-observer.type.d.ts.map +1 -1
- package/dist/types/router-stats.type.d.mts +8 -8
- package/dist/types/router-stats.type.d.ts +8 -8
- package/dist/types/router-stats.type.d.ts.map +1 -1
- package/dist/types/sql-command-executor.type.d.mts +4 -4
- package/dist/types/sql-command-executor.type.d.ts +4 -4
- package/dist/types/sql-query-executor.type.d.mts +3 -3
- package/dist/types/sql-query-executor.type.d.ts +3 -3
- package/dist/types/wal-layout.type.d.mts +1 -1
- package/dist/types/wal-layout.type.d.ts +1 -1
- package/dist/types/wal-layout.type.d.ts.map +1 -1
- package/dist/types/wal-position.type.d.mts +5 -5
- package/dist/types/wal-position.type.d.ts +5 -5
- package/dist/types/wal-position.type.d.ts.map +1 -1
- package/dist/value-text.d.mts +5 -5
- package/dist/value-text.d.ts +5 -5
- package/dist/value-text.js +6 -6
- package/dist/value-text.js.map +1 -1
- package/dist/wal-layout-of.d.mts +1 -1
- package/dist/wal-layout-of.d.ts +1 -1
- package/dist/wal-layout-of.d.ts.map +1 -1
- package/dist/wal-layout-of.js +1 -1
- package/dist/wal-layout-of.js.map +1 -1
- package/package.json +11 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probe-connection-closed.error.js","sourceRoot":"","sources":["../src/probe-connection-closed.error.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"probe-connection-closed.error.js","sourceRoot":"","sources":["../src/probe-connection-closed.error.ts"],"names":[],"mappings":";;;AAAA,mEAAmE;AACnE,MAAa,0BAA2B,SAAQ,KAAK;IAG9B;IAFH,IAAI,GAAG,4BAA4B,CAAC;IAEtD,YAAqB,IAAY;QAC/B,KAAK,CAAC,oCAAoC,IAAI,kCAAkC,CAAC,CAAC;QAD/D,SAAI,GAAJ,IAAI,CAAQ;IAEjC,CAAC;CACF;AAND,gEAMC"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { type ClientConfig } from 'pg';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* An own probe connection to a node: lazy, one. A probe has two ceilings:
|
|
4
4
|
*
|
|
5
|
-
* - `timeoutMs`
|
|
6
|
-
*
|
|
7
|
-
* - `connectTimeoutMs`
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
5
|
+
* - `timeoutMs` is the ceiling of ONE probe (connection establishment and the query together):
|
|
6
|
+
* if it does not fit, this probe is refused;
|
|
7
|
+
* - `connectTimeoutMs` is the lifetime ceiling of a connection that did not get established or
|
|
8
|
+
* on which a query did not answer (from the start of the establishment or the query). A probe refused
|
|
9
|
+
* by its own ceiling does NOT tear the connection: the establishment and the query live until this
|
|
10
|
+
* ceiling. A slow but alive replica (establishment takes several RTTs, longer than
|
|
11
|
+
* the probe ceiling) this way gets a ready connection for the next probe instead of
|
|
12
|
+
* starting the establishment anew forever; a frozen one does not answer by this ceiling either —
|
|
13
|
+
* the connection is torn, the next probe opens a new one.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
15
|
+
* A connection refusal (not a ceiling) closes exactly THE connection on which
|
|
16
|
+
* the query was: a refusal of an old query does not tear an already new healthy one. A connection loss
|
|
17
|
+
* not by our will (the server restarted, the network broke) is `onLost`: the state
|
|
18
|
+
* taken through it proves nothing anymore. After `close()` the connection
|
|
19
|
+
* is no longer opened: a query is refused right away.
|
|
20
20
|
*/
|
|
21
21
|
export declare class ProbeConnection {
|
|
22
22
|
private readonly node;
|
|
@@ -29,16 +29,16 @@ export declare class ProbeConnection {
|
|
|
29
29
|
private closed;
|
|
30
30
|
constructor(node: string, connection: string | ClientConfig, timeoutMs: number, onLost?: () => void, connectTimeoutMs?: number);
|
|
31
31
|
query(text: string): Promise<readonly unknown[]>;
|
|
32
|
-
/**
|
|
32
|
+
/** Close and never open again. An ongoing connection establishment is cut too. */
|
|
33
33
|
close(): Promise<void>;
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
35
|
+
* The query did not fit into the probe ceiling: the connection lives until the query answers,
|
|
36
|
+
* but no longer than `connectTimeoutMs` from its start (the probe ceiling has already passed).
|
|
37
37
|
*/
|
|
38
38
|
private expireIfSilent;
|
|
39
39
|
private connected;
|
|
40
|
-
/**
|
|
40
|
+
/** The connection is lost not by our will: report it if it was the current connection. */
|
|
41
41
|
private lose;
|
|
42
|
-
/**
|
|
42
|
+
/** Close exactly `target`; it stops being the current one only if it was. */
|
|
43
43
|
private discard;
|
|
44
44
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { type ClientConfig } from 'pg';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* An own probe connection to a node: lazy, one. A probe has two ceilings:
|
|
4
4
|
*
|
|
5
|
-
* - `timeoutMs`
|
|
6
|
-
*
|
|
7
|
-
* - `connectTimeoutMs`
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
5
|
+
* - `timeoutMs` is the ceiling of ONE probe (connection establishment and the query together):
|
|
6
|
+
* if it does not fit, this probe is refused;
|
|
7
|
+
* - `connectTimeoutMs` is the lifetime ceiling of a connection that did not get established or
|
|
8
|
+
* on which a query did not answer (from the start of the establishment or the query). A probe refused
|
|
9
|
+
* by its own ceiling does NOT tear the connection: the establishment and the query live until this
|
|
10
|
+
* ceiling. A slow but alive replica (establishment takes several RTTs, longer than
|
|
11
|
+
* the probe ceiling) this way gets a ready connection for the next probe instead of
|
|
12
|
+
* starting the establishment anew forever; a frozen one does not answer by this ceiling either —
|
|
13
|
+
* the connection is torn, the next probe opens a new one.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
15
|
+
* A connection refusal (not a ceiling) closes exactly THE connection on which
|
|
16
|
+
* the query was: a refusal of an old query does not tear an already new healthy one. A connection loss
|
|
17
|
+
* not by our will (the server restarted, the network broke) is `onLost`: the state
|
|
18
|
+
* taken through it proves nothing anymore. After `close()` the connection
|
|
19
|
+
* is no longer opened: a query is refused right away.
|
|
20
20
|
*/
|
|
21
21
|
export declare class ProbeConnection {
|
|
22
22
|
private readonly node;
|
|
@@ -29,17 +29,17 @@ export declare class ProbeConnection {
|
|
|
29
29
|
private closed;
|
|
30
30
|
constructor(node: string, connection: string | ClientConfig, timeoutMs: number, onLost?: () => void, connectTimeoutMs?: number);
|
|
31
31
|
query(text: string): Promise<readonly unknown[]>;
|
|
32
|
-
/**
|
|
32
|
+
/** Close and never open again. An ongoing connection establishment is cut too. */
|
|
33
33
|
close(): Promise<void>;
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
35
|
+
* The query did not fit into the probe ceiling: the connection lives until the query answers,
|
|
36
|
+
* but no longer than `connectTimeoutMs` from its start (the probe ceiling has already passed).
|
|
37
37
|
*/
|
|
38
38
|
private expireIfSilent;
|
|
39
39
|
private connected;
|
|
40
|
-
/**
|
|
40
|
+
/** The connection is lost not by our will: report it if it was the current connection. */
|
|
41
41
|
private lose;
|
|
42
|
-
/**
|
|
42
|
+
/** Close exactly `target`; it stops being the current one only if it was. */
|
|
43
43
|
private discard;
|
|
44
44
|
}
|
|
45
45
|
//# sourceMappingURL=probe-connection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probe-connection.d.ts","sourceRoot":"","sources":["../src/probe-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,IAAI,CAAC;AAO/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,eAAe;IAMxB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IATnC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,MAAM,CAAS;gBAGJ,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GAAG,YAAY,EACjC,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,MAAM,IAAsB,EACpC,gBAAgB,GAAE,MAAiD;IAGhF,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC;IA6BtD,kFAAkF;IAC5E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB5B;;;OAGG;IACH,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,SAAS;IA6BjB,
|
|
1
|
+
{"version":3,"file":"probe-connection.d.ts","sourceRoot":"","sources":["../src/probe-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,IAAI,CAAC;AAO/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,eAAe;IAMxB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IATnC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,MAAM,CAAS;gBAGJ,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GAAG,YAAY,EACjC,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,MAAM,IAAsB,EACpC,gBAAgB,GAAE,MAAiD;IAGhF,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC;IA6BtD,kFAAkF;IAC5E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB5B;;;OAGG;IACH,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,SAAS;IA6BjB,0FAA0F;IAC1F,OAAO,CAAC,IAAI;IAQZ,6EAA6E;IAC7E,OAAO,CAAC,OAAO;CAOhB"}
|
package/dist/probe-connection.js
CHANGED
|
@@ -7,23 +7,23 @@ const destroy_client_1 = require("./destroy-client");
|
|
|
7
7
|
const probe_connection_closed_error_1 = require("./probe-connection-closed.error");
|
|
8
8
|
const probe_timeout_error_1 = require("./probe-timeout.error");
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* An own probe connection to a node: lazy, one. A probe has two ceilings:
|
|
11
11
|
*
|
|
12
|
-
* - `timeoutMs`
|
|
13
|
-
*
|
|
14
|
-
* - `connectTimeoutMs`
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
12
|
+
* - `timeoutMs` is the ceiling of ONE probe (connection establishment and the query together):
|
|
13
|
+
* if it does not fit, this probe is refused;
|
|
14
|
+
* - `connectTimeoutMs` is the lifetime ceiling of a connection that did not get established or
|
|
15
|
+
* on which a query did not answer (from the start of the establishment or the query). A probe refused
|
|
16
|
+
* by its own ceiling does NOT tear the connection: the establishment and the query live until this
|
|
17
|
+
* ceiling. A slow but alive replica (establishment takes several RTTs, longer than
|
|
18
|
+
* the probe ceiling) this way gets a ready connection for the next probe instead of
|
|
19
|
+
* starting the establishment anew forever; a frozen one does not answer by this ceiling either —
|
|
20
|
+
* the connection is torn, the next probe opens a new one.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
22
|
+
* A connection refusal (not a ceiling) closes exactly THE connection on which
|
|
23
|
+
* the query was: a refusal of an old query does not tear an already new healthy one. A connection loss
|
|
24
|
+
* not by our will (the server restarted, the network broke) is `onLost`: the state
|
|
25
|
+
* taken through it proves nothing anymore. After `close()` the connection
|
|
26
|
+
* is no longer opened: a query is refused right away.
|
|
27
27
|
*/
|
|
28
28
|
class ProbeConnection {
|
|
29
29
|
node;
|
|
@@ -65,14 +65,14 @@ class ProbeConnection {
|
|
|
65
65
|
else if (pending !== null) {
|
|
66
66
|
this.expireIfSilent(client, pending);
|
|
67
67
|
}
|
|
68
|
-
//
|
|
68
|
+
// The probe ceiling during establishment: the establishment is bounded by its own timer (`connected`).
|
|
69
69
|
throw error;
|
|
70
70
|
}
|
|
71
71
|
finally {
|
|
72
72
|
clearTimeout(timer);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
/**
|
|
75
|
+
/** Close and never open again. An ongoing connection establishment is cut too. */
|
|
76
76
|
async close() {
|
|
77
77
|
this.closed = true;
|
|
78
78
|
const client = this.client;
|
|
@@ -94,12 +94,12 @@ class ProbeConnection {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
97
|
+
* The query did not fit into the probe ceiling: the connection lives until the query answers,
|
|
98
|
+
* but no longer than `connectTimeoutMs` from its start (the probe ceiling has already passed).
|
|
99
99
|
*/
|
|
100
100
|
expireIfSilent(client, pending) {
|
|
101
101
|
const timer = setTimeout(() => this.discard(client), Math.max(0, this.connectTimeoutMs - this.timeoutMs));
|
|
102
|
-
//
|
|
102
|
+
// The cleanup timer does not hold the process: close() closes the connection anyway.
|
|
103
103
|
timer.unref();
|
|
104
104
|
const settle = () => clearTimeout(timer);
|
|
105
105
|
pending.then(settle, settle);
|
|
@@ -112,15 +112,15 @@ class ProbeConnection {
|
|
|
112
112
|
? { connectionString: this.connection, application_name: replica_sync_defaults_constant_1.REPLICA_SYNC_DEFAULTS.APPLICATION_NAME }
|
|
113
113
|
: { application_name: replica_sync_defaults_constant_1.REPLICA_SYNC_DEFAULTS.APPLICATION_NAME, ...this.connection };
|
|
114
114
|
const client = new pg_1.Client(config);
|
|
115
|
-
//
|
|
115
|
+
// A termination of an idle connection by the server is an error event: without a listener it crashes the process.
|
|
116
116
|
client.on('error', () => this.lose(client));
|
|
117
117
|
client.on('end', () => this.lose(client));
|
|
118
118
|
this.client = client;
|
|
119
|
-
//
|
|
119
|
+
// An establishment that did not finish within its ceiling is cut (a frozen node).
|
|
120
120
|
const connectTimer = setTimeout(() => this.discard(client), this.connectTimeoutMs);
|
|
121
121
|
connectTimer.unref();
|
|
122
122
|
const ready = client.connect().then(() => client);
|
|
123
|
-
//
|
|
123
|
+
// A refusal of an establishment after the probe ceiling has no one to accept it: without a handler it is an unhandled rejection.
|
|
124
124
|
ready.then(() => clearTimeout(connectTimer), () => {
|
|
125
125
|
clearTimeout(connectTimer);
|
|
126
126
|
this.discard(client);
|
|
@@ -128,7 +128,7 @@ class ProbeConnection {
|
|
|
128
128
|
this.ready = ready;
|
|
129
129
|
return { client, ready };
|
|
130
130
|
}
|
|
131
|
-
/**
|
|
131
|
+
/** The connection is lost not by our will: report it if it was the current connection. */
|
|
132
132
|
lose(target) {
|
|
133
133
|
const current = this.client === target;
|
|
134
134
|
this.discard(target);
|
|
@@ -136,7 +136,7 @@ class ProbeConnection {
|
|
|
136
136
|
this.onLost();
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
/**
|
|
139
|
+
/** Close exactly `target`; it stops being the current one only if it was. */
|
|
140
140
|
discard(target) {
|
|
141
141
|
if (this.client === target) {
|
|
142
142
|
this.client = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probe-connection.js","sourceRoot":"","sources":["../src/probe-connection.ts"],"names":[],"mappings":";;;AAAA,2BAA+C;AAE/C,+FAAmF;AACnF,qDAAiD;AACjD,mFAA6E;AAC7E,+DAA0D;AAE1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAa,eAAe;IAMP;IACA;IACA;IACA;IACA;IATX,MAAM,GAAkB,IAAI,CAAC;IAC7B,KAAK,GAA2B,IAAI,CAAC;IACrC,MAAM,GAAG,KAAK,CAAC;IAEvB,YACmB,IAAY,EACZ,UAAiC,EACjC,SAAiB,EACjB,SAAqB,GAAG,EAAE,CAAC,SAAS,EACpC,mBAA2B,sDAAqB,CAAC,kBAAkB;QAJnE,SAAI,GAAJ,IAAI,CAAQ;QACZ,eAAU,GAAV,UAAU,CAAuB;QACjC,cAAS,GAAT,SAAS,CAAQ;QACjB,WAAM,GAAN,MAAM,CAA8B;QACpC,qBAAgB,GAAhB,gBAAgB,CAAmD;IACnF,CAAC;IAEJ,KAAK,CAAC,KAAK,CAAC,IAAY;QACtB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,0DAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClD,CAAC;QACD,IAAI,KAAiC,C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+
/** A node probe did not fit into the ceiling: the connection is torn, the node is considered unavailable. */
|
|
2
2
|
export declare class ProbeTimeoutError extends Error {
|
|
3
3
|
readonly node: string;
|
|
4
4
|
readonly timeoutMs: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** A node probe did not fit into the ceiling: the connection is torn, the node is considered unavailable. */
|
|
2
2
|
export declare class ProbeTimeoutError extends Error {
|
|
3
3
|
readonly node: string;
|
|
4
4
|
readonly timeoutMs: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probe-timeout.error.d.ts","sourceRoot":"","sources":["../src/probe-timeout.error.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"probe-timeout.error.d.ts","sourceRoot":"","sources":["../src/probe-timeout.error.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAC7G,qBAAa,iBAAkB,SAAQ,KAAK;IAIxC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM;IAJ5B,SAAkB,IAAI,uBAAuB;gBAGlC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM;CAI7B"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProbeTimeoutError = void 0;
|
|
4
|
-
/**
|
|
4
|
+
/** A node probe did not fit into the ceiling: the connection is torn, the node is considered unavailable. */
|
|
5
5
|
class ProbeTimeoutError extends Error {
|
|
6
6
|
node;
|
|
7
7
|
timeoutMs;
|
|
8
8
|
name = 'ProbeTimeoutError';
|
|
9
9
|
constructor(node, timeoutMs) {
|
|
10
|
-
super(
|
|
10
|
+
super(`the probe of the node ${node} did not answer within ${timeoutMs} ms`);
|
|
11
11
|
this.node = node;
|
|
12
12
|
this.timeoutMs = timeoutMs;
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probe-timeout.error.js","sourceRoot":"","sources":["../src/probe-timeout.error.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"probe-timeout.error.js","sourceRoot":"","sources":["../src/probe-timeout.error.ts"],"names":[],"mappings":";;;AAAA,6GAA6G;AAC7G,MAAa,iBAAkB,SAAQ,KAAK;IAI/B;IACA;IAJO,IAAI,GAAG,mBAAmB,CAAC;IAE7C,YACW,IAAY,EACZ,SAAiB;QAE1B,KAAK,CAAC,yBAAyB,IAAI,0BAA0B,SAAS,KAAK,CAAC,CAAC;QAHpE,SAAI,GAAJ,IAAI,CAAQ;QACZ,cAAS,GAAT,SAAS,CAAQ;IAG5B,CAAC;CACF;AATD,8CASC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NodeState } from './types/node-state.type.mjs';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* A probe row (`PROBE_SQL.STATE`) → the node state. Everything that did not parse
|
|
4
|
+
* is `null` (and a pause is "paused"): "could not determine" then excludes
|
|
5
|
+
* the replica. An answer without a boolean `in_recovery` is not a Postgres answer: a probe refusal.
|
|
6
6
|
*/
|
|
7
7
|
export declare function readNodeState(row: unknown): NodeState;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { NodeState } from './types/node-state.type';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* A probe row (`PROBE_SQL.STATE`) → the node state. Everything that did not parse
|
|
4
|
+
* is `null` (and a pause is "paused"): "could not determine" then excludes
|
|
5
|
+
* the replica. An answer without a boolean `in_recovery` is not a Postgres answer: a probe refusal.
|
|
6
6
|
*/
|
|
7
7
|
export declare function readNodeState(row: unknown): NodeState;
|
|
8
8
|
//# sourceMappingURL=read-node-state.d.ts.map
|
package/dist/read-node-state.js
CHANGED
|
@@ -7,15 +7,15 @@ const timeline_of_1 = require("./timeline-of");
|
|
|
7
7
|
const token_lsn_1 = require("./token-lsn");
|
|
8
8
|
const wal_layout_of_1 = require("./wal-layout-of");
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* A probe row (`PROBE_SQL.STATE`) → the node state. Everything that did not parse
|
|
11
|
+
* is `null` (and a pause is "paused"): "could not determine" then excludes
|
|
12
|
+
* the replica. An answer without a boolean `in_recovery` is not a Postgres answer: a probe refusal.
|
|
13
13
|
*/
|
|
14
14
|
function readNodeState(row) {
|
|
15
15
|
const value = (row ?? {});
|
|
16
16
|
const inRecovery = value.in_recovery;
|
|
17
17
|
if (typeof inRecovery !== 'boolean') {
|
|
18
|
-
throw new Error(
|
|
18
|
+
throw new Error(`the probe returned something wrong: in_recovery = ${JSON.stringify(inRecovery)}`);
|
|
19
19
|
}
|
|
20
20
|
const systemId = typeof value.system_id === 'string' && wal_format_constant_1.WAL_FORMAT.SYSTEM_ID.test(value.system_id)
|
|
21
21
|
? value.system_id
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-node-state.js","sourceRoot":"","sources":["../src/read-node-state.ts"],"names":[],"mappings":";;AAYA,sCAwBC;AApCD,yEAA6D;AAC7D,+CAA0C;AAC1C,+CAA2C;AAC3C,2CAAuC;AAEvC,mDAA8C;AAE9C;;;;GAIG;AACH,SAAgB,aAAa,CAAC,GAAY;IACxC,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,EAAE,CAA4B,CAAC;IACrD,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC;IACrC,IAAI,OAAO,UAAU,KAAK,SAAS,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"read-node-state.js","sourceRoot":"","sources":["../src/read-node-state.ts"],"names":[],"mappings":";;AAYA,sCAwBC;AApCD,yEAA6D;AAC7D,+CAA0C;AAC1C,+CAA2C;AAC3C,2CAAuC;AAEvC,mDAA8C;AA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