Page MenuHomePhabricator

Configure a metrics platform stream with a custom schema to record how Nuke users filter pages to delete
Closed, ResolvedPublic5 Estimated Story Points

Description

From https://wikitech.wikimedia.org/wiki/Metrics_Platform/Custom_schemas#Creating_a_custom_schema

Create a new fragment in a new directory in the data-engineering/schemas-event-secondary repository under jsonschema/fragment/analytics/product_metrics.
Create a schema that combines your new fragment, the common fragment, and a platform fragment as a new directory under jsonschema/analytics/product_metrics.
Then define an event stream that uses the custom schema.

Acceptance Critera

  • Create a new fragment
  • Create a schema that uses the new fragment
  • Configure an event stream that uses the new schema

Details

Related Changes in Gerrit:
Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
jsonschema-tools upgrade to 1.5.0 to fix non deterministic CI testrepos/data-engineering/schemas-event-secondary!51ottoT389881_jsonschema-tools-updatemaster
MP fragment schema for MassDelete: fix examplerepos/data-engineering/schemas-event-secondary!50jsnJsn.sherman/T382147-followupmaster
Add MP schema for MassDelete workflowsrepos/data-engineering/schemas-event-secondary!37jsnJsn.sherman/T382147master
Customize query in GitLab

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Scardenasmolinar set the point value for this task to 5.
jsn.sherman changed the task status from Open to In Progress.Jan 14 2025, 7:40 PM
jsn.sherman claimed this task.
jsn.sherman moved this task from Ready to In Progress on the Moderator-Tools-Team (Kanban) board.

Note that I have some WIP on this, but I had to ask some clarifying questions (which were promptly answered) and then set it down to work on other things; I should finish up my patches for this task next week.

moving to review column to reflect that I'm waiting on external review

Change #1123435 had a related patch set uploaded (by Jsn.sherman; author: Jsn.sherman):

[operations/mediawiki-config@master] [WIP] Add MP event stream for MassDelete workflows

https://gerrit.wikimedia.org/r/1123435

jsn.sherman added a subscriber: Samwalton9-WMF.

@Samwalton9-WMF Question:

Now that that the form is publicly available, should we also collect more info about the user, eg. user groups or edit bucket?

we discussed today; we'll only collect data for those who can perform mass deletes

Change #1123435 merged by jenkins-bot:

[operations/mediawiki-config@master] Add MP event stream for MassDelete workflows

https://gerrit.wikimedia.org/r/1123435

