-
Notifications
You must be signed in to change notification settings - Fork 3
Update project structure to align with node v18 and new async-locks #80
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
Conversation
We have a lot of test failures mostly related to concurrency, probably due to the new async-locks. Need to see if it due to similar problems as js-db. |
Ok one of the big things is because we no longer support This is actually a breaking change unfortunately. But we released it as 5.2.0. I think I just need to update all the usages of inode index and convert them to strings using |
Converting all the inode indexes to strings solved a bunch of concurrency issues. However there's another problem now... it seems to do with some encoding. Could it be the node v18 issue? |
There seems to be some problem with the database persistence. I wrote a file called However if I stop EFS then start it again, I should be able to read the same thing again. However I seem to get This is pretty strange, since the new DB shouldn't have this problem... but we have to see. |
This error is definitely due to the upgrade in |
Oh this error was due to We must repass back the same crypto object in when restarting the db. |
This is problem for EFS because when we do When we stop the EFS, we stop the DB, the DB must then must be started again with the same crypto object. We will need to keep track of the crypto object between restarts of the EFS. |
Another thing, is that the This is not quite correct. We need to only manage the lifecycle of the DB if the DB was created by EFS. If the EFS did not create the DB, the DB's lifecycle should be independent. |
Ok changing that management of the DB instance now means that in PK's side, when giving a DB to EFS, we must then consider that the DB's own lifecycle must be managed outside of the EFS. This is a breaking change @tegefaulkes. One thing I note is the complication of having to start the DB just to destroy things. This actually doesn't occur here in EFS because if it was our own encapsulated instance, the DB can just be destroyed after stopping and would clear all relevant state. Otherwise we just clear the inode manager state. However in PK, we end up restarting the DB only to delete things. I wonder if some of that can be simplified if you can just destroy the DB and have expect all the state to be cleared. The only thing would be domains that leave state outside the DB... and may require the DB to do something in order to destroy. Unless we encapsulate all state within our local Polykey node path and just destroy that and it should be fine... but that does break the composition abstraction. It just appears that the idea that stopping then destroying shouldn't actually stop the DB since destroying domains actually depend on the DB instance running. Still not sure how to elegantly express this. |
Ok that fixed everything but now broke some of the chroot tests.
I think that may have relied on the DB lifecycle. |
The solution involved a weird trick from https://stackoverflow.com/a/64638986/582917. The constructor parameter type didn't work. But the type assertion did: const efsChrooted = new (this.constructor as new (...params: ConstructorParameters<typeof EncryptedFS>) => this)({
db: this.db,
iNodeMgr: this.iNodeMgr,
fdMgr: this.fdMgr,
rootIno: target,
blockSize: this.blockSize,
umask: this.umask,
logger: this.logger,
chroots: this.chroots,
chrootParent: this,
}); This is partly due to the experimental decorator situation in swc. Remember we had to use In this case it also required a type assertion on the actual constructor function type. I remember TSC didn't have this problem, but our tests now use SWC so this becomes an issue. |
d852952
to
25bac62
Compare
* updated `@matrixai/db` to 5.2.0 and `@matrixai/async-locks` to 4.0.0 * changed how EFS handles non-encapsulated DB lifecycles, it no longer manages injected DB instances * due to `swc` testing, changed to using `new this.constructor` over `new EncryptedFS` for `chroot` * changed to node v18 * changed to using `npm root` over `npm bin`
25bac62
to
b0ad946
Compare
Tasks 2. and 3. are going to staging. |
Description
This is following up with the updates with respect to node v18 and macos updates and
npm root
overnpm bin
.Issues Fixed
Tasks
js-db
andjs-async-locks
Final checklist