diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-07-04 12:11:38 +0100 |
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-07-04 19:36:30 +0100 |
| commit | 61e106fe6a15f76b73125682e91d5c17ee875be2 (patch) | |
| tree | 14727c98dff6b4d5097951c1ec4d238627e5c52e /src/sql | |
| parent | 409e41d1d97b180233be778a2d23ba0b4328b5c2 (diff) | |
| download | webstat-61e106fe6a15f76b73125682e91d5c17ee875be2.tar.bz2 webstat-61e106fe6a15f76b73125682e91d5c17ee875be2.tar.xz webstat-61e106fe6a15f76b73125682e91d5c17ee875be2.zip | |
Include extra details when storing unparsable and uninsertable lines.
Now includes the hostnameId, timestamp and optionally error message.
Updates idx_entities_retryinsert to account for details not being NULL.
Also fixes the issue where the entities inserted and rollback would
still be recorded in the entity cache if the access log insert failed.
This would have lead to PK violations later on.
Diffstat (limited to 'src/sql')
| -rw-r--r-- | src/sql/markEntityRetried.sql | 2 | ||||
| -rw-r--r-- | src/sql/selectUninsertableLines.sql | 2 | ||||
| -rw-r--r-- | src/sql/uninsertableInsert.sql | 5 | ||||
| -rw-r--r-- | src/sql/unparsableInsert.sql | 4 |
4 files changed, 11 insertions, 2 deletions
diff --git a/src/sql/markEntityRetried.sql b/src/sql/markEntityRetried.sql index 6ec2263..a52a15c 100644 --- a/src/sql/markEntityRetried.sql +++ b/src/sql/markEntityRetried.sql @@ -1,6 +1,6 @@ UPDATE entities SET - detail = jsonb_build_object('retriedAt', CURRENT_TIMESTAMP at time zone 'utc', 'error', ?::text) + detail = detail || jsonb_build_object('retriedAt', CURRENT_TIMESTAMP at time zone 'utc', 'error', ?::text) WHERE id = ? diff --git a/src/sql/selectUninsertableLines.sql b/src/sql/selectUninsertableLines.sql index 894ab67..060e800 100644 --- a/src/sql/selectUninsertableLines.sql +++ b/src/sql/selectUninsertableLines.sql @@ -5,7 +5,7 @@ FROM entities WHERE type = 'uninsertable_line' - AND detail IS NULL + AND detail ->> 'retriedAt' IS NULL ORDER BY id LIMIT ? diff --git a/src/sql/uninsertableInsert.sql b/src/sql/uninsertableInsert.sql new file mode 100644 index 0000000..5b09393 --- /dev/null +++ b/src/sql/uninsertableInsert.sql @@ -0,0 +1,5 @@ +INSERT INTO entities(type, value, detail) + VALUES ('uninsertable_line', $1, jsonb_build_object('hostnameId', $2::int, 'error', $3::text, + 'timestamp', CURRENT_TIMESTAMP)) +RETURNING + id diff --git a/src/sql/unparsableInsert.sql b/src/sql/unparsableInsert.sql new file mode 100644 index 0000000..6441f93 --- /dev/null +++ b/src/sql/unparsableInsert.sql @@ -0,0 +1,4 @@ +INSERT INTO entities(type, value, detail) + VALUES ('unparsable_line', $1, jsonb_build_object('hostnameId', $2::int, 'timestamp', CURRENT_TIMESTAMP)) +RETURNING + id |