Mentioned in SAL (#wikimedia-operations) [2025-03-12T14:15:26Z] <tgr@deploy2002> Started scap sync-world: Backport for [[gerrit:1123435|Add MP event stream for MassDelete workflows (T382147)]], [[gerrit:1126648|Enable SUL3 signup for 50% of group 2 users (T384218)]], [[gerrit:rMW11269562e8f6|[enwiki] Throttle exemption for event (T388637)]]

Mentioned in SAL (#wikimedia-operations) [2025-03-12T14:18:48Z] <tgr@deploy2002> jsn, tgr, superpes: Backport for [[gerrit:1123435|Add MP event stream for MassDelete workflows (T382147)]], [[gerrit:1126648|Enable SUL3 signup for 50% of group 2 users (T384218)]], [[gerrit:rMW11269562e8f6|[enwiki] Throttle exemption for event (T388637)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2025-03-12T14:26:30Z] <tgr@deploy2002> Finished scap sync-world: Backport for [[gerrit:1123435|Add MP event stream for MassDelete workflows (T382147)]], [[gerrit:1126648|Enable SUL3 signup for 50% of group 2 users (T384218)]], [[gerrit:rMW11269562e8f6|[enwiki] Throttle exemption for event (T388637)]] (duration: 11m 04s)

Hi @jsn.sherman !

By default, streams have canary_events_enabled.
https://wikitech.wikimedia.org/wiki/Data_Platform/Systems/Hadoop_Event_Ingestion_Lifecycle#Canary_Events

This mean that (unless you disable canary events) when you declare a stream, artificial canary events will automatically start being produced.
If the stream does not have a schema, these canary events will fail.

Add MP schema for MassDelete workflows has not yet been merged, but Add MP event stream for MassDelete workflows (1123435) has.

Generally, schemas be deployed before any usages of that schema (a stream) is declared.

This is currently causing canary event failures and alerts.

ASAP, we should do one of:

This seems to be causing unrelated test failures on other patches...

https://gitlab.wikimedia.org/repos/data-engineering/schemas-event-secondary/-/jobs/466271 for https://gitlab.wikimedia.org/repos/data-engineering/schemas-event-secondary/-/merge_requests/49

1) Schema Repository Structure in ./jsonschema/
     Schema with title analytics/mediawiki/product_metrics/ext_massdelete
       current version 1.0.0 must be equal to materialized latest version 1.0.0:
    AssertionError [ERR_ASSERTION]: Dereferenced current schema does not equal latest schema version 1.0.0
    + expected - actual
             "status_code": -6305039478318694
           }
           "instrument_name": "dolor"
           "massdelete_filter": {
    -        "date_from": "2013-01-22"
    -        "date_to": "2013-01-22"
    +        "date_from": "2013-03-19"
    +        "date_to": "2013-03-19"
             "limit": -6305039478318694
             "namespaces": [
               -6305039478318694
             ]
    
    at Context.<anonymous> (node_modules/@wikimedia/jsonschema-tools/lib/tests/structure.js:120:28)
jsn.sherman moved this task from Done to QA on the Moderator-Tools-Team (Kanban) board.

It looks like the issue is the expected date in the date properties in the examples section; is there a proper placeholder value I should be using in the schema? it seems to expect the date to be the current date when the schema has an arbitrary old date. Is this me doing something wrong in the schema? Or should the CI be able to accept a past date in an example block?

It's the current date... But in 2013? Which feels even more odd

If a schema does not have examples, and shouldGenerateExamples is enabled (it is), then https://github.com/json-schema-faker/json-schema-faker is used to generate the examples.

This test is a sanity check to make sure that whatever current.yaml has it exactly what the materialized versioned schema file has.

Something must be going wrong here.

yes, I was just poking around json-schema-tools and wondering where the options were set for the test run; this smells like a ci code issue rather than a schema problem. Having said that, I'm not discounting the possibility that I messed up somehow.

I think I see it. I'm not exactly sure why this is happening, but:

fragment/analytics/product_metrics/ext_massdelete/current.yaml examples is a bit weird:

examples:
  - massdelete_filter:
      target: dolor
      pattern: dolor
      limit: 0
      namespaces:
        - 0
      date_from: '2025-01-01'
      date_to: '2025-01-01'
  - massdelete_response_time_ms: 500

- massdelete_response_time_ms is its own example entry.

I think you've got a misplaced '-' in the yaml!

This probably should have failed the examples must validate against schema test, but the schema doesn't have any required properties, and massdelete_response_time_ms is an actual field, so it is valid!

I don't know why an example is being generated during this test at all though...

Maybe there is a subtle race condition in the test when it dereferences and materializes current.yaml to compare against the materialized file. Somehow maybe it is checking the current.yaml file for examples, not seeing any, generating them, THEN dereferencing and merging schemas together?

Reading the code I don't see it.

@Ottomata Can I just update the existing schema version or do I need to increment? We haven't deployed any instruments against this yet.

I think I see it. I'm not exactly sure why this is happening, but:

fragment/analytics/product_metrics/ext_massdelete/current.yaml examples is a bit weird:

examples:
  - massdelete_filter:
      target: dolor
      pattern: dolor
      limit: 0
      namespaces:
        - 0
      date_from: '2025-01-01'
      date_to: '2025-01-01'
  - massdelete_response_time_ms: 500

- massdelete_response_time_ms is its own example entry.

I think you've got a misplaced '-' in the yaml!

This probably should have failed the examples must validate against schema test, but the schema doesn't have any required properties, and massdelete_response_time_ms is an actual field, so it is valid!

I don't know why an example is being generated during this test at all though...

I updated that example, but I'm now seeing this error too:
https://gitlab.wikimedia.org/repos/data-engineering/schemas-event-secondary/-/compare/master...Jsn.sherman%2FT382147-followup

7904 passing (7s)
302 pending
1 failing

1) Schema Repository Structure in ./jsonschema/
     Schema with title analytics/mediawiki/product_metrics/ext_massdelete
       current version 1.0.0 must be equal to materialized latest version 1.0.0:

    AssertionError [ERR_ASSERTION]: Dereferenced current schema does not equal latest schema version 1.0.0
    + expected - actual

             "status_code": -6305039478318694
           }
           "instrument_name": "dolor"
           "massdelete_filter": {
    -        "date_from": "2013-01-22"
    -        "date_to": "2013-01-22"
    +        "date_from": "2013-03-20"
    +        "date_to": "2013-03-20"
             "limit": -6305039478318694
             "namespaces": [
               -6305039478318694
             ]

    at Context.<anonymous> (node_modules/@wikimedia/jsonschema-tools/lib/tests/structure.js:120:28)

@Ottomata Can I just update the existing schema version or do I need to increment? We haven't deployed any instruments against this yet.

I answered my own question; incrementing the version resolves the issue with the updated example; thanks @Ottomata!

Hm, technically you can just update, this only changes the example, so as long as rematerialize all the right files (the fragment and the dependent concrete schemas).

Usually this may require a restart of eventgate, as eventgate assumes schema versions are immutable. In this case, the examples are not used by eventgate, so I think it will be fine!

Oh! incrementing the version is fine too.

@Ottomata @jsn.sherman this issue is blocking us from merging a schema update (https://gitlab.wikimedia.org/repos/data-engineering/schemas-event-secondary/-/merge_requests/49), would it be possible to prioritize fixing this early this week?

@Ottomata @jsn.sherman this issue is blocking us from merging a schema update (https://gitlab.wikimedia.org/repos/data-engineering/schemas-event-secondary/-/merge_requests/49), would it be possible to prioritize fixing this early this week?

We'll get it merged today; I'm so used to the Gerrit +2 workflow that I forgot that approved != merged in gitlab.

@Ottomata @jsn.sherman this issue is blocking us from merging a schema update (https://gitlab.wikimedia.org/repos/data-engineering/schemas-event-secondary/-/merge_requests/49), would it be possible to prioritize fixing this early this week?

We'll get it merged today; I'm so used to the Gerrit +2 workflow that I forgot that approved != merged in gitlab.

So, I went to add changelogs since I incremented the schema versions and found that the build was failing again. Once again, the issue seemed to be that CI is expecting today's date, but in 2013

1) Schema Repository Structure in ./jsonschema/
     Schema with title analytics/mediawiki/product_metrics/ext_massdelete
       current version 1.0.1 must be equal to materialized latest version 1.0.1:
    AssertionError [ERR_ASSERTION]: Dereferenced current schema does not equal latest schema version 1.0.1
    + expected - actual
             "status_code": -6305039478318694
           }
           "instrument_name": "dolor"
           "massdelete_filter": {
    -        "date_from": "2013-03-20"
    -        "date_to": "2013-03-20"
    +        "date_from": "2013-03-24"
    +        "date_to": "2013-03-24"
             "limit": -6305039478318694
             "namespaces": [
               -6305039478318694
             ]

https://gitlab.wikimedia.org/repos/data-engineering/schemas-event-secondary/-/jobs/470075

Updating the date to match today once again resolved it:
https://gitlab.wikimedia.org/repos/data-engineering/schemas-event-secondary/-/jobs/470076

This makes me doubt that the example was the source of the issue. Any thoughts @Reedy or @Ottomata?

Odd.. The example was obviously definitely wrong, but beyond that...

Very strange.

Updating the date to match today once again resolved it:

What does this mean? What did you change?

What is the difference between b55d14dede745df1f007c86fe8c6c870c2af462b and eb02a28694e2f88503866165e77db07d4ff260d8?

Hm, you could consider manually editing the 1.0.0 versions and fixing their examples too. Just in case?

I don't see how that could affect this test though...

literally just the example dates in
https://gitlab.wikimedia.org/repos/data-engineering/schemas-event-secondary/-/merge_requests/50/diffs#55ef7678e8de301e759e79f8a3476bc9489eac40_0_597
https://gitlab.wikimedia.org/repos/data-engineering/schemas-event-secondary/-/merge_requests/50/diffs#55ef7678e8de301e759e79f8a3476bc9489eac40_0_598

those dates were generated as 2013-03-20 when I ran the scripts last week and passed. The same npm run test command failed locally and in CI today. I updated both to 2013-03-24 by hand and now npm run test is passing locally and in CI.

^ sounds like it will pass until tomorrow!

I wonder if the issue might have something to do with the fragment examples generation vs the concrete event schema's example generation!

I'll see if I can find something...

Sorry yall, this is quite a strange issue that we have not encountered before.

Ah ha! I found it.

https://github.com/wikimedia/jsonschema-tools/blob/master/lib/jsonschema-tools.js#L166-L171

We have a static value used for format: date-time example generation, but not for format: date. .massdelete_filter is format: date.

Creating a task and will submit a patch.

Okay, T389881: Bug: jsonschema-tools generates non deterministic examples for date format fields is done. I also fixed and merged @jsn.sherman's MR 50 in schemas-event-secondary.

@kostajh @Reedy please rebase your MRs and confirm the fix! Thank you!

jsn.sherman moved this task from QA to Done on the Moderator-Tools-Team (Kanban) board.

closing out this task; if there are further problems related to jsonschema-tools, please see T389881: Bug: jsonschema-tools generates non deterministic examples for date format fields