Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with indexes not properly updating in SDKs if no primary_key is specified #1733

Open
cloutiertyler opened this issue Sep 23, 2024 · 1 comment

Comments

@cloutiertyler
Copy link
Contributor

cloutiertyler commented Sep 23, 2024

From @SteveBoytsun:

It took me 2+ hours of torturing stdb, but I finally found a repro. Here are the steps:

  1. Define a table with unique column and a non-unique column (NO PK)
  2. Insert some values into said table
  3. Subscribe to that table
  4. Call a reducer that modifies non-unique values
  5. !Profit
    The issue happens because
  • Client SDK doesn't treat these changes as updates - instead they're delete+insert
  • Due to how we calculate diffs on the client, inserts are performed before deletes, which means that indexes are updated and subsequently deleted
    A workaround for that issue is to always have a PK. As for proper fix, I would recommend making sure that we do all deletes BEFORE inserts.

Incidentally, this is part of what I did last week to optimize chunk crossing in BitCraft. I discussed it with @cloutiertyler as purely an optimization, and he suggested sitting on it until after 0.12, but since there's a bug that can be fixed by those changes it may be worth re-evaluating when to do it. Changes are ~2.5/5 on complexity scale (and it's not trivial to separate them from the rest of optimizations), but they are already somewhat-tested in BitCraft.

Note: this may also be an issue in other client SDKs

@cloutiertyler
Copy link
Contributor Author

Downgrading to a P2 under the theory that new users will not run into this.

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

No branches or pull requests

1 participant