Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key constraint issues, retry / lookup queries forfailed job #4033

Open
underdarknl opened this issue Jan 17, 2025 · 0 comments
Open

Key constraint issues, retry / lookup queries forfailed job #4033

underdarknl opened this issue Jan 17, 2025 · 0 comments
Labels
boefjes Issues related to boefjes bug Something isn't working

Comments

@underdarknl
Copy link
Contributor

Please add bug, the name of any relevant modules (e.g. rocky), and any other relevant labels to your issue.

Describe the bug

I'm seeing the following logs on postgres:

5-01-17 08:21:11.895 UTC [8025] ERROR:  duplicate key value violates unique constraint "boefje_meta_pkey"
2025-01-17 08:21:11.895 UTC [8025] DETAIL:  Key (id)=(1ad000dd-edd8-4f8a-ae42-70563ea1ad4a) already exists.
2025-01-17 08:21:11.895 UTC [8025] STATEMENT:  INSERT INTO boefje_meta (id, boefje_id, boefje_version, organization, input_ooi, arguments, environment, runnable_hash, started_at, ended_at) VALUES ('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'::uuid, 'security_txt_downloader', NULL, 'test', 'Website|internet|185.73.32.3|tcp|80|http|internet|css.underdark.nl', '{"input": {"object_type": "Website", "scan_profile": "scan_profile_type=''inherited'' reference=Reference(''Website|internet|185.73.32.3|tcp|80|http|internet|css.underdark.nl'') level=<ScanLevel.L2: 2> user_id=None", "user_id": "None", "primary_key": "Website|internet|185.73.32.3|tcp|80|http|internet|css.underdark.nl", "ip_service": {"ip_port": {"address": {"network": {"name": "internet"}, "address": "185.73.32.3"}, "protocol": "tcp", "port": "80"}, "service": {"name": "http"}}, "hostname": {"network": {"name": "internet"}, "name": "css.underdark.nl"}, "certificate": "None"}}', '{}', '3457f1ec8b651fb4fa6caeedeb70b367cf6d1a6728075648668251d1894cefb1', '2025-01-17T08:21:10.926257+00:00'::timestamptz, '2025-01-17T08:21:11.891491+00:00'::timestamptz)

This is followed up by a read from Octopoes for that specific OOI every few seconds.


172.30.0.14:42738 - "GET /test/object?reference=Hostname%7Cinternet%7Ccss.underdark.nl&valid_time=2025-01-17%2010%3A50%3A35.605765%2B00%3A00 HTTP/1.1" 200
172.30.0.14:53806 - "GET /test/object?reference=Hostname%7Cinternet%7Ccss.underdark.nl&valid_time=2025-01-17%2010%3A51%3A35.653344%2B00%3A00 HTTP/1.1" 200
172.30.0.14:36802 - "GET /test/object?reference=Hostname%7Cinternet%7Ccss.underdark.nl&valid_time=2025-01-17%2010%3A52%3A35.709503%2B00%3A00 HTTP/1.1" 200
172.30.0.14:52048 - "GET /test/object?reference=Hostname%7Cinternet%7Ccss.underdark.nl&valid_time=2025-01-17%2010%3A53%3A35.811916%2B00%3A00 HTTP/1.1" 200
172.30.0.14:58242 - "GET /test/object?reference=Hostname%7Cinternet%7Ccss.underdark.nl&valid_time=2025-01-17%2010%3A54%3A35.855342%2B00%3A00 HTTP/1.1" 200
172.30.0.14:56862 - "GET /test/object?reference=Hostname%7Cinternet%7Ccss.underdark.nl&valid_time=2025-01-17%2010%3A55%3A35.903854%2B00%3A00 HTTP/1.1" 200
172.30.0.14:45248 - "GET /test/object?reference=Hostname%7Cinternet%7Ccss.underdark.nl&valid_time=2025-01-17%2010%3A56%3A35.959063%2B00%3A00 HTTP/1.1" 200
172.30.0.14:37976 - "GET /test/object?reference=Hostname%7Cinternet%7Ccss.underdark.nl&valid_time=2025-01-17%2010%3A57%3A36.027924%2B00%3A00 HTTP/1.1" 200
172.30.0.14:33248 - "GET /test/object?reference=Hostname%7Cinternet%7Ccss.underdark.nl&valid_time=2025-01-17%2010%3A58%3A36.092760%2B00%3A00 HTTP/1.1" 200
172.30.0.14:39830 - "GET /test/object?reference=Hostname%7Cinternet%7Ccss.underdark.nl&valid_time=2025-01-17%2010%3A59%3A36.141722%2B00%3A00 HTTP/1.1" 200
172.30.0.14:59512 - "GET /test/object?reference=Hostname%7Cinternet%7Ccss.underdark.nl&valid_time=2025-01-17%2011%3A00%3A36.191452%2B00%3A00 HTTP/1.1" 200
172.30.0.14:36218 - "GET /test/object?reference=Hostname%7Cinternet%7Ccss.underdark.nl&valid_time=2025-01-17%2011%3A01%3A36.710511%2B00%3A00 HTTP/1.1" 200
172.30.0.14:56538 - "GET /test/object?reference=Hostname%7Cinternet%7Ccss.underdark.nl&valid_time=2025-01-17%2011%3A02%3A36.761285%2B00%3A00 HTTP/1.1" 200
172.30.0.14:45680 - "GET /test/object?reference=Hostname%7Cinternet%7Ccss.underdark.nl&valid_time=2025-01-17%2011%3A03%3A36.817759%2B00%3A00 HTTP/1.1" 200

