Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Ensure portdb selects _all_ rows with negative rowids #13226

Merged
merged 2 commits into from
Jul 11, 2022

Conversation

DMRobertson
Copy link
Contributor

@DMRobertson DMRobertson commented Jul 8, 2022

#982 tried to fix this problem (missing rows with negative row ids), but unfortunately it only selected at most one batch_size's worth of such rows (default: 1000).

The backward_select query uses the backward_chunk variable as an
inclusive upper bound on the rowids it selects. It is initially 0 (see
setup_table). It is then set to

backward_chunk = min(row[0] for row in brows) - 1

where brows is the result of running the backwards_select query.
For this to make sense, we need to ensure that backwards_select picks
rows in descending order. Otherwise we'll jump right to the bottom of
the rowids, pick out the lowest batch only and discard everything we
skipped over. This is a Bad Thing.

I've tested this locally with the reproduction case reported in #13191.
Without the patch, I could reproduce the reported failure; with the
patch, the portdb script completes successfully. I sanity checked that
the postgres table had the right number of rows in events and
events_edges too.

David Robertson added 2 commits July 8, 2022 14:52
The `backward_select` query uses the `backward_chunk` variable as an
inclusive upper bound on the rowids it selects. It is initially 0 (see
`setup_table`). It is then set to

```
backward_chunk = min(row[0] for row in brows) - 1
```

where `brows` is the result of running the `backwards_select` query.
For this to make sense, we need to ensure that `backwards_select` picks
rows in descending order. Otherwise we'll jump right to the bottom of
the rowids, pick out the lowest batch only and discard everything we
skipped over. This is a Bad Thing.

I've tested this locally with the reproduction case reported in #13191.
Without the patch, I could reproduce the reported failure; with the
patch, the portdb script completes successfully.
@DMRobertson DMRobertson linked an issue Jul 8, 2022 that may be closed by this pull request
@DMRobertson DMRobertson marked this pull request as ready for review July 8, 2022 14:38
@DMRobertson DMRobertson requested a review from a team as a code owner July 8, 2022 14:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

synapse_port_db - Failed to insert: event_edges
2 participants