milestone 30: overview as a dashboard, explicit health contract, period aggregations
This commit is contained in:
@@ -71,24 +71,6 @@ pub const ddl: [:0]const u8 =
|
||||
\\CREATE INDEX idx_query_log_client ON query_log(client_ip);
|
||||
\\CREATE INDEX idx_query_log_domain ON query_log(domain_id);
|
||||
\\
|
||||
\\CREATE TABLE upstream_targets (
|
||||
\\ id INTEGER PRIMARY KEY,
|
||||
\\ url TEXT NOT NULL UNIQUE -- the historical identity: config.db ids cannot cross database files
|
||||
\\);
|
||||
\\
|
||||
\\CREATE TABLE upstream_minute (
|
||||
\\ upstream_id INTEGER NOT NULL REFERENCES upstream_targets(id),
|
||||
\\ minute_ts INTEGER NOT NULL,
|
||||
\\ successes INTEGER NOT NULL,
|
||||
\\ failures INTEGER NOT NULL,
|
||||
\\ last_failure_ts INTEGER,
|
||||
\\ last_error TEXT,
|
||||
\\ PRIMARY KEY (upstream_id, minute_ts),
|
||||
\\ CHECK (successes >= 0),
|
||||
\\ CHECK (failures >= 0)
|
||||
\\) WITHOUT ROWID;
|
||||
\\CREATE INDEX idx_upstream_minute_ts ON upstream_minute(minute_ts);
|
||||
\\
|
||||
\\CREATE TABLE querylog_meta (
|
||||
\\ id INTEGER PRIMARY KEY CHECK (id = 1), -- one row, enforced by the schema
|
||||
\\ created_at INTEGER NOT NULL,
|
||||
@@ -121,9 +103,9 @@ const set_user_version = std.fmt.comptimePrint("PRAGMA user_version = {d};", .{f
|
||||
///
|
||||
/// - Commit never fsyncs at `synchronous = NORMAL`; the checkpoint's fsync is
|
||||
/// the only guaranteed durability boundary. This moves that boundary from
|
||||
/// ~40 min to ~5 h of querylog data (query rows plus upstream-history
|
||||
/// minutes) under power loss or kernel panic. Typical loss stays far smaller
|
||||
/// because of kernel writeback, but that is not a guarantee.
|
||||
/// ~40 min to ~5 h of querylog data under power loss or kernel panic.
|
||||
/// Typical loss stays far smaller because of kernel writeback, but that is
|
||||
/// not a guarantee.
|
||||
/// - Process crash or clean stop loses nothing committed, at any threshold.
|
||||
/// Consistency is never at risk: recovery replays the longest valid WAL
|
||||
/// prefix atomically.
|
||||
@@ -325,22 +307,20 @@ test "fingerprint matches a fresh hash of the DDL" {
|
||||
try testing.expectEqual(fingerprint, @as(i32, @bitCast(std.hash.Crc32.hash(ddl))));
|
||||
}
|
||||
|
||||
test "ddl creates the query-log tables, the upstream-history tables and every index" {
|
||||
test "ddl creates the query-log tables and every index" {
|
||||
var database = try db.Db.open(":memory:", .{ .mode = .memory });
|
||||
defer database.close();
|
||||
try db.applyPragmas(&database, .{});
|
||||
try database.exec(ddl);
|
||||
|
||||
try testing.expectEqual(
|
||||
@as(i64, 5),
|
||||
@as(i64, 3),
|
||||
try database.queryInt("SELECT count(*) FROM sqlite_schema WHERE type='table'"),
|
||||
);
|
||||
const objects = [_][]const u8{
|
||||
"domains", "query_log",
|
||||
"idx_query_log_ts", "idx_query_log_client",
|
||||
"idx_query_log_domain", "upstream_targets",
|
||||
"upstream_minute", "idx_upstream_minute_ts",
|
||||
"querylog_meta",
|
||||
"idx_query_log_domain", "querylog_meta",
|
||||
};
|
||||
for (objects) |name| {
|
||||
var stmt = try database.prepare("SELECT count(*) FROM sqlite_schema WHERE name = ?1");
|
||||
|
||||
Reference in New Issue
Block a user