ponder 0.8.8 → 0.8.9
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/bin/ponder.js +52 -24
- package/dist/bin/ponder.js.map +1 -1
- package/package.json +1 -1
- package/src/database/index.ts +33 -21
- package/src/indexing-store/historical.ts +1 -0
- package/src/utils/pg.ts +34 -4
package/dist/bin/ponder.js
CHANGED
|
@@ -3922,13 +3922,28 @@ var ReadonlyClient = class extends pg.Client {
|
|
|
3922
3922
|
}
|
|
3923
3923
|
}
|
|
3924
3924
|
};
|
|
3925
|
-
function
|
|
3926
|
-
return
|
|
3925
|
+
function createErrorHandler(logger) {
|
|
3926
|
+
return (error) => {
|
|
3927
|
+
const client = error.client;
|
|
3928
|
+
const pid = client?.processID ?? "unknown";
|
|
3929
|
+
const applicationName = client?.connectionParameters?.application_name ?? "unknown";
|
|
3930
|
+
logger.error({
|
|
3931
|
+
service: "postgres",
|
|
3932
|
+
msg: `Pool error (application_name: ${applicationName}, pid: ${pid})`,
|
|
3933
|
+
error
|
|
3934
|
+
});
|
|
3935
|
+
};
|
|
3936
|
+
}
|
|
3937
|
+
function createPool(config, logger) {
|
|
3938
|
+
const pool = new pg.Pool({
|
|
3927
3939
|
// https://stackoverflow.com/questions/59155572/how-to-set-query-timeout-in-relation-to-statement-timeout
|
|
3928
3940
|
statement_timeout: 2 * 60 * 1e3,
|
|
3929
3941
|
// 2 minutes
|
|
3930
3942
|
...config
|
|
3931
3943
|
});
|
|
3944
|
+
const onError2 = createErrorHandler(logger);
|
|
3945
|
+
pool.on("error", onError2);
|
|
3946
|
+
return pool;
|
|
3932
3947
|
}
|
|
3933
3948
|
|
|
3934
3949
|
// src/utils/pglite.ts
|
|
@@ -4108,28 +4123,40 @@ var createDatabase = ({
|
|
|
4108
4123
|
);
|
|
4109
4124
|
const [readonlyMax, userMax, syncMax] = common.options.command === "serve" ? [preBuild.databaseConfig.poolConfig.max - internalMax, 0, 0] : [equalMax, equalMax, equalMax];
|
|
4110
4125
|
driver = {
|
|
4111
|
-
internal: createPool(
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4126
|
+
internal: createPool(
|
|
4127
|
+
{
|
|
4128
|
+
...preBuild.databaseConfig.poolConfig,
|
|
4129
|
+
application_name: `${preBuild.namespace}_internal`,
|
|
4130
|
+
max: internalMax,
|
|
4131
|
+
statement_timeout: 10 * 60 * 1e3
|
|
4132
|
+
// 10 minutes to accommodate slow sync store migrations.
|
|
4133
|
+
},
|
|
4134
|
+
common.logger
|
|
4135
|
+
),
|
|
4136
|
+
user: createPool(
|
|
4137
|
+
{
|
|
4138
|
+
...preBuild.databaseConfig.poolConfig,
|
|
4139
|
+
application_name: `${preBuild.namespace}_user`,
|
|
4140
|
+
max: userMax
|
|
4141
|
+
},
|
|
4142
|
+
common.logger
|
|
4143
|
+
),
|
|
4144
|
+
readonly: createPool(
|
|
4145
|
+
{
|
|
4146
|
+
...preBuild.databaseConfig.poolConfig,
|
|
4147
|
+
application_name: `${preBuild.namespace}_readonly`,
|
|
4148
|
+
max: readonlyMax
|
|
4149
|
+
},
|
|
4150
|
+
common.logger
|
|
4151
|
+
),
|
|
4152
|
+
sync: createPool(
|
|
4153
|
+
{
|
|
4154
|
+
...preBuild.databaseConfig.poolConfig,
|
|
4155
|
+
application_name: "ponder_sync",
|
|
4156
|
+
max: syncMax
|
|
4157
|
+
},
|
|
4158
|
+
common.logger
|
|
4159
|
+
)
|
|
4133
4160
|
};
|
|
4134
4161
|
qb = {
|
|
4135
4162
|
internal: new HeadlessKysely({
|
|
@@ -5402,6 +5429,7 @@ ${prettyPrint(key)}`
|
|
|
5402
5429
|
await database.createTriggers();
|
|
5403
5430
|
await indexingStore.flush();
|
|
5404
5431
|
await database.removeTriggers();
|
|
5432
|
+
isDatabaseEmpty = false;
|
|
5405
5433
|
const query2 = { sql: _sql, params, typings };
|
|
5406
5434
|
const res = await database.qb.user.wrap({ method: "sql" }, async () => {
|
|
5407
5435
|
try {
|