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

Implement YStore versioning #48

Merged
merged 1 commit into from
Nov 23, 2022
Merged

Conversation

davidbrochart
Copy link
Collaborator

Closes #43.

@davidbrochart davidbrochart force-pushed the version branch 2 times, most recently from cd02839 to 8ea0486 Compare November 21, 2022 10:52
Copy link
Collaborator

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

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

Thanks David

version = int(await f.readline())
if version != self.version:
raise YDocVersionMismatch(
f"YStore version mismatch: got '{version}' in file, but supported is '{self.version}'"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we automatically remove the store or add a sentence like: You can remove file '...' to fix this error - WARNING it will erase the documents edition history.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think removing the DB is too much, as the user could decide to still use it with another ypy-websocket version.
But it's true that it would be nice to not error out, as most of the time users want things to just work. What about moving the out-of-date DB to a new name, like .jupyter_ystore(1).db, .jupyter_ystore(2).db, etc.?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not a fan of renaming for two reasons:

  • It is gonna fill the user disk with files that are useless for most users
  • It does not solve the trouble of an user that use another ypy-websocket as it may even enter a recursive loop of database renaming.

That said what about making the version part of the naming?

Let's ping folks to get idea @afshin @ellisonbg

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  • It is gonna fill the user disk with files that are useless for most users

We could move it to the OS's temporary directory.

  • it may even enter a recursive loop of database renaming.

I don't get that part, why would it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

| It is gonna fill the user disk with files that are useless for most users
We could move it to the OS's temporary directory.

You will get into troubles for user spawning multiple Jupyter servers from multiple folders (a la VS Code).

it may even enter a recursive loop of database renaming.

if the user has two environments (envA and envB) that uses two different versions of the store, the user could end up in the following scenario:

  1. Work with envA -> .jupyter_ystore.db is created
  2. Stop envA
  3. Work with envB -> .jupyter_ystore.db is renamed .juypter_ystore(1).db and new db is created
  4. Stop envB
  5. Work back with envA -> .jupyter_ystore.db is renamed and a new deb is created
  6. ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the explanation, then including the version in the name would work indeed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thinking about it, making the version part of the file name is also problematic, as we now have to ensure that the version in the file name and the version in the database match.

cursor = await db.execute("pragma user_version")
version = (await cursor.fetchone())[0]
if version != self.version:
raise YDocVersionMismatch(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question here.

@@ -160,7 +195,7 @@ async def read(self) -> AsyncIterator[Tuple[bytes, bytes]]: # type: ignore
raise YDocNotFound

async def write(self, data: bytes) -> None:
await self.db_created.wait()
await self.db_initialized
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not related but should we invert line 198 and line 199. The rational behind it is that the metadata is generating a timestamp. If the initialization takes some time, the timestamp will shift a bit. It may be more interesting to get the timestamp matching the write execution request.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The metadata that we get from get_metadata() is generic, even though it is indeed a timestamp in jupyter-server-ydoc currently.
I think you are referring to the timestamp column. But anyway, that's a good point and I think we should move both before waiting for the DB to be ready, as they are independent.

@davidbrochart davidbrochart force-pushed the version branch 9 times, most recently from 39b9fe0 to b1cae10 Compare November 23, 2022 11:07
@davidbrochart
Copy link
Collaborator Author

@fcollonval I'm going to merge this.
Backing-up out-of-date ystores seems to be the safest thing to do. We can improve it in the future with other strategies.

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.

Add schema version
2 participants