Page MenuHomePhabricator

[BUG] query-next: stale data and non-deterministic response payloads
Closed, ResolvedPublicBUG REPORT

Description

Pilot users reported stale data and non-deterministic response payloads.

Some WDQS v2 indexes has drifted and this manifests with inconsistent responses across requests.

Context

We run multiple instances of WDQS (and QLever databases) behind a load balancer. Each receives real-time updates
independently. We don't pin clients to specific hosts (caveat: keepalive can temporarily pin connections),
and requests are round-robin. Each query to https://query-next.wikidata.org can, in principle, be answered
by a different WDQS and QLever host.

Next to real-time updates, we plan to reconcile weekly from the RDF exports, specifically to resolve
consistency issues. This reconciliation capability was deployed to our staging environment (internal, not exposed
to public traffic) but has yet to be deployed to the query-next deployments.

Problem

Currently we run on a relatively old index, built in July 2026:

$ runuser@wdqs-main-external-backend-0:/srv/data$ ls
2026-07-03_23-11-22 current lost+found

Our telemetry indicates no obvious data loss from the update stream, but throughout August and September we did several iterations
on the update (and qlever-index-rebuild of in-memory delta triple updates) code path, so it is safe to assume some PODs might have drifted by now.

Reported queries

SELECT ?item ?ror ?deprecated WHERE { ?item p:P6782 ?stmt . ?stmt ps:P6782 ?ror; wikibase:rank ?rank . BIND(?rank = wikibase:DeprecatedRank AS ?deprecated) }

AC

  • Identify which QLever POD is stale
  • document the troubleshooting process in a runbook on Wikitech. This is a good learning experience (in review).
  • Update the index on WDQS nodes. We build weekly, but don't ship.
  • After an index update, verify data is no longer stale. Test queries to be provided and coordinated with pilot users.

Follow up

  • We need parity with the triple count dashboard and WDQS node data drift alerting we have in place for Blazegraph.
  • Drfit (stale and inconsistent responses) should be an SLI for the new SLO.
  • Ship new indexes weekly T435674: Promote the data reload pipeline to prod

Event Timeline

gmodena renamed this task from query-next: stale data and non-deterministic response payloads to [NEEDS GROOMING] query-next: stale data and non-deterministic response payloads.Oct 8 2026, 10:49 AM
gmodena added a subscriber: HasanAkgun_WMDE.

