Skip to content

Commit 8e4bf48

Browse files
committed
v2.25.2: Disable coalescing in $cas updates on concurrent updates, even if the $cas values are the same
1 parent cfb149f commit 8e4bf48

File tree

9 files changed

+170
-99
lines changed

9 files changed

+170
-99
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ dist
22

33
# Common in both .gitignore and .npmignore
44
node_modules
5+
coverage
56
yarn.lock
67
pnpm-lock.yaml
78
.DS_Store

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ dist/*.tsbuildinfo
55

66
# Common in both .gitignore and .npmignore
77
node_modules
8+
coverage
89
package-lock.json
910
yarn.lock
1011
pnpm-lock.yaml

docs/classes/PgQueryUpdate.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Class: PgQueryUpdate\<TTable\>
88

9-
Defined in: [src/pg/PgQueryUpdate.ts:11](https://github.com/clickup/ent-framework/blob/master/src/pg/PgQueryUpdate.ts#L11)
9+
Defined in: [src/pg/PgQueryUpdate.ts:10](https://github.com/clickup/ent-framework/blob/master/src/pg/PgQueryUpdate.ts#L10)
1010

1111
A very lean interface for a Query. In practice each query is so different
1212
that this interface is the only common part of them all.
@@ -27,7 +27,7 @@ that this interface is the only common part of them all.
2727

2828
> **new PgQueryUpdate**\<`TTable`\>(`schema`, `id`, `input`): [`PgQueryUpdate`](PgQueryUpdate.md)\<`TTable`\>
2929
30-
Defined in: [src/pg/PgQueryUpdate.ts:16](https://github.com/clickup/ent-framework/blob/master/src/pg/PgQueryUpdate.ts#L16)
30+
Defined in: [src/pg/PgQueryUpdate.ts:15](https://github.com/clickup/ent-framework/blob/master/src/pg/PgQueryUpdate.ts#L15)
3131

3232
#### Parameters
3333

@@ -55,7 +55,7 @@ Defined in: [src/pg/PgQueryUpdate.ts:16](https://github.com/clickup/ent-framewor
5555

5656
> **run**(`client`, `annotation`): `Promise`\<`boolean`\>
5757
58-
Defined in: [src/pg/PgQueryUpdate.ts:26](https://github.com/clickup/ent-framework/blob/master/src/pg/PgQueryUpdate.ts#L26)
58+
Defined in: [src/pg/PgQueryUpdate.ts:25](https://github.com/clickup/ent-framework/blob/master/src/pg/PgQueryUpdate.ts#L25)
5959

6060
#### Parameters
6161

eslint.base.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,11 @@ export default function createConfig({
594594
message:
595595
"Please use react-router-dom instead, since react-router's useLocation() doesn't work properly with StaticRouter on server side.",
596596
},
597+
{
598+
group: ["braintrust/loadPrompt"],
599+
message:
600+
"You should use DynamicPromptsRepository to load prompts from braintrust.",
601+
}
597602
],
598603
},
599604
],

package-lock.json

Lines changed: 89 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@clickup/ent-framework",
33
"description": "A PostgreSQL graph-database-alike library with microsharding and row-level security",
4-
"version": "2.25.1",
4+
"version": "2.25.2",
55
"license": "MIT",
66
"keywords": [
77
"postgresql",

src/pg/PgQueryUpdate.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import uniq from "lodash/uniq";
22
import type { Query } from "../abstract/Query";
33
import type { QueryAnnotation } from "../abstract/QueryAnnotation";
44
import type { Schema } from "../abstract/Schema";
5-
import { stringHash } from "../internal/misc";
65
import type { Field, Table, UpdateInput } from "../types";
76
import { ID } from "../types";
87
import type { PgClient } from "./PgClient";
@@ -143,10 +142,12 @@ class PgRunnerUpdate<TTable extends Table> extends PgRunner<
143142
}
144143

145144
override key(input: UpdateInput<TTable> & { [ID]: string }): string {
146-
return (
147-
input[ID] +
148-
(input.$cas ? ":" + stringHash(JSON.stringify(input.$cas)) : "")
149-
);
145+
// If we have $cas, then we disable coalescing entirely. E.g. when a client
146+
// sends 2 updates for the same ID even for the same $cas values from the
147+
// same Node process, we want only the 1st update to succeed and the 2nd one
148+
// to skip (same behavior as if those 2 updates were run in different Node
149+
// processes: coalescing must not change the concurrency guarantees).
150+
return input.$cas ? super.key(input) : input[ID];
150151
}
151152

152153
async runSingle(

0 commit comments

Comments
 (0)