Coder Social home page Coder Social logo

ROWID stability about axiom HOT 36 CLOSED

twisted avatar twisted commented on June 7, 2024
ROWID stability

from axiom.

Comments (36)

mithrandi avatar mithrandi commented on June 7, 2024 1

https://pypi.org/project/axiom/0.8.0rc1/ c/o https://github.com/twisted/axiom/blob/0.8.0rc1/.github/workflows/publish.yml

from axiom.

glyph avatar glyph commented on June 7, 2024

There is an evil incantation which will make a quick upgrade possible.

http://nbviewer.ipython.org/gist/glyph/2f3fd023b273e53c84fc

from axiom.

lvh avatar lvh commented on June 7, 2024

does the evil mad scientist cackle

from axiom.

lvh avatar lvh commented on June 7, 2024

It might be a good idea to ask drh about this specifically. I'm reasonably sure it'll work consistently, but he's the only authority on the subject.

Also, did you test the case where VACUUM does in fact work correctly now, just in case there's something special about ROWID we're forgetting about?

from axiom.

glyph avatar glyph commented on June 7, 2024

Here's a version of the notebook that does a VACUUM, names the oid column differently, bumps the schema version, and re-opens the store. http://nbviewer.ipython.org/urls/glyph.im/blob/2C4F608E-26FC-4688-8432-C19C33171FBF.ipynb

from axiom.

mithrandi avatar mithrandi commented on June 7, 2024

I think you need to delete a row that was not the last row added to the table in order to really demonstrate that VACUUM is behaving correctly.

from axiom.

glyph avatar glyph commented on June 7, 2024

@mithrandi - feel free to make a hacked up version of the notebook :). Maybe it's time to start actually having a branch / PR for this somewhere though?

from axiom.

glyph avatar glyph commented on June 7, 2024

@mithrandi - also, some very basic experiments I did showed OIDs changing if there were more than 10 rows or so in the database - was I doing those wrong?

from axiom.

mithrandi avatar mithrandi commented on June 7, 2024

So I played around a bit, with the following results:

A version of your example which demonstrates ROWID stability after deleting some rows before VACUUMing.

A further modified version which demonstrates how ROWIDs are not stable without making the schema change.

So, I'm fairly satisfied with these empirical results, but I would still love to hear from drh whether this can be expected to work reliably.

from axiom.

glyph avatar glyph commented on June 7, 2024

Is drh on github? @\drh isn't him, but it would be neat to just tag him in :)

from axiom.

mithrandi avatar mithrandi commented on June 7, 2024

Posted about this on the sqlite-users list; sadly, drh seems to think it doesn't work.

EDIT: Fixed the sqlite-users archive link, which apparently changed(?)

from axiom.

ldanielburr avatar ldanielburr commented on June 7, 2024

Just a comment from the peanut gallery, but what's wrong with adding a migration that does what drh suggested?

BEGIN;
ALTER TABLE some_table_name RENAME TO temp_name;
CREATE TABLE some_table_name(oid INTEGER PRIMARY KEY, ....);
INSERT INTO some_table_name SELECT oid, * FROM temp_name;
DROP TABLE temp_name;
COMMIT;

from axiom.

glyph avatar glyph commented on June 7, 2024

@ldanielburr Yes, we'll have to do that. In fact it could be expressed as even less work; we don't do ALTER TABLE anywhere, and all our migrations already copy code from old tables to new tables, deleting as they go.

The problem is in detecting that the change needs to happen. Right now we have only a single axis of migration: up through different versions of classes; this version is encoded in the table name. To implement this, we need a meta-schema version; one that indicates what sqlite3 features are available, which means we need a different way of encoding that information; either by adding features to the table-naming convention or by putting it somewhere else in the database. Not impossible, just something we were hoping to avoid with the simple ALTER TABLE hack.

from axiom.

mithrandi avatar mithrandi commented on June 7, 2024

