Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3492018
D4157.id13221.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D4157.id13221.diff
View Options
diff --git a/keyserver/src/creators/day-creator.js b/keyserver/src/creators/day-creator.js
--- a/keyserver/src/creators/day-creator.js
+++ b/keyserver/src/creators/day-creator.js
@@ -5,6 +5,8 @@
import { dbQuery, SQL } from '../database/database';
import createIDs from './id-creator';
+const MYSQL_DUPLICATE_ENTRY_FOR_KEY_ERROR_CODE = 1062;
+
async function fetchOrCreateDayID(
threadID: string,
date: string,
@@ -30,7 +32,7 @@
await dbQuery(insertQuery);
return id;
} catch (e) {
- if (e.errno !== 1062) {
+ if (e.errno !== MYSQL_DUPLICATE_ENTRY_FOR_KEY_ERROR_CODE) {
throw new ServerError('unknown_error');
}
// There's a race condition that can happen if two people start editing
diff --git a/keyserver/src/database/database.js b/keyserver/src/database/database.js
--- a/keyserver/src/database/database.js
+++ b/keyserver/src/database/database.js
@@ -84,6 +84,8 @@
FakeSQLResult.prototype = Array.prototype;
const fakeResult: QueryResults = (new FakeSQLResult(): any);
+const MYSQL_DEADLOCK_ERROR_CODE = 1213;
+
type QueryOptions = {
+triesLeft?: number,
+multipleStatements?: boolean,
@@ -122,7 +124,7 @@
}
return await connection.query(statement);
} catch (e) {
- if (e.errno === 1213 && triesLeft > 0) {
+ if (e.errno === MYSQL_DEADLOCK_ERROR_CODE && triesLeft > 0) {
console.log('deadlock occurred, trying again', e);
return await dbQuery(statement, { ...options, triesLeft: triesLeft - 1 });
}
diff --git a/keyserver/src/database/migrations.js b/keyserver/src/database/migrations.js
--- a/keyserver/src/database/migrations.js
+++ b/keyserver/src/database/migrations.js
@@ -42,11 +42,13 @@
return true;
}
+const MYSQL_TABLE_DOESNT_EXIST_ERROR_CODE = 1146;
+
async function setUpDBAndReturnVersion(): Promise<number> {
try {
return await fetchDBVersion();
} catch (e) {
- if (e.errno !== 1146) {
+ if (e.errno !== MYSQL_TABLE_DOESNT_EXIST_ERROR_CODE) {
throw e;
}
await setupDB();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 9:44 PM (18 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678726
Default Alt Text
D4157.id13221.diff (1 KB)
Attached To
Mode
D4157: [keyserver] Better document MySQL errno
Attached
Detach File
Event Timeline
Log In to Comment