prostgles-server 2.0.161 → 2.0.162
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/package.json
CHANGED
package/tests/client/PID.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
75837
|
|
@@ -78,6 +78,7 @@ async function client_only(db, auth, log, methods) {
|
|
|
78
78
|
await db.planes.delete();
|
|
79
79
|
let inserts = new Array(100).fill(null).map((d, i) => ({ id: i, flight_number: `FN${i}`, x: Math.random(), y: i }));
|
|
80
80
|
await db.planes.insert(inserts);
|
|
81
|
+
const CLOCK_DRIFT = 2000;
|
|
81
82
|
if ((await db.planes.count()) !== 100)
|
|
82
83
|
throw "Not 100 planes";
|
|
83
84
|
/**
|
|
@@ -94,16 +95,19 @@ async function client_only(db, auth, log, methods) {
|
|
|
94
95
|
const p10 = planes.filter(p => p.x == 10);
|
|
95
96
|
log(Date.now() + ": sub stats: x10 -> " + p10.length + " x20 ->" + planes.filter(p => p.x == 20).length);
|
|
96
97
|
if (p10.length === 100) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
98
|
+
/** 2 second delay to account for client-server clock drift */
|
|
99
|
+
setTimeout(async () => {
|
|
100
|
+
// db.planes.findOne({}, { select: { last_updated: "$max"}}).then(log);
|
|
101
|
+
sP.unsubscribe();
|
|
102
|
+
log(Date.now() + ": sub: db.planes.update({}, { x: 20, last_updated });");
|
|
103
|
+
const dLastUpdated = Math.max(...p10.map(v => +v.last_updated));
|
|
104
|
+
const last_updated = Date.now();
|
|
105
|
+
if (dLastUpdated >= last_updated)
|
|
106
|
+
throw "dLastUpdated >= last_updated should not happen";
|
|
107
|
+
await db.planes.update({}, { x: 20, last_updated });
|
|
108
|
+
log(Date.now() + ": sub: Updated to x20", await db.planes.count({ x: 20 }));
|
|
109
|
+
// db.planes.findOne({}, { select: { last_updated: "$max"}}).then(log)
|
|
110
|
+
}, CLOCK_DRIFT);
|
|
107
111
|
}
|
|
108
112
|
});
|
|
109
113
|
let updt = 0;
|
|
@@ -127,7 +131,7 @@ async function client_only(db, auth, log, methods) {
|
|
|
127
131
|
if (x20 === 100) {
|
|
128
132
|
// log(22)
|
|
129
133
|
// console.timeEnd("test")
|
|
130
|
-
log(Date.now() + ": sync end: Finished replication test. Inserting 100 rows then updating two times took: " + (Date.now() - start) + "ms");
|
|
134
|
+
log(Date.now() + ": sync end: Finished replication test. Inserting 100 rows then updating two times took: " + (Date.now() - start - CLOCK_DRIFT) + "ms");
|
|
131
135
|
resolve(true);
|
|
132
136
|
}
|
|
133
137
|
});
|
|
@@ -93,6 +93,8 @@ export default async function client_only(db: DBHandlerClient, auth: Auth, log:
|
|
|
93
93
|
let inserts = new Array(100).fill(null).map((d, i) => ({ id: i, flight_number: `FN${i}`, x: Math.random(), y: i }));
|
|
94
94
|
await db.planes.insert(inserts);
|
|
95
95
|
|
|
96
|
+
const CLOCK_DRIFT = 2000;
|
|
97
|
+
|
|
96
98
|
if((await db.planes.count()) !== 100) throw "Not 100 planes";
|
|
97
99
|
|
|
98
100
|
/**
|
|
@@ -112,17 +114,22 @@ export default async function client_only(db: DBHandlerClient, auth: Auth, log:
|
|
|
112
114
|
log(Date.now() + ": sub stats: x10 -> " + p10.length + " x20 ->" + planes.filter(p => p.x == 20).length);
|
|
113
115
|
|
|
114
116
|
if(p10.length === 100){
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
117
|
+
|
|
118
|
+
/** 2 second delay to account for client-server clock drift */
|
|
119
|
+
setTimeout(async () => {
|
|
120
|
+
|
|
121
|
+
// db.planes.findOne({}, { select: { last_updated: "$max"}}).then(log);
|
|
122
|
+
|
|
123
|
+
sP.unsubscribe();
|
|
124
|
+
log(Date.now() + ": sub: db.planes.update({}, { x: 20, last_updated });");
|
|
125
|
+
const dLastUpdated = Math.max(...p10.map(v => +v.last_updated))
|
|
126
|
+
const last_updated = Date.now();
|
|
127
|
+
if(dLastUpdated >= last_updated) throw "dLastUpdated >= last_updated should not happen"
|
|
128
|
+
await db.planes.update({}, { x: 20, last_updated });
|
|
129
|
+
log(Date.now() + ": sub: Updated to x20" , await db.planes.count({ x: 20 }))
|
|
130
|
+
|
|
131
|
+
// db.planes.findOne({}, { select: { last_updated: "$max"}}).then(log)
|
|
132
|
+
}, CLOCK_DRIFT)
|
|
126
133
|
}
|
|
127
134
|
});
|
|
128
135
|
|
|
@@ -148,7 +155,7 @@ export default async function client_only(db: DBHandlerClient, auth: Auth, log:
|
|
|
148
155
|
if(x20 === 100){
|
|
149
156
|
// log(22)
|
|
150
157
|
// console.timeEnd("test")
|
|
151
|
-
log(Date.now() + ": sync end: Finished replication test. Inserting 100 rows then updating two times took: " + (Date.now() - start) + "ms")
|
|
158
|
+
log(Date.now() + ": sync end: Finished replication test. Inserting 100 rows then updating two times took: " + (Date.now() - start - CLOCK_DRIFT) + "ms")
|
|
152
159
|
resolve(true)
|
|
153
160
|
}
|
|
154
161
|
});
|