And from bytes:


172.30.0.14:46836 - "GET /bytes/boefje_meta?boefje_id=dns-sec&input_ooi=Hostname%7Cinternet%7Ccss.underdark.nl&organization=test&limit=1&descending=true HTTP/1.1" 200
172.30.0.14:49110 - "GET /bytes/boefje_meta?boefje_id=dns-sec&input_ooi=Hostname%7Cinternet%7Ccss.underdark.nl&organization=test&limit=1&descending=true HTTP/1.1" 200
172.30.0.14:34074 - "GET /bytes/boefje_meta?boefje_id=dns-sec&input_ooi=Hostname%7Cinternet%7Ccss.underdark.nl&organization=test&limit=1&descending=true HTTP/1.1" 200
172.30.0.14:41868 - "GET /bytes/boefje_meta?boefje_id=dns-sec&input_ooi=Hostname%7Cinternet%7Ccss.underdark.nl&organization=test&limit=1&descending=true HTTP/1.1" 200
172.30.0.14:60720 - "GET /bytes/boefje_meta?boefje_id=dns-sec&input_ooi=Hostname%7Cinternet%7Ccss.underdark.nl&organization=test&limit=1&descending=true HTTP/1.1" 200
172.30.0.14:38156 - "GET /bytes/boefje_meta?boefje_id=dns-sec&input_ooi=Hostname%7Cinternet%7Ccss.underdark.nl&organization=test&limit=1&descending=true HTTP/1.1" 200
172.30.0.14:34246 - "GET /bytes/boefje_meta?boefje_id=dns-sec&input_ooi=Hostname%7Cinternet%7Ccss.underdark.nl&organization=test&limit=1&descending=true HTTP/1.1" 200
172.30.0.14:39414 - "GET /bytes/boefje_meta?boefje_id=dns-sec&input_ooi=Hostname%7Cinternet%7Ccss.underdark.nl&organization=test&limit=1&descending=true HTTP/1.1" 200
172.30.0.14:57574 - "GET /bytes/boefje_meta?boefje_id=dns-sec&input_ooi=Hostname%7Cinternet%7Ccss.underdark.nl&organization=test&limit=1&descending=true HTTP/1.1" 200
172.30.0.14:56414 - "GET /bytes/boefje_meta?boefje_id=dns-sec&input_ooi=Hostname%7Cinternet%7Ccss.underdark.nl&organization=test&limit=1&descending=true HTTP/1.1" 200