So I'm looking at fixing this issue again. When opening a store, we can check whether the system tables (axiom_objects etc.) have an explicit PK or not. We also know which columns are in each item type's schema, so we can check for the presence of a storeID column there. Coupled with ignoring storeID in the schema mismatch check this would allow us to handle existing stores.

New types / versions / tables could always be created with the storeID column, and axiomatic upgrade could upgrade the system tables as well as even upgrading existing types without bumping the schema version. There could also be a flag to auto-upgrade system tables on store open.

from axiom.

mithrandi avatar mithrandi commented on June 7, 2024

Okay, I have a PR up; reviews greatly appreciated.

from axiom.

glyph avatar glyph commented on June 7, 2024

Thank you, so much, everybody who worked on this. It's weirdly kind of emotional seeing a bug that was really bothering me so much over a decade ago actually, finally get fixed.

from axiom.

mithrandi avatar mithrandi commented on June 7, 2024

It was pretty satisfying working on the fix too! Although I think we still need to roll a new release?

from axiom.

glyph avatar glyph commented on June 7, 2024

@ldanielburr are you interested in being the release manager? Happy to add you on PyPI.

from axiom.

ldanielburr avatar ldanielburr commented on June 7, 2024

@glyph, please point me at the release management docs, and I'll take a look. I don't want to promise anything yet, but I will commit to reviewing the release management process docs and giving you a firm answer :)

from axiom.

glyph avatar glyph commented on June 7, 2024

@ldanielburr It's really just

$ python setup.py sdist bdist_wheel
$ twine upload dist/*

what's your username on PyPI? I'll give you upload access and you can do this.

from axiom.

mithrandi avatar mithrandi commented on June 7, 2024

Ideally we would update NEWS.txt with info about the ROWID change since it's a big one and eg. may make axiomatic upgrade unexpectedly take a long time. You'll also need to bump axiom/_version.py

from axiom.

ldanielburr avatar ldanielburr commented on June 7, 2024

@glyph, my PyPI username is "somenamenobodyelsehas".

from axiom.

ldanielburr avatar ldanielburr commented on June 7, 2024

@mithrandi, agreed, there should be a NEWS.txt, version bump, etc.

from axiom.

glyph avatar glyph commented on June 7, 2024

@ldanielburr You now have upload access to Axiom.

from axiom.

ldanielburr avatar ldanielburr commented on June 7, 2024

@glyph thanks for the PyPI access. I will commit to getting the newsfile and version updates up for a PR sometime next week, and then the upload to PyPI.

from axiom.

ldanielburr avatar ldanielburr commented on June 7, 2024

Ok, so I didn't get to this task yet. Just updating this thread to let people know I still intend to make a release.

from axiom.

glyph avatar glyph commented on June 7, 2024

@ldanielburr we all know how it goes with open source :-). Thanks for the update.

from axiom.

glyph avatar glyph commented on June 7, 2024

@ldanielburr soooooo… how’s it going?

from axiom.

ldanielburr avatar ldanielburr commented on June 7, 2024

@glyph, it is going like pride before a fall ;) Sorry I haven't gotten to this yet. Holiday break is coming up in a few weeks, and I'll try to give this a go in December.

from axiom.

glyph avatar glyph commented on June 7, 2024

@ldanielburr 🤞

from axiom.

glyph avatar glyph commented on June 7, 2024

How do we promote this to “not an RC”?

from axiom.

mithrandi avatar mithrandi commented on June 7, 2024

Basically just create a release on GitHub with a not-an-RC version number (ie. 0.8.0); the release artifacts will then be built and published to PyPI automatically. My plan is to do the final release in a few days just to allow a little testing if anyone wants.

from axiom.

glyph avatar glyph commented on June 7, 2024

All right, happy to let that play out.

from axiom.

mithrandi avatar mithrandi commented on June 7, 2024

Problems: #112

from axiom.

mithrandi avatar mithrandi commented on June 7, 2024

https://pypi.org/project/axiom/0.8.0/

from axiom.

glyph avatar glyph commented on June 7, 2024

Amazing. At long, long last :)

from axiom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.