deepline 0.3.550 → 0.3.552
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/dist/bundling-sources/sdk/src/client-core.ts +23 -0
- package/dist/bundling-sources/sdk/src/http-core.ts +6 -2
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +58 -29
- package/dist/bundling-sources/sdk/src/types.ts +22 -0
- package/dist/bundling-sources/shared_libs/integration-contracts/tool-connection.ts +42 -0
- package/dist/bundling-sources/shared_libs/monitors/package.json +2 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-upstream-identity.ts +80 -13
- package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +31 -0
- package/dist/bundling-sources/shared_libs/monitors/tamradar-countries.ts +285 -0
- package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +1 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +163 -0
- package/dist/bundling-sources/shared_libs/play-runtime/activity-observation.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +137 -0
- package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +12 -0
- package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +20 -16
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +47 -14
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +48 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-constants.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +187 -16
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +102 -29
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +854 -3
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +15 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +6 -2
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +37 -7
- package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +43 -0
- package/dist/bundling-sources/shared_libs/product-notifications/billing-sales.ts +1 -0
- package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +38 -5
- package/dist/bundling-sources/shared_libs/product-notifications/default-policy.ts +1 -1
- package/dist/bundling-sources/shared_libs/product-notifications/events.ts +16 -0
- package/dist/cli/{auth-UJCAHGZG.mjs → auth-KVSBJZOX.mjs} +5 -5
- package/dist/cli/auth-MMNVWATX.js +43 -0
- package/dist/cli/{billing-RYWMI7JJ.mjs → billing-54RHFEBI.mjs} +20 -13
- package/dist/cli/{billing-VO2O5O5O.js → billing-FQREA7UA.js} +109 -102
- package/dist/cli/chunk-2RIKOPIM.mjs +9 -0
- package/dist/cli/{chunk-XYIECA7M.js → chunk-2WFPHBR4.js} +30 -8
- package/dist/cli/{chunk-SBNNK73L.js → chunk-3FD5EQ62.js} +6 -6
- package/dist/cli/{chunk-JLFOQRWM.js → chunk-45PVGZST.js} +270 -270
- package/dist/cli/{chunk-YSYOQYZE.js → chunk-4MK42735.js} +48 -44
- package/dist/cli/{chunk-2IW5GKB4.js → chunk-4NQF6KJ3.js} +13 -13
- package/dist/cli/{chunk-72NXIFOT.mjs → chunk-4TALT2M3.mjs} +1 -1
- package/dist/cli/{chunk-ADWMIZCB.js → chunk-4UUR4TCH.js} +22 -13
- package/dist/cli/{chunk-EMPXPEIQ.mjs → chunk-57VZVF5D.mjs} +3 -3
- package/dist/cli/{chunk-5J3TRWTB.js → chunk-634ZDA3F.js} +1 -1
- package/dist/cli/{chunk-FMXLQHM2.mjs → chunk-6O5HOODW.mjs} +13 -13
- package/dist/cli/{chunk-HCFH2V27.mjs → chunk-6PRW5UBA.mjs} +3 -2
- package/dist/cli/{chunk-N2Y2IGNB.mjs → chunk-6RZOWL2V.mjs} +1 -1
- package/dist/cli/{chunk-JKLDCFY5.js → chunk-6YCA5NKJ.js} +11 -11
- package/dist/cli/{chunk-5LUF4LAR.mjs → chunk-6ZORHRKB.mjs} +1 -0
- package/dist/cli/{chunk-DGUTBLXF.js → chunk-77AAAGVB.js} +3 -2
- package/dist/cli/{chunk-OKNOQRQ3.js → chunk-7IKQKKNX.js} +3 -3
- package/dist/cli/{chunk-JYUIIDZO.js → chunk-ADRC5I3R.js} +23 -22
- package/dist/cli/{chunk-IZCPOX7X.mjs → chunk-AQWQ2BFX.mjs} +1 -1
- package/dist/cli/{chunk-7BWMCVYU.mjs → chunk-AWJPDPMA.mjs} +1 -1
- package/dist/cli/{chunk-S6XOKGBF.mjs → chunk-AZQ264ID.mjs} +1 -1
- package/dist/cli/{chunk-EU23QOJ6.js → chunk-BAIST2BR.js} +26 -26
- package/dist/cli/{chunk-6P7TGCHQ.mjs → chunk-BGBJV26E.mjs} +10 -3
- package/dist/cli/{chunk-COHCKZQK.mjs → chunk-DJ2JDK4O.mjs} +2 -1
- package/dist/cli/{chunk-E4S7OE7B.mjs → chunk-EOPEYCY7.mjs} +3 -3
- package/dist/cli/{chunk-LUULRAQB.mjs → chunk-EUPVF4SU.mjs} +10 -7
- package/dist/cli/{chunk-TB3WT76F.js → chunk-F2LH7TGF.js} +23 -20
- package/dist/cli/{chunk-UL7HWZO7.mjs → chunk-FTJLJCE5.mjs} +2 -2
- package/dist/cli/{chunk-3WG2GURT.js → chunk-G4O75EXF.js} +9 -9
- package/dist/cli/{chunk-7AOFSZJM.mjs → chunk-GGGAEVCX.mjs} +23 -1
- package/dist/cli/{chunk-R5CYKRA2.js → chunk-GKYAYLRI.js} +12 -12
- package/dist/cli/{chunk-UV4RU2TE.js → chunk-H4ALLC2X.js} +2 -0
- package/dist/cli/{chunk-LWHWMU4V.js → chunk-HO3XK3R7.js} +7 -7
- package/dist/cli/{chunk-E2QVWDDW.mjs → chunk-HYC4MKGK.mjs} +3 -3
- package/dist/cli/{chunk-KSUTNW3X.js → chunk-IDVVIXPJ.js} +42 -41
- package/dist/cli/{chunk-BJO7ZXAK.js → chunk-IHRKLXZN.js} +5 -5
- package/dist/cli/{chunk-ZQZOYGDC.mjs → chunk-IYSTRCLX.mjs} +5 -4
- package/dist/cli/{chunk-SMLWC7PM.js → chunk-JWUAX6OP.js} +10 -10
- package/dist/cli/{chunk-RKF263LR.js → chunk-KWSH5T7K.js} +25 -18
- package/dist/cli/{chunk-I62PCYU6.js → chunk-MF2GHZDO.js} +2 -2
- package/dist/cli/{chunk-XKE2PGZ2.js → chunk-PFO3ISXA.js} +26 -15
- package/dist/cli/{chunk-MXEYNRTZ.mjs → chunk-PTVD2GVQ.mjs} +6 -5
- package/dist/cli/{chunk-QD2KT7II.mjs → chunk-QAORXEY3.mjs} +2 -2
- package/dist/cli/{chunk-2AKS64KJ.mjs → chunk-QILKGXYF.mjs} +2 -2
- package/dist/cli/{chunk-DJWM5OOY.mjs → chunk-QPKH23EC.mjs} +4 -4
- package/dist/cli/{chunk-MAE3AKDR.mjs → chunk-QX7LFGJR.mjs} +18 -9
- package/dist/cli/{chunk-CIBQVA6V.mjs → chunk-QY3ZNU6Z.mjs} +2 -2
- package/dist/cli/{chunk-MJDQZYKO.js → chunk-RBEUVDZF.js} +10 -6
- package/dist/cli/{chunk-RS6ZSKX6.js → chunk-RQZQVFCJ.js} +2 -2
- package/dist/cli/{chunk-QNWNR6DG.js → chunk-S46HWQKO.js} +53 -53
- package/dist/cli/{chunk-4NQWUUOH.mjs → chunk-S5S355UY.mjs} +2 -2
- package/dist/cli/{chunk-NM3AYEDI.js → chunk-SHLFOPD6.js} +5 -5
- package/dist/cli/{chunk-K7JZV4QW.mjs → chunk-U7QRMBIY.mjs} +2 -2
- package/dist/cli/{chunk-ECWOIXAV.js → chunk-UPMRIVZB.js} +14 -12
- package/dist/cli/{chunk-R7J7CJPZ.js → chunk-V436Z54K.js} +1 -0
- package/dist/cli/{chunk-RINUMR6C.js → chunk-VQALXEXO.js} +20 -19
- package/dist/cli/{chunk-F2RXBNT5.mjs → chunk-WE5HES3H.mjs} +7 -5
- package/dist/cli/{chunk-GWNYLIF7.mjs → chunk-WEHCBH5R.mjs} +4 -2
- package/dist/cli/{chunk-SZNX3XU3.js → chunk-WLN3SUIA.js} +3 -3
- package/dist/cli/{chunk-3W44AJOE.js → chunk-XVB7V4N7.js} +18 -16
- package/dist/cli/{chunk-HEVUFICQ.mjs → chunk-YJHE3O5M.mjs} +9 -5
- package/dist/cli/{chunk-GVW5V562.mjs → chunk-YLTMXJFC.mjs} +7 -3
- package/dist/cli/{chunk-TL3WIXDH.mjs → chunk-Z5TSLLOW.mjs} +19 -8
- package/dist/cli/{chunk-KLQILE2I.mjs → chunk-ZIAXDBXX.mjs} +2 -2
- package/dist/cli/command-docs.js +4 -4
- package/dist/cli/command-docs.mjs +3 -3
- package/dist/cli/concurrent-runs-help-FQAIHKKC.js +21 -0
- package/dist/cli/{concurrent-runs-help-766HVJR3.mjs → concurrent-runs-help-Q4KPAUJX.mjs} +7 -7
- package/dist/cli/{csv-VU52KZOX.mjs → csv-2PTVDNO6.mjs} +10 -5
- package/dist/cli/{csv-4DZKGYCU.js → csv-F5VAGX4K.js} +19 -14
- package/dist/cli/{db-UBGW373S.mjs → db-IEDXAUF7.mjs} +6 -6
- package/dist/cli/{db-KPIH4HPW.js → db-Z3OIUFMM.js} +27 -27
- package/dist/cli/{describe-NGITP6RA.mjs → describe-QDANCTS3.mjs} +21 -21
- package/dist/cli/describe-VUTT5ZKU.js +50 -0
- package/dist/cli/describe-core.d.mts +4 -2
- package/dist/cli/describe-core.d.ts +4 -2
- package/dist/cli/describe-core.js +4 -4
- package/dist/cli/describe-core.mjs +3 -3
- package/dist/cli/{executions-G3X25U3V.js → executions-H6H5655J.js} +8 -8
- package/dist/cli/{executions-CO5UF3CV.mjs → executions-R3LP74QN.mjs} +6 -6
- package/dist/cli/{feedback-ZYF65WPH.js → feedback-VFOUR66B.js} +14 -14
- package/dist/cli/{feedback-M2L5DVN2.mjs → feedback-WL3MRVT5.mjs} +6 -6
- package/dist/cli/git-ETB3GH3K.js +25 -0
- package/dist/cli/{git-AYJD5CLS.mjs → git-YX2J4GCI.mjs} +5 -5
- package/dist/cli/index.js +148 -148
- package/dist/cli/index.mjs +47 -47
- package/dist/cli/{integrations-LKEGGTZO.mjs → integrations-5ZK5KLVP.mjs} +7 -7
- package/dist/cli/{integrations-GSXXJ4CF.js → integrations-E2JZYKHS.js} +15 -15
- package/dist/cli/{legacy-noops-MZDLLEKN.js → legacy-noops-3VW4IJTH.js} +9 -9
- package/dist/cli/{legacy-noops-UF4GKMD4.mjs → legacy-noops-SMN3GSXY.mjs} +6 -6
- package/dist/cli/{mcp-RTNC6LP3.js → mcp-UQV2K4EW.js} +24 -24
- package/dist/cli/{mcp-NHQ6RMBP.mjs → mcp-V6MGCYAG.mjs} +4 -4
- package/dist/cli/{monitors-NC4ZR5DH.mjs → monitors-GGKS5W6M.mjs} +7 -7
- package/dist/cli/{monitors-WMWB6EKQ.js → monitors-R3BBDCRC.js} +100 -100
- package/dist/cli/{org-33Q7CXJB.js → org-GRYVMNSW.js} +88 -88
- package/dist/cli/{org-ZXUSYREQ.mjs → org-Z37NGJV4.mjs} +6 -6
- package/dist/cli/{play-N24XV6TI.js → play-2MVO27VO.js} +332 -332
- package/dist/cli/{play-IPWFGNRE.mjs → play-MDWPR4XG.mjs} +19 -19
- package/dist/cli/{providers-AUI7MMQS.js → providers-2AACRUZH.js} +9 -9
- package/dist/cli/{providers-MSVE7UZS.mjs → providers-AKDYFZJZ.mjs} +6 -6
- package/dist/cli/{quickstart-PSC6VTRI.js → quickstart-H6IV3PV3.js} +6 -6
- package/dist/cli/{quickstart-OME5XMW5.mjs → quickstart-QDGRJFZY.mjs} +4 -4
- package/dist/cli/{run-UTIX7CJY.js → run-2634REDK.js} +47 -47
- package/dist/cli/{run-EYTT2DHO.mjs → run-RTSQNGRD.mjs} +26 -26
- package/dist/cli/{search-FVE7PM72.mjs → search-6AOJ4XPP.mjs} +7 -7
- package/dist/cli/search-VTW2YNBS.js +32 -0
- package/dist/cli/{search-output-TQMY6BDG.mjs → search-output-6ADMTOU5.mjs} +40 -10
- package/dist/cli/{search-output-O463JNLR.js → search-output-S5ODBL5E.js} +43 -13
- package/dist/cli/{secrets-TWZ2GO73.js → secrets-LHCIIHMT.js} +15 -15
- package/dist/cli/{secrets-KCJJAHQB.mjs → secrets-TFIFBFB3.mjs} +6 -6
- package/dist/cli/sessions-CJ4FJ2WB.js +22 -0
- package/dist/cli/{sessions-ZCWAA7QL.mjs → sessions-WHBVUHVW.mjs} +6 -6
- package/dist/cli/{settings-SCR654U7.js → settings-CP4FVK2W.js} +85 -85
- package/dist/cli/{settings-4JFKCKII.mjs → settings-EBONWL5C.mjs} +12 -12
- package/dist/cli/{setup-Q2YOPGOI.mjs → setup-I5AZE3IU.mjs} +15 -10
- package/dist/cli/{setup-O6GH3UWT.js → setup-LFGHTNLQ.js} +55 -50
- package/dist/cli/skills-R7EBXREW.js +36 -0
- package/dist/cli/{skills-QHPZ6H2G.mjs → skills-W76AO5XE.mjs} +7 -7
- package/dist/cli/{tools-YO22H46E.mjs → tools-7IJHGF6W.mjs} +19 -19
- package/dist/cli/tools-V7U2BDXM.js +57 -0
- package/dist/cli/update-4COPZETK.js +34 -0
- package/dist/cli/{update-WHBC5IHE.mjs → update-GFOPZTHY.mjs} +9 -9
- package/dist/cli/{views-4CZJ5BLG.js → views-BPL2TQJ4.js} +21 -21
- package/dist/cli/{views-XNLXV2BT.mjs → views-D4NX4SBG.mjs} +6 -6
- package/dist/cli/{workflow-QUWP2CG2.mjs → workflow-YXP42FUI.mjs} +7 -7
- package/dist/cli/{workflow-C4VBARIE.js → workflow-ZYNAUCKC.js} +17 -17
- package/dist/{client-Ceo295L2.d.ts → client-Bf3IpUKN.d.ts} +1 -1
- package/dist/{client-BEJqhQAj.d.mts → client-CyXGrO4D.d.mts} +1 -1
- package/dist/{client-core-BPYuWfBC.d.ts → client-core-BWd0lX0Z.d.ts} +110 -4
- package/dist/{client-core-BqetRxx-.d.mts → client-core-BxsLnXlm.d.mts} +110 -4
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +127 -126
- package/dist/plays/play-description.d.mts +1 -1
- package/dist/plays/play-description.d.ts +1 -1
- package/dist/plays/run-request.d.mts +1 -1
- package/dist/plays/run-request.d.ts +1 -1
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-J4OW5RNJ.js +0 -43
- package/dist/cli/chunk-NIPLY25A.mjs +0 -7
- package/dist/cli/concurrent-runs-help-3XZIHVRP.js +0 -21
- package/dist/cli/describe-4BI6E2CM.js +0 -50
- package/dist/cli/git-QRZP4DNA.js +0 -25
- package/dist/cli/search-CQ6JG2EN.js +0 -32
- package/dist/cli/sessions-LMPXUPUH.js +0 -22
- package/dist/cli/skills-M4CFE65Z.js +0 -36
- package/dist/cli/tools-CV7XA2V6.js +0 -57
- package/dist/cli/update-PUWBKPWJ.js +0 -34
package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts
CHANGED
|
@@ -1907,7 +1907,8 @@ async function acquireWithConcurrency(
|
|
|
1907
1907
|
requested: number,
|
|
1908
1908
|
): Promise<InternalAcquireOutcome> {
|
|
1909
1909
|
let probeBaselineSupported = true;
|
|
1910
|
-
|
|
1910
|
+
const requesterId = normalizeRequesterId(input);
|
|
1911
|
+
if (rateStateCollapsedAcquireEnabled(requesterId)) {
|
|
1911
1912
|
while (true) {
|
|
1912
1913
|
try {
|
|
1913
1914
|
return await collapsedGrantWithConcurrency(
|
|
@@ -1933,7 +1934,7 @@ async function acquireWithConcurrency(
|
|
|
1933
1934
|
while (true) {
|
|
1934
1935
|
const lockSql = `SELECT bucket_id FROM ${scopeHoldTableName(input)}
|
|
1935
1936
|
WHERE bucket_id = $1 FOR UPDATE`;
|
|
1936
|
-
const singleTripOpening = rateStateSingleTripEnabled()
|
|
1937
|
+
const singleTripOpening = rateStateSingleTripEnabled(requesterId)
|
|
1937
1938
|
? renderRateStateStatementForSingleTrip(lockSql, [input.bucketId])
|
|
1938
1939
|
: null;
|
|
1939
1940
|
if (singleTripOpening === null) {
|
|
@@ -2014,6 +2015,7 @@ async function collapsedGrantWithConcurrency(
|
|
|
2014
2015
|
const opening = `BEGIN ISOLATION LEVEL READ COMMITTED;\n${RATE_STATE_BOUNDS_SQL}\n${lock};`;
|
|
2015
2016
|
let open = false;
|
|
2016
2017
|
let committed = false;
|
|
2018
|
+
const committedLeaseIds: string[] = [];
|
|
2017
2019
|
const grantClient: PostgresSchedulerQueryClient = {
|
|
2018
2020
|
query: async <Row extends Record<string, unknown>>(
|
|
2019
2021
|
sql: string,
|
|
@@ -2022,7 +2024,7 @@ async function collapsedGrantWithConcurrency(
|
|
|
2022
2024
|
const grant = renderRateStateStatementForSingleTrip(
|
|
2023
2025
|
sql,
|
|
2024
2026
|
parameters,
|
|
2025
|
-
rateStateRenderOptions(),
|
|
2027
|
+
rateStateRenderOptions(normalizeRequesterId(input)),
|
|
2026
2028
|
);
|
|
2027
2029
|
if (grant === null) {
|
|
2028
2030
|
open = true;
|
|
@@ -2030,13 +2032,23 @@ async function collapsedGrantWithConcurrency(
|
|
|
2030
2032
|
return await client.query<Row>(sql, parameters);
|
|
2031
2033
|
}
|
|
2032
2034
|
open = true;
|
|
2033
|
-
const result =
|
|
2035
|
+
const result = oneRequestRows<Row>(
|
|
2036
|
+
await client.query<Row>(`${opening}\n${grant};\nCOMMIT;`),
|
|
2037
|
+
);
|
|
2034
2038
|
committed = true;
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2039
|
+
const rows = result.rows.filter(
|
|
2040
|
+
(row) => !Object.hasOwn(row, RATE_STATE_SCOPE_LOCK_MARKER),
|
|
2041
|
+
);
|
|
2042
|
+
for (const row of rows) {
|
|
2043
|
+
const leaseIds = (row as { lease_ids?: unknown }).lease_ids;
|
|
2044
|
+
if (!Array.isArray(leaseIds)) continue;
|
|
2045
|
+
for (const leaseId of leaseIds) {
|
|
2046
|
+
if (typeof leaseId === 'string' && leaseId.length > 0) {
|
|
2047
|
+
committedLeaseIds.push(leaseId);
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
return { rows };
|
|
2040
2052
|
},
|
|
2041
2053
|
} as PostgresSchedulerQueryClient;
|
|
2042
2054
|
try {
|
|
@@ -2052,10 +2064,32 @@ async function collapsedGrantWithConcurrency(
|
|
|
2052
2064
|
return outcome;
|
|
2053
2065
|
} catch (error) {
|
|
2054
2066
|
// Same as the multi-trip path. After a committed request this only fails
|
|
2055
|
-
// a post-statement invariant check (lease drift, grant shape)
|
|
2056
|
-
//
|
|
2057
|
-
//
|
|
2058
|
-
if (
|
|
2067
|
+
// a post-statement invariant check (lease drift, grant shape): that grant
|
|
2068
|
+
// has already committed, so give its leases back instead of letting them
|
|
2069
|
+
// hold concurrency slots until their TTL, then fail as before.
|
|
2070
|
+
if (committed) {
|
|
2071
|
+
if (committedLeaseIds.length > 0) {
|
|
2072
|
+
try {
|
|
2073
|
+
await client.query(
|
|
2074
|
+
`DELETE FROM ${concurrencyLeaseTableName(input)}
|
|
2075
|
+
WHERE bucket_id = $1 AND lease_id = ANY($2::text[])`,
|
|
2076
|
+
[input.bucketId, committedLeaseIds],
|
|
2077
|
+
);
|
|
2078
|
+
} catch (releaseError) {
|
|
2079
|
+
console.error(
|
|
2080
|
+
'[rate-state] committed_grant_lease_release_failed',
|
|
2081
|
+
{
|
|
2082
|
+
bucketId: input.bucketId,
|
|
2083
|
+
leases: committedLeaseIds.length,
|
|
2084
|
+
error:
|
|
2085
|
+
releaseError instanceof Error
|
|
2086
|
+
? releaseError.message
|
|
2087
|
+
: String(releaseError),
|
|
2088
|
+
},
|
|
2089
|
+
);
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
} else if (open) {
|
|
2059
2093
|
try {
|
|
2060
2094
|
await client.query('ROLLBACK');
|
|
2061
2095
|
} catch {
|
|
@@ -2082,9 +2116,18 @@ async function boundRateStateTransaction(
|
|
|
2082
2116
|
);
|
|
2083
2117
|
}
|
|
2084
2118
|
|
|
2085
|
-
/**
|
|
2119
|
+
/**
|
|
2120
|
+
* The same transaction-local bounds as {@link boundRateStateTransaction}, plus
|
|
2121
|
+
* a closed-socket check. A one-request transaction is already on the server
|
|
2122
|
+
* when it starts waiting for the scope lock, so a caller that aborts or drops
|
|
2123
|
+
* its connection would otherwise have its grant and COMMIT run anyway and
|
|
2124
|
+
* leave leases nobody holds. Checking the socket makes PostgreSQL abort the
|
|
2125
|
+
* transaction instead, as the multi-trip path does when it reads end-of-file.
|
|
2126
|
+
*/
|
|
2127
|
+
const RATE_STATE_CLIENT_CONNECTION_CHECK_INTERVAL_MS = 100;
|
|
2086
2128
|
const RATE_STATE_BOUNDS_SQL = `SET LOCAL lock_timeout = ${escapeLiteral(`${RATE_STATE_LOCK_TIMEOUT_MS}ms`)};
|
|
2087
|
-
SET LOCAL statement_timeout = ${escapeLiteral(`${RATE_STATE_STATEMENT_TIMEOUT_MS}ms`)}
|
|
2129
|
+
SET LOCAL statement_timeout = ${escapeLiteral(`${RATE_STATE_STATEMENT_TIMEOUT_MS}ms`)};
|
|
2130
|
+
SET LOCAL client_connection_check_interval = ${escapeLiteral(`${RATE_STATE_CLIENT_CONNECTION_CHECK_INTERVAL_MS}ms`)};`;
|
|
2088
2131
|
|
|
2089
2132
|
/**
|
|
2090
2133
|
* The one request a bounded single-statement transaction becomes. If any
|
|
@@ -2201,10 +2244,27 @@ function rateStateArrayParameterText(
|
|
|
2201
2244
|
return `{${elements.join(',')}}`;
|
|
2202
2245
|
}
|
|
2203
2246
|
|
|
2204
|
-
|
|
2247
|
+
/**
|
|
2248
|
+
* Whether this acquire's requester is an organization listed in
|
|
2249
|
+
* `rateStateOneRequestOrgIds`. A call with no requester, or a run-only
|
|
2250
|
+
* requester, is never listed.
|
|
2251
|
+
*/
|
|
2252
|
+
function rateStateOneRequestOrgListed(
|
|
2253
|
+
requesterId: string | null | undefined,
|
|
2254
|
+
): boolean {
|
|
2255
|
+
if (!requesterId?.startsWith('org:')) return false;
|
|
2256
|
+
const orgIds: readonly string[] =
|
|
2257
|
+
DURABLE_RUNS_ROLLOUT.rateStateOneRequestOrgIds;
|
|
2258
|
+
return orgIds.includes(requesterId.slice('org:'.length));
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2261
|
+
function rateStateCollapsedAcquireEnabled(
|
|
2262
|
+
requesterId: string | null = null,
|
|
2263
|
+
): boolean {
|
|
2205
2264
|
const enabled: boolean =
|
|
2206
|
-
DURABLE_RUNS_ROLLOUT.rateStateCollapsedAcquire &&
|
|
2207
|
-
|
|
2265
|
+
(DURABLE_RUNS_ROLLOUT.rateStateCollapsedAcquire &&
|
|
2266
|
+
DURABLE_RUNS_ROLLOUT.rateStateSingleTripTransactions) ||
|
|
2267
|
+
rateStateOneRequestOrgListed(requesterId);
|
|
2208
2268
|
return enabled;
|
|
2209
2269
|
}
|
|
2210
2270
|
|
|
@@ -2213,28 +2273,39 @@ function rateStateCollapsedAcquireEnabled(): boolean {
|
|
|
2213
2273
|
* rate-state statement binds the bucket id (text) as `$1`; it is compared with
|
|
2214
2274
|
* and written to text columns only, so its uses may stay uncast.
|
|
2215
2275
|
*/
|
|
2216
|
-
function rateStateRenderOptions(): {
|
|
2276
|
+
function rateStateRenderOptions(requesterId: string | null = null): {
|
|
2217
2277
|
arrays?: boolean;
|
|
2218
2278
|
textParameters?: readonly number[];
|
|
2219
2279
|
} {
|
|
2220
|
-
return rateStateCollapsedAcquireEnabled()
|
|
2280
|
+
return rateStateCollapsedAcquireEnabled(requesterId)
|
|
2221
2281
|
? { arrays: true, textParameters: [1] }
|
|
2222
2282
|
: {};
|
|
2223
2283
|
}
|
|
2224
2284
|
|
|
2225
|
-
function rateStateSingleTripEnabled(
|
|
2226
|
-
|
|
2285
|
+
function rateStateSingleTripEnabled(
|
|
2286
|
+
requesterId: string | null = null,
|
|
2287
|
+
): boolean {
|
|
2288
|
+
const enabled: boolean =
|
|
2289
|
+
DURABLE_RUNS_ROLLOUT.rateStateSingleTripTransactions ||
|
|
2290
|
+
rateStateOneRequestOrgListed(requesterId);
|
|
2227
2291
|
return enabled;
|
|
2228
2292
|
}
|
|
2229
2293
|
|
|
2230
|
-
/**
|
|
2231
|
-
|
|
2294
|
+
/**
|
|
2295
|
+
* The rows of a one-request transaction. The scheduler pool flattens a
|
|
2296
|
+
* multi-statement result; a bare node-postgres client returns one result per
|
|
2297
|
+
* statement. BEGIN, SET LOCAL and COMMIT return no rows, so flattening yields
|
|
2298
|
+
* exactly the rows of the request's real statements whichever client ran it,
|
|
2299
|
+
* without depending on how many bound statements precede them.
|
|
2300
|
+
*/
|
|
2301
|
+
function oneRequestRows<Row extends Record<string, unknown>>(
|
|
2232
2302
|
result: unknown,
|
|
2233
|
-
statementIndex: number,
|
|
2234
2303
|
): { rows: Row[] } {
|
|
2235
2304
|
if (Array.isArray(result)) {
|
|
2236
2305
|
return {
|
|
2237
|
-
rows: (
|
|
2306
|
+
rows: result.flatMap(
|
|
2307
|
+
(entry) => ((entry as { rows?: Row[] } | null)?.rows ?? []) as Row[],
|
|
2308
|
+
),
|
|
2238
2309
|
};
|
|
2239
2310
|
}
|
|
2240
2311
|
return { rows: ((result as { rows?: Row[] }).rows ?? []) as Row[] };
|
|
@@ -2256,7 +2327,7 @@ async function queryBoundedRateState<
|
|
|
2256
2327
|
// One request, still four commands in one transaction: BEGIN, the same
|
|
2257
2328
|
// transaction-local bounds, the statement (its own snapshot), COMMIT.
|
|
2258
2329
|
const result = await client.query(rateStateSingleTripRequest(singleTrip));
|
|
2259
|
-
return
|
|
2330
|
+
return oneRequestRows<Row>(result) as Awaited<
|
|
2260
2331
|
ReturnType<typeof client.query<Row>>
|
|
2261
2332
|
>;
|
|
2262
2333
|
} catch (error) {
|
|
@@ -3830,12 +3901,14 @@ async function collapsedApplyConcurrencyObservations(
|
|
|
3830
3901
|
};
|
|
3831
3902
|
let committed = false;
|
|
3832
3903
|
try {
|
|
3833
|
-
const result =
|
|
3904
|
+
const result = oneRequestRows<{
|
|
3834
3905
|
accepted_rows: number;
|
|
3835
3906
|
counted_rows: number;
|
|
3836
3907
|
rule_rows: ConcurrencyCheckpointRow[] | string | null;
|
|
3837
3908
|
}>(
|
|
3838
|
-
|
|
3909
|
+
await client.query(
|
|
3910
|
+
`BEGIN;\n${RATE_STATE_BOUNDS_SQL}\n${fold};${checkpoint ? '' : '\nCOMMIT;'}`,
|
|
3911
|
+
),
|
|
3839
3912
|
);
|
|
3840
3913
|
committed = !checkpoint;
|
|
3841
3914
|
const row = result.rows[0];
|