The boefje log indicated an initial upload to Bytes for the raw file was sucesfull, but it tried again and then failed. It then also failed to path the status to "failed".

Grepped for the UUID:

2025-01-17T08:21:07.726103 [info] Handling task[1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
2025-01-17T08:21:07.726768 [info] Dispatched task[1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
2025-01-17T08:21:07.771089 [info] Handling task[1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
2025-01-17T08:21:07.771816 [info] Dispatched task[1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
HTTP Request: PATCH http://scheduler:8000/tasks/1ad000dd-edd8-4f8a-ae42-70563ea1ad4a "HTTP/1.1 200 OK"
2025-01-17T08:21:08.833398 [info] Handling boefje security_txt_downloader[task_id=1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
2025-01-17T08:21:08.927601 [info] Starting boefje security_txt_downloader[1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
2025-01-17T08:21:08.945782 [error] Error running boefje security_txt_downloader[1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
│ │                         │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                 │ │
│ │               │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                           │ │
│ │                  │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                        │ │
│ │                         │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                 │ │
2025-01-17T08:21:09.798073 [info] Saving to Bytes for boefje security_txt_downloader[1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
HTTP Request: POST http://bytes:8000/bytes/raw?boefje_meta_id=1ad000dd-edd8-4f8a-ae42-70563ea1ad4a "HTTP/1.1 200 OK"
2025-01-17T08:21:09.858527 [info] Saved raw file 5535b23d-ca74-4b2f-970f-0dde1d8f79d9 for boefje security_txt_downloader[1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
2025-01-17T08:21:09.858666 [error] An error occurred handling scheduler item[id=1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
│ │                         │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                 │ │
│ │               │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                           │ │
│ │                    │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                      │ │
│ │                    │   │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                  │ │
│ │                           │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),               │ │
│ │                         │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                 │ │
HTTP Request: GET http://scheduler:8000/tasks/1ad000dd-edd8-4f8a-ae42-70563ea1ad4a "HTTP/1.1 200 OK"
HTTP Request: PATCH http://scheduler:8000/tasks/1ad000dd-edd8-4f8a-ae42-70563ea1ad4a "HTTP/1.1 200 OK"
2025-01-17T08:21:10.802787 [info] Set status to TaskStatus.FAILED in the scheduler for task[id=1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
HTTP Request: PATCH http://scheduler:8000/tasks/1ad000dd-edd8-4f8a-ae42-70563ea1ad4a "HTTP/1.1 200 OK"
2025-01-17T08:21:10.811284 [info] Handling boefje security_txt_downloader[task_id=1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
2025-01-17T08:21:10.926151 [info] Starting boefje security_txt_downloader[1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
2025-01-17T08:21:10.946494 [error] Error running boefje security_txt_downloader[1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
│ │                         │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                 │ │
│ │               │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                           │ │
│ │                  │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                        │ │
│ │                         │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                 │ │
2025-01-17T08:21:11.891566 [info] Saving to Bytes for boefje security_txt_downloader[1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
2025-01-17T08:21:11.911553 [error] An error occurred handling scheduler item[id=1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
│ │                         │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                 │ │
│ │               │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                           │ │
│ │                  │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                        │ │
│ │                         │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                 │ │
│ │                    │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                      │ │
│ │                    │   │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                  │ │
│ │                  │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                        │ │
│ │            │   │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                          │ │
│ │               │   id=UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'),                           │ │
HTTP Request: GET http://scheduler:8000/tasks/1ad000dd-edd8-4f8a-ae42-70563ea1ad4a "HTTP/1.1 200 OK"
HTTP Request: PATCH http://scheduler:8000/tasks/1ad000dd-edd8-4f8a-ae42-70563ea1ad4a "HTTP/1.1 200 OK"
2025-01-17T08:21:12.824266 [info] Set status to TaskStatus.FAILED in the scheduler for task[id=1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]

Bytes logs seem to concur when grepping for the UUID:

2025-01-17T08:21:09.800620 [info] Added boefje meta [id=1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
172.30.0.11:57288 - "POST /bytes/raw?boefje_meta_id=1ad000dd-edd8-4f8a-ae42-70563ea1ad4a HTTP/1.1" 200
2025-01-17T08:21:11.894126 [info] Added boefje meta [id=1ad000dd-edd8-4f8a-ae42-70563ea1ad4a]
DETAIL:  Key (id)=(1ad000dd-edd8-4f8a-ae42-70563ea1ad4a) already exists.
DETAIL:  Key (id)=(1ad000dd-edd8-4f8a-ae42-70563ea1ad4a) already exists.
[parameters: {'id': UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'), 'boefje_id': 'security_txt_downloader', 'boefje_version': None, 'organization': 'test', 'input_ooi': 'Website|internet|185.73.32.3|tcp|80|http|internet|css.underdark.nl', 'arguments': '{"input": {"object_type": "Website", "scan_profile": "scan_profile_type=\'inherited\' reference=Reference(\'Website|internet|185.73.32.3|tcp|80|http| ... (284 characters truncated) ... tcp", "port": "80"}, "service": {"name": "http"}}, "hostname": {"network": {"name": "internet"}, "name": "css.underdark.nl"}, "certificate": "None"}}', 'environment': '{}', 'runnable_hash': '3457f1ec8b651fb4fa6caeedeb70b367cf6d1a6728075648668251d1894cefb1', 'started_at': datetime.datetime(2025, 1, 17, 8, 21, 10, 926257, tzinfo=TzInfo(UTC)), 'ended_at': datetime.datetime(2025, 1, 17, 8, 21, 11, 891491, tzinfo=TzInfo(UTC))}]
DETAIL:  Key (id)=(1ad000dd-edd8-4f8a-ae42-70563ea1ad4a) already exists.
DETAIL:  Key (id)=(1ad000dd-edd8-4f8a-ae42-70563ea1ad4a) already exists.
[parameters: {'id': UUID('1ad000dd-edd8-4f8a-ae42-70563ea1ad4a'), 'boefje_id': 'security_txt_downloader', 'boefje_version': None, 'organization': 'test', 'input_ooi': 'Website|internet|185.73.32.3|tcp|80|http|internet|css.underdark.nl', 'arguments': '{"input": {"object_type": "Website", "scan_profile": "scan_profile_type=\'inherited\' reference=Reference(\'Website|internet|185.73.32.3|tcp|80|http| ... (284 characters truncated) ... tcp", "port": "80"}, "service": {"name": "http"}}, "hostname": {"network": {"name": "internet"}, "name": "css.underdark.nl"}, "certificate": "None"}}', 'environment': '{}', 'runnable_hash': '3457f1ec8b651fb4fa6caeedeb70b367cf6d1a6728075648668251d1894cefb1', 'started_at': datetime.datetime(2025, 1, 17, 8, 21, 10, 926257, tzinfo=TzInfo(UTC)), 'ended_at': datetime.datetime(2025, 1, 17, 8, 21, 11, 891491, tzinfo=TzInfo(UTC))}]

Expected behavior
I'd expect the retries to stop at some point. But most of all, I'd expect the task to try saving its data only once. (perhaps the task was executed twice due to a race condition somehow?

OpenKAT version
Main

@underdarknl underdarknl added the bug Something isn't working label Jan 17, 2025
@github-project-automation github-project-automation bot moved this to Incoming features / Need assessment in KAT Jan 17, 2025
@underdarknl underdarknl changed the title Key constraint issues Key constraint issues, retry / lookup queries forfailed job Jan 17, 2025
@underdarknl underdarknl added the boefjes Issues related to boefjes label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
boefjes Issues related to boefjes bug Something isn't working
Projects
Status: Incoming features / Need assessment
Development

No branches or pull requests

1 participant