Snapshot Pages to the Wayback Machine After Deploy
Triggers a Wayback Machine save of a URL, verifies the snapshot landed, and alerts on failure.
Read used space, MAXSIZE and growth per data file, alert Slack, then raise MAXSIZE and pre-grow the file behind an approval and re-read to confirm.
A data file that is almost full and cannot grow is one insert away from error 1105. When a file reaches its MAXSIZE or sits on a volume with no free space, the next page allocation fails. Every INSERT and UPDATE that needs a new page fails with it and the database is effectively down for writes. A tiny or percent FILEGROWTH makes it worse, because the file crawls toward its ceiling in small steps and the last one lands in the middle of a busy day.
The signals are in the catalog long before the wall. sys.database_files
carries the file size, the MAXSIZE and the growth increment. FILEPROPERTY
gives the real used space inside the file. sys.dm_os_volume_stats gives the
free space on the volume underneath it. Put together they say how much a file
can still absorb before it cannot grow.
This blueprint reads all of that for every ROWS data file in the database you
point it at, works out the real headroom and flags the files that are close
to the wall. It splits them in two. A capped file near its MAXSIZE can be
fixed, so it is grown. An unlimited file on a full volume cannot be fixed by
growing, because growing needs disk the volume does not have, so it is
reported instead. It alerts Slack. When you allow it and a human approves the
run, it raises MAXSIZE, pre-grows the file so there is free space now and
leaves a sane fixed FILEGROWTH, all in one ALTER DATABASE ... MODIFY FILE.
Then it reads sys.database_files again and fails the run if the real
headroom is still below the floor, because a grow that the disk could not
satisfy must never be reported as a fix.
This blueprint was created by zkasuran.
ONLINE FULL or SIMPLE user databases are acted on. The audit refuses master, model, msdb and tempdb by name and by DB_ID() > 4. It returns nothing when it is pointed at a system database or one that is not FULL or SIMPLE recovery.ROWS data files are touched. Log files are out of scope for this guard.dry_run is true and auto_remediate is false, so a normal run only measures headroom and alerts.auto_remediate is true, dry_run is false and a human resumes the Pause with approved: true. A pause resumed without an answer reads as a refusal.concurrencyLimit: 1, so two grows never write to the same volume at once.io.kestra.plugin.jdbc.sqlserver.Query. ALTER DATABASE cannot run inside an explicit transaction, so this is never a Queries task with transaction: true.audit (io.kestra.plugin.jdbc.sqlserver.Query, read-only) reads every ROWS data file in the connected database, its size, MAXSIZE, growth increment and used space from sys.database_files and FILEPROPERTY plus the volume free space from sys.dm_os_volume_stats. It works out the real headroom (free space in the file plus the smaller of the room left to MAXSIZE and the free space on the volume) and keeps the files over used_pct_threshold of their MAXSIZE, under min_headroom_mb of headroom or unlimited on a volume under volume_free_floor_mb free. Each capped row carries its own ALTER DATABASE ... MODIFY FILE statement, built in T-SQL with QUOTENAME.targets (io.kestra.plugin.core.output.OutputValues) splits the findings into the grow plan (capped files) and the report only count (unlimited files on a full volume) then builds the quoted file name list for the re-read. summary (io.kestra.plugin.core.log.Log) logs every file with its used space, size, MAXSIZE, headroom and growth.route (io.kestra.plugin.core.flow.If):alert posts the at risk files to Slack.remediate_gate runs only when auto_remediate is true and dry_run is false.approval_gate (io.kestra.plugin.core.flow.Pause) holds the run until a human resumes it.grow_branch runs the grow only when there is a capped file to grow. If every finding is an unlimited file on a full volume, only_report logs that a file grow cannot fix a disk problem.remediate (io.kestra.plugin.core.flow.Loop, concurrencyLimit: 1) runs one ALTER DATABASE ... MODIFY FILE (SIZE, MAXSIZE, FILEGROWTH) per file.after_state reads the size, MAXSIZE, used space, growth and headroom back for every grown file and state_log logs the before and after side by side.reverify counts the touched files whose real headroom is still below min_headroom_mb. verify_result fails the run through io.kestra.plugin.core.execution.Fail if there are any.declined logs the findings untouched when the approval was refused.errors posts a Slack alert when the audit cannot run, a statement is rejected or the re-read fails the run.sys.database_files that fails the run when the headroom did not come back, so a grow blocked by a full disk is never reported as success.Error 1105 is sudden and total. One moment writes work, the next every insert that needs a page fails. The warning signs are spread across three places and no single alert ties them together, so by the time anyone looks the file is already at the wall. Doing the check by hand across every database is slow. Growing a file blind on a schedule is how a grow lands on a busy afternoon or fails quietly on a full disk. Kestra reads the used space, the MAXSIZE and the volume free space first, works out the real headroom, gates the change behind two inputs and a human approval, grows one file at a time, then reads the catalog again and fails loudly if the headroom did not come back. The Slack alert says what was found and whether anything changed. The run history keeps every before and after.
On Kestra 2.0.5 against SQL Server 2022 (16.0.4295.3) on Linux, with a local HTTP sink standing in for Slack. Three databases were seeded. appdata was created with a data file at SIZE = 16MB, MAXSIZE = 32MB, FILEGROWTH = 1MB and a table was filled until the file autogrew to its 32 MB ceiling and an insert returned error 1105, which is the state the guard exists to catch. okdata was left with a 64 MB data file capped at 4096 MB and almost empty, as a healthy control. unldata was created with an unlimited growth data file to exercise the disk level report only path. Every number below was read back with sqlcmd against sys.database_files and FILEPROPERTY, not from the flow log.
| Run | Inputs | Result |
|---|---|---|
| 1 | defaults, on appdata |
1 file flagged GROW_FILE: 32 MB used of a 32 MB cap, headroom 0 MB, 1 MB growth. Slack said "No change applied" |
| 2 | defaults, on okdata |
0 flagged, clean branch. The healthy 64 MB file capped at 4096 MB is never flagged |
| 3 | auto_remediate: true, dry_run: true, on appdata |
still 1 flagged, still "No change applied". The dry run blocked the write with auto_remediate on |
| 4 | auto_remediate: true, dry_run: false, pause resumed approved: false |
declined logged the finding. sqlcmd confirmed the file stayed at 32 MB of 32 MB |
| 5 | same, resumed approved: true |
one ALTER DATABASE MODIFY FILE ran. sqlcmd: size 32 MB to 288 MB, MAXSIZE 32 MB to 10240 MB, FILEGROWTH 1 MB to 256 MB, headroom 0 MB to 10208 MB. reverify returned 0 still at risk. An INSERT that had failed with 1105 then succeeded |
| 6 | defaults on the grown appdata |
0 flagged, clean branch. The same file that was flagged reads clean after the fix |
| 7 | approved: true as a login without ALTER DATABASE |
the grow was rejected, the file stayed at 32 MB of 32 MB with 0 MB headroom, reverify found it still short and remediation_failed failed the run. The errors block posted to Slack. The same re-read catches a pre-grow the disk could not satisfy |
| 8 | volume_free_floor_mb: 50000 on unldata, approved: true |
the unlimited growth file was classified REPORT_ONLY, only_report logged that a grow cannot fix a disk problem, nothing was written |
| 9 | unreachable host | audit failed on the TCP connection and the errors block posted to Slack |
Across every run okdata stayed at 2 MB used in a 64 MB file capped at 4096 MB and was never flagged, which shows the detector reports only the file that is actually near its ceiling.
sys.database_files, sys.dm_os_volume_stats and FILEPROPERTY in the database (VIEW SERVER STATE plus access to the database) or sysadmin. Remediation also needs ALTER DATABASE on the target, so db_owner is enough, as is sysadmin.SQLSERVER_PASSWORD: password for the login in user. The password input defaults to this secret.SLACK_WEBHOOK_URL: Slack incoming webhook, used by alert and the errors block.SECRET_.| Input | Default | Purpose |
|---|---|---|
url |
jdbc:sqlserver://localhost:1433 |
SQL Server instance and database to check |
user |
sa |
SQL Server login |
password |
{{ secret('SQLSERVER_PASSWORD') }} |
Password for the login |
used_pct_threshold |
80 |
Flag a capped file at or over this percent of its MAXSIZE used |
min_headroom_mb |
256 |
Flag a file with less real headroom. Also the floor the re-read checks |
volume_free_floor_mb |
2048 |
Flag an unlimited file whose volume has less free space |
min_file_size_mb |
8 |
Ignore files smaller than this |
min_growth_mb |
16 |
A fixed growth under this or percent growth counts as unsafe |
target_maxsize_mb |
10240 |
MAXSIZE a grown file is raised to, never below its new size or current MAXSIZE |
filegrowth_mb |
256 |
Fixed FILEGROWTH left on the file |
auto_remediate |
false |
Allow the statements to run |
dry_run |
true |
Must be false for a statement to run |
SQLSERVER_PASSWORD and SLACK_WEBHOOK_URL secrets.url to include the database (jdbc:sqlserver://host:1433;databaseName=yourdb), set user, then run it once with the defaults and read the headroom per file.target_maxsize_mb to the size the busiest file can reach on its volume. Set filegrowth_mb to a step that fits your write rate.auto_remediate: true and dry_run: false and approve the pause.weekly trigger, which always runs in safe mode.sys.databases and loops, so one schedule covers a whole instance.target_maxsize_mb per database from the volume size, instead of one number, by reading sys.dm_os_volume_stats in the audit.sys.dm_io_virtual_file_stats in the audit and raise the priority of a near full file that is also under heavy write latency.