Baseline is query.wikidata.org

 % curl -s -G "https://query.wikidata.org/sparql" -H "Accept: application/sparql-results+json" --data-urlencode 'query=SELECT (COUNT(*) AS ?count) WHERE { { SELECT ?item ?ror ?deprecated WHERE { ?item p:P6782 ?stmt . ?stmt ps:P6782 ?ror; wikibase:rank ?rank . BIND(?rank = wikibase:DeprecatedRank AS ?deprecated) } } }'
{
  "head" : {
    "vars" : [ "count" ]
  },
  "results" : {
    "bindings" : [ {
      "count" : {
        "datatype" : "http://www.w3.org/2001/XMLSchema#integer",
        "type" : "literal",
        "value" : "144261"
      }
    } ]
  }

Smoke test on eqiad PODs

for i in 0 1 2; do
  kubectl -n wdqs port-forward wdqs-main-external-backend-$i $((7010+i)):7001 >/dev/null 2>&1 &
done
sleep 3

for i in 0 1 2; do
  echo "wdqs-main-external-backend-$i"
  curl -s -G "http://localhost:$((7010+i))/sparql" -H "Accept: application/sparql-results+json" --data-urlencode 'query=PREFIX p: <http://www.wikidata.org/prop/> PREFIX ps: <http://www.wikidata.org/prop/statement/> PREFIX wikibase: <http://wikiba.se/ontology#> SELECT (COUNT(*) AS ?count) WHERE { { SELECT ?item ?ror ?deprecated WHERE { ?item p:P6782 ?stmt . ?stmt ps:P6782 ?ror; wikibase:rank ?rank . BIND(?rank = wikibase:DeprecatedRank AS ?deprecated) } } }'
  echo
done

Gives me

{"head":{"vars":["count"]},"results":{"bindings":[{"count":{"datatype":"http://www.w3.org/2001/XMLSchema#int","type":"literal","value":"144261"}}]},"meta":{"query-time-ms":9676,"result-size-total":1}}
wdqs-main-external-backend-1
{"head":{"vars":["count"]},"results":{"bindings":[{"count":{"datatype":"http://www.w3.org/2001/XMLSchema#int","type":"literal","value":"144261"}}]},"meta":{"query-time-ms":3143,"result-size-total":1}}
wdqs-main-external-backend-2
{"head":{"vars":["count"]},"results":{"bindings":[{"count":{"datatype":"http://www.w3.org/2001/XMLSchema#int","type":"literal","value":"143522"}}]},"meta":{"query-time-ms":3075,"result-size-total":1}}

So looks like wdqs-main-external-backend-2 has drifted.

lerickson renamed this task from [NEEDS GROOMING] query-next: stale data and non-deterministic response payloads to query-next: stale data and non-deterministic response payloads.Oct 8 2026, 2:34 PM
lerickson triaged this task as High priority.

Our plan is to get a new index by one of the two following methods:

  • validate the most recent data-reload-pipeline index
  • build an index manually using the script we have for this purpose
lerickson renamed this task from query-next: stale data and non-deterministic response payloads to [BUG] query-next: stale data and non-deterministic response payloads.Wed, Oct 14, 1:57 PM
lerickson claimed this task.
lerickson updated Other Assignee, added: gmodena.
Restricted Application changed the subtype of this task from "Task" to "Bug Report". · View Herald TranscriptWed, Oct 14, 1:57 PM

Change #1355749 had a related patch set uploaded (by Lerickson; author: Lerickson):

[operations/deployment-charts@master] WDQS V2 main: Look for an index in the data-reload-test-bucket S3 bucket instead of wdqs-update-pipeline.

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

Change #1355749 merged by jenkins-bot:

[operations/deployment-charts@master] WDQS V2 main: Look for an index in the data-reload-test-bucket S3 bucket instead of wdqs-update-pipeline.

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

We have updated the index for the wikidata_main graph so there shouldn't be discrepancies or stale data anymore. We expect to have the scholarly_articles graph updated tomorrow, Friday Oct 16.

The new wikidata_main index that is now live was built by the data-reload pipeline based on a snapshot from Oct 13 of Wikidata (and then streaming updates on top of that to keep up to date since Oct 13).

Let's run some validation and LGTM. Runbook for this failure scenario is in review. Metrics and alerting will follow (we have these in place for Blazegraph, needs adjustments for qlever).

wikidata_main

I've run the test query @ArthurPSmith reported, and verified it returns the same number of results across the whole wikidata_main fleet:

SELECT (COUNT(*) AS ?count) WHERE { { SELECT ?item ?ror ?deprecated WHERE { ?item p:P6782 ?stmt . ?stmt ps:P6782 ?ror; wikibase:rank ?rank . BIND(?rank = wikibase:DeprecatedRank AS ?deprecated) } } }

I did not compare the result sets returned.

To repro.

gmodena@deploy1003:~$ cat test_drift.sh 
for i in 0 1 2; do
  kubectl -n wdqs port-forward wdqs-main-external-$i $((7010+i)):7001 >/dev/null 2>&1 &
done
sleep 3

for i in 0 1 2; do
  echo "wdqs-main-external-backend-$i"
  curl -s -G "http://localhost:$((7010+i))/sparql" -H "Accept: application/sparql-results+json" --data-urlencode 'query=SELECT (COUNT(*) AS ?count) WHERE { { SELECT ?item ?ror ?deprecated WHERE { ?item p:P6782 ?stmt . ?stmt ps:P6782 ?ror; wikibase:rank ?rank . BIND(?rank = wikibase:DeprecatedRank AS ?deprecated) } } }'
  echo
done

In eqiad:

gmodena@deploy1003:~$ kube_env wdqs dse-k8s-eqiad
gmodena@deploy1003:~$ ./test_drift.sh 
wdqs-main-external-backend-0
{"head":{"vars":["count"]},"results":{"bindings":[{"count":{"datatype":"http://www.w3.org/2001/XMLSchema#int","type":"literal","value":"144260"}}]},"meta":{"query-time-ms":4347,"result-size-total":1}}
wdqs-main-external-backend-1
{"head":{"vars":["count"]},"results":{"bindings":[{"count":{"datatype":"http://www.w3.org/2001/XMLSchema#int","type":"literal","value":"144260"}}]},"meta":{"query-time-ms":4755,"result-size-total":1}}
wdqs-main-external-backend-2
{"head":{"vars":["count"]},"results":{"bindings":[{"count":{"datatype":"http://www.w3.org/2001/XMLSchema#int","type":"literal","value":"144260"}}]},"meta":{"query-time-ms":4469,"result-size-total":1}}

In codfw:

gmodena@deploy1003:~$ kube_env wdqs dse-k8s-codfw
gmodena@deploy1003:~$ ./test_drift.sh 
wdqs-main-external-backend-0
{"head":{"vars":["count"]},"results":{"bindings":[{"count":{"datatype":"http://www.w3.org/2001/XMLSchema#int","type":"literal","value":"144260"}}]},"meta":{"query-time-ms":3129,"result-size-total":1}}
wdqs-main-external-backend-1
{"head":{"vars":["count"]},"results":{"bindings":[{"count":{"datatype":"http://www.w3.org/2001/XMLSchema#int","type":"literal","value":"144260"}}]},"meta":{"query-time-ms":3072,"result-size-total":1}}
wdqs-main-external-backend-2
{"head":{"vars":["count"]},"results":{"bindings":[{"count":{"datatype":"http://www.w3.org/2001/XMLSchema#int","type":"literal","value":"144260"}}]},"meta":{"query-time-ms":3145,"result-size-total":1}}

scholarly_articles

@lerickson scholarly looks good to me. I ran an item count as a smoke test. The cardinality differs by triple-digit number of records (out of 8B+ triples).

This looks like a legitimate eventual-consistency artifact (one we need to live with and document in the SLO), and the fact that each instance is updated independently by it's own streaming process (so timing are expected to be slightly off) rather than a borked pod. Let's deploy a new scholarly_articles index once ready (that's good practice), but I don't think it's a blocker for this task.

gmodena@deploy1003:~$ cat count_items.sh 
for i in 0 1 2; do
  kubectl -n wdqs port-forward wdqs-scholarly-external-backend-$i $((7010+i)):7001 >/dev/null 2>&1 &
done
sleep 3

for i in 0 1 2; do
  echo "wdqs-main-external-backend-$i"
  curl -s -G "http://localhost:$((7010+i))/sparql" -H "Accept: application/sparql-results+json" --data-urlencode 'query=PREFIX wikibase: <http://wikiba.se/ontology#> SELECT (SUM(?n) AS ?count) WHERE { ?item wikibase:statements ?n . }'
  echo
done

eqiad:

gmodena@deploy1003:~$ kube_env wdqs dse-k8s-eqiad
gmodena@deploy1003:~$ ./count_items.sh 
wdqs-main-external-backend-0
{"head":{"vars":["count"]},"results":{"bindings":[{"count":{"datatype":"http://www.w3.org/2001/XMLSchema#int","type":"literal","value":"801390978"}}]},"meta":{"query-time-ms":799,"result-size-total":1}}
wdqs-main-external-backend-1
{"head":{"vars":["count"]},"results":{"bindings":[{"count":{"datatype":"http://www.w3.org/2001/XMLSchema#int","type":"literal","value":"801390971"}}]},"meta":{"query-time-ms":788,"result-size-total":1}}
wdqs-main-external-backend-2
{"head":{"vars":["count"]},"results":{"bindings":[{"count":{"datatype":"http://www.w3.org/2001/XMLSchema#int","type":"literal","value":"801390979"}}]},"meta":{"query-time-ms":809,"result-size-total":1}}

codfw:

gmodena@deploy1003:~$ ./test_drift.sh 
wdqs-main-external-backend-0
{"head":{"vars":["count"]},"results":{"bindings":[{"count":{"datatype":"http://www.w3.org/2001/XMLSchema#int","type":"literal","value":"801390704"}}]},"meta":{"query-time-ms":799,"result-size-total":1}}
wdqs-main-external-backend-1
{"head":{"vars":["count"]},"results":{"bindings":[{"count":{"datatype":"http://www.w3.org/2001/XMLSchema#int","type":"literal","value":"801390706"}}]},"meta":{"query-time-ms":789,"result-size-total":1}}
wdqs-main-external-backend-2
{"head":{"vars":["count"]},"results":{"bindings":[{"count":{"datatype":"http://www.w3.org/2001/XMLSchema#int","type":"literal","value":"801390708"}}]},"meta":{"query-time-ms":795,"result-size-total":1}}

A runbook to troubleshoot this type of issue is available https://wikitech.wikimedia.org/wiki/Wikidata_Platform/Runbook/Tuple_drift_in_QLever_replicas. The intended audience are WDP engineers and SRE.