some invocations of `omdb db alert list` will perform a full-table scan and therefore don't work
bugDebuggingdevelopmentfault-management
so it turns out that a bare invocation of the `omdb db alert ls` command is broken:
```console
root@oxz_switch0:~# omdb db alert ls
note: database URL not specified. Will search DNS.
note: (override with --db-url or OMDB_DB_URL)
note: using DNS from system config (typically /etc/resolv.conf)
note: (if this is not right, use --dns-server to specify an alternate DNS server)
note: using database URL postgresql://root@[fd4d:f531:d8e1:104::4]:32221,[fd4d:f531:d8e1:104::3]:32221,[fd4d:f531:d8e1:101::3]:32221,[fd4d:f531:d8e1:102::3]:32221,[fd4d:f531:d8e1:103::3]:32221/omicron?sslmode=disable
note: database schema version matches expected (275.0.0)
Error: loading alerts
Caused by:
query `SELECT "alert"."id", "alert"."time_created", "alert"."time_modified", "alert"."time_dispatched", "alert"."alert_class", "alert"."payload", "alert"."num_dispatched", "alert"."case_id", "alert"."alert_version", "rendezvous_alert_created"."alert_id", "rendezvous_alert_created"."created_at_generation" FROM ("alert" LEFT OUTER JOIN "rendezvous_alert_created" ON ("rendezvous_alert_created"."alert_id" = "alert"."id")) ORDER BY "alert"."time_created" ASC LIMIT $1` contains a full table/index scan which is explicitly disallowed
root@oxz_switch0:~#
```
if you try to filter the alert list, it is no longer doing a full table scan and works:
```console
root@oxz_switch0:~# omdb db alert ls --dispatched false
note: database URL not specified. Will search DNS.
note: (override with --db-url or OMDB_DB_URL)
note: using DNS from system config (typically /etc/resolv.conf)
note: (if this is not right, use --dns-server to specify an alternate DNS server)
note: using database URL postgresql://root@[fd4d:f531:d8e1:104::4]:32221,[fd4d:f531:d8e1:104::3]:32221,[fd4d:f531:d8e1:101::3]:32221,[fd4d:f531:d8e1:102::3]:32221,[fd4d:f531:d8e1:103::3]:32221/omicron?sslmode=disable
note: database schema version matches expected (275.0.0)
ID CLASS TIME_CREATED TIME_DISPATCHED DISPATCHED FM_CASE_ID FM_GEN
root@oxz_switch0:~#
```
but with no filters, it doesn't. this is a shame and i should feel bad about it. hopefully feeling bad about it should cause me to fix it. eventually.
if i feel bad enough to fix it, the way i should fix it is by paginating the query, not allowing the full scan. unfortunately this may be a bit bothersome since there is also ordering by timestamp going on, if i recall correctly. blah!
0 条评论