Skip to content

Fix Vote History sorting#5927

Open
pawelperek-da wants to merge 3 commits into
mainfrom
pawel/vote-history-sort
Open

Fix Vote History sorting#5927
pawelperek-da wants to merge 3 commits into
mainfrom
pawel/vote-history-sort

Conversation

@pawelperek-da

@pawelperek-da pawelperek-da commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #5692

Before:
Screenshot 2026-06-12 at 13 21 48

After:
Screenshot 2026-06-12 at 13 32 16

Pull Request Checklist

Cluster Testing

  • If a cluster test is required, comment /cluster_test on this PR to request it, and ping someone with access to the DA-internal system to approve it.
  • If an upgrade test is required, comment /upgrade_test on this PR to request it, and ping someone with access to the DA-internal system to approve it.
  • If a hard-migration test is required (from the latest release), comment /hdm_test on this PR to request it, and ping someone with access to the DA-internal system to approve it.
  • If a logical synchronizer upgrade test is required (from canton-3.5), comment /lsu_test on this PR to request it, and ping someone with access to the DA-internal system to approve it.

PR Guidelines

  • Include any change that might be observable by our partners or affect their deployment in the release notes.
  • Specify fixed issues with Fixes #n, and mention issues worked on using #n
  • Include a screenshot for frontend-related PRs - see README or use your favorite screenshot tool

Merge Guidelines

  • Make the git commit message look sensible when squash-merging on GitHub (most likely: just copy your PR description).

Signed-off-by: Paweł Perek <pawel.perek@digitalasset.com>
@pawelperek-da pawelperek-da marked this pull request as ready for review June 11, 2026 21:19
Signed-off-by: Paweł Perek <pawel.perek@digitalasset.com>
Signed-off-by: Paweł Perek <pawel.perek@digitalasset.com>
createAction = sqlu"""
create index concurrently if not exists scan_txlog_store_sid_en_vot
on scan_txlog_store (store_id, entry_number desc)
create index concurrently if not exists scan_txlog_store_sid_rt_en_vot

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rautenrieth-da could you take a look if that's a correct way to remove unused indices? We didn't use IndexAction.Drop before but AFAIU that's the way

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me. Since this is the first time we're using it, we should check if it really works as intended. You won't trigger the code path in integration tests, you need to first deploy an old version of the app and then a version that has your PR merged. At the very least, check logs of CILR after the changes from this PR have been deployed there.

case Some(a) => Some(sql"""entry_number < $a""")
case Some(a) =>
Some(
sql"""(record_time, entry_number) < ((select record_time from #$txLogTableName where store_id = $txLogStoreId and entry_number = $a), $a)"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you check the plane for this? the SQL query looks weird to me.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to commenting with the query plan. We just dropped the index on (store_id, entry_number), how can it quickly find the record time from the entry number?

I would have expected that we do either:

  • Sort lexicographically by (record_time, entry_number), and include the record time in the API pagination token (along with the entry number)
  • Argue why two vote requests can never have the same record time, sort by record time only, and paginate by record time (instead of entry number). If you store the record time as "micros since epoch", you don't even need to change the type of pageToken in the API.

@ray-roestenburg-da ray-roestenburg-da Jun 15, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this exactly (out of band) and decided we should use the (record_time, entry_number) in page token

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix sorting in Vote history's infinite scroll

3 participants