Cassandra: Query answers 500 on a partition whose items were all deleted

Aperta Adatta ai principianti
#795 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
databases

Direzione di ricerca

Inizia da crates/storage-cassandra/src/data/query.rs, dove il ciclo dei risultati chiama cassandra_util::get_column(&row, "item_data", "query parse")? e fallisce sulla riga solo statica lasciata da delete_item.rs. Salta lì le righe il cui item_data è null e verifica se la lettura Scan ha lo stesso ciclo. È completato quando una Query su una partizione completamente eliminata restituisce Count: 0 con e senza ConsistentRead, dimostrato da un test a doppio target in tests/.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

On the Cassandra backend, a Query whose partition key names a partition that held items, all of which have since been deleted, answers 500 InternalServerError instead of an empty result. Amazon DynamoDB answers 200 with Count: 0.

Reproduction

A table with a hash key pk (S) and a range key sk (S), on a local Cassandra 4.1 node:

  1. PutItem {"pk": "a", "sk": "1"}.
  2. Query with pk = :p, :p = "a": Count: 1.
  3. DeleteItem {"pk": "a", "sk": "1"}.
  4. The same Query, with ConsistentRead false and true: both answer 500 {'Code': 'InternalServerError', 'Message': 'Internal server error'}.

A conditional delete (attribute_exists(pk)) in step 3 gives the same result. The server logs:

ERROR extenddb_storage_cassandra::cassandra_util: query parse parse column 'item_data': General error: Column or Udt property 'item_data' is empty

Where

crates/storage-cassandra/src/data/delete_item.rs writes partition_max_delete_timestamp before it deletes the row (update_partition_max_delete_timestamp_at). On a table with a sort key that column is STATIC (ddl.rs), so once the last item is gone the partition still holds a row with only the static column set. The Query path in crates/storage-cassandra/src/data/query.rs reads item_data from every row it gets back with cassandra_util::get_column(&row, "item_data", "query parse")?, which fails on that static-only row.

Seen on main (5ff323beb) and on the branch of #424; the reproduction above was run against the #424 branch.

Suggested fix

Skip rows whose item_data is null in the Query (and Scan, if it has the same read) result loop, as rows with no item, rather than failing the request.

Test

A dual-target test in tests/ that puts one item, deletes it and asserts that a Query of its partition answers Count: 0, with and without ConsistentRead.

Lingua principale
Rust
Stelle
517
Fork
60
Merge medio
5g 1h
PR unite (30g)
67

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ExtendDB/extenddb

Tutte le issue di ExtendDB/extenddb

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.