Prober: the signature index by the poster's md5
A poster of 2.7 kB broke the index build (a btree key is at most a third of a page) and left an invalid index that IF NOT EXISTS would have taken for the real one: the migration drops it first and indexes md5(poster), and the sweep asks by it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
8e008da364
commit
411c36eec0
2 files changed
+10
-6
No files matched your search
@@ -438,8 +438,9 @@ class PendingLadder {
|
|||||||
for (const s of signatures) {
|
for (const s of signatures) {
|
||||||
let rows: any[]
|
let rows: any[]
|
||||||
do {
|
do {
|
||||||
// The poster's rows by the signature index, a tool's and group's by the ladder's: never a test on the rows,
|
// The poster's rows by the signature index (on the poster's md5: a poster can be longer than a btree
|
||||||
// which was a scan of the whole table per signature on the HDD (LOG.md (134)).
|
// key), a tool's and group's by the ladder's: never a test on the rows, which was a scan of the whole
|
||||||
|
// table per signature on the HDD (LOG.md (134)).
|
||||||
;({ rows } =
|
;({ rows } =
|
||||||
s.poster === ''
|
s.poster === ''
|
||||||
? await db.rawQuery(
|
? await db.rawQuery(
|
||||||
@@ -449,8 +450,8 @@ class PendingLadder {
|
|||||||
)
|
)
|
||||||
: await db.rawQuery(
|
: await db.rawQuery(
|
||||||
`SELECT encode(release_key, 'hex') AS release_key FROM pending_releases
|
`SELECT encode(release_key, 'hex') AS release_key FROM pending_releases
|
||||||
WHERE status = ? AND group_id = ? AND tool = ? AND poster = ? LIMIT ?`,
|
WHERE status = ? AND group_id = ? AND tool = ? AND md5(poster) = md5(?::text) AND poster = ? LIMIT ?`,
|
||||||
[PENDING.waiting, s.group_id, s.tool, s.poster, limit]
|
[PENDING.waiting, s.group_id, s.tool, s.poster, s.poster, limit]
|
||||||
))
|
))
|
||||||
discarded += await this.discardKeys(rows, samplePercent)
|
discarded += await this.discardKeys(rows, samplePercent)
|
||||||
} while (rows.length === limit && rows.some((r) => !explored(r.release_key, samplePercent)))
|
} while (rows.length === limit && rows.some((r) => !explored(r.release_key, samplePercent)))
|
||||||
|
|||||||
@@ -3,14 +3,17 @@ import { BaseSchema } from '@adonisjs/lucid/schema'
|
|||||||
/**
|
/**
|
||||||
* The discard sweep of a dropped signature (tool, group, poster) read the whole pending_releases table per
|
* The discard sweep of a dropped signature (tool, group, poster) read the whole pending_releases table per
|
||||||
* signature: the planner took a parallel seq scan over the poster test, four minutes on the HDD that starved the
|
* signature: the planner took a parallel seq scan over the poster test, four minutes on the HDD that starved the
|
||||||
* lanes' claims (LOG.md (134)). The waiting rows by signature make it an index range.
|
* lanes' claims (LOG.md (134)). The waiting rows by signature make it an index range. By the poster's md5: a
|
||||||
|
* poster of 2.7 kB broke the first build (a btree key is at most a third of a page), which left an invalid index
|
||||||
|
* behind that IF NOT EXISTS would have taken for the real one; the drop clears it.
|
||||||
*/
|
*/
|
||||||
export default class extends BaseSchema {
|
export default class extends BaseSchema {
|
||||||
static disableTransactions = true
|
static disableTransactions = true
|
||||||
|
|
||||||
async up() {
|
async up() {
|
||||||
|
this.schema.raw(`DROP INDEX CONCURRENTLY IF EXISTS pending_releases_signature_idx`)
|
||||||
this.schema.raw(
|
this.schema.raw(
|
||||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS pending_releases_signature_idx ON pending_releases (group_id, tool, poster) WHERE status = 0`
|
`CREATE INDEX CONCURRENTLY IF NOT EXISTS pending_releases_signature_idx ON pending_releases (group_id, tool, md5(poster)) WHERE status = 0`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user