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 IndexedDB. #6963

Open
Ms2ger opened this issue Aug 4, 2015 · 40 comments
Open

Implement IndexedDB. #6963

Ms2ger opened this issue Aug 4, 2015 · 40 comments
Labels
A-content/dom Interacting with the DOM from web content C-assigned There is someone working on resolving the issue E-very-complex Very difficult. Do not attempt without significant relevant experience and motivation. I-enhancement No impact; the issue is a missing or proposed feature.

Comments

@Ms2ger
Copy link
Contributor

Ms2ger commented Aug 4, 2015

(Just filing as a placeholder.)

@Ms2ger Ms2ger added A-content/dom Interacting with the DOM from web content E-very-complex Very difficult. Do not attempt without significant relevant experience and motivation. I-enhancement No impact; the issue is a missing or proposed feature. labels Aug 4, 2015
@Manishearth Manishearth self-assigned this Aug 9, 2015
@farodin91
Copy link
Contributor

I like to work on it.
Some Questions before a start to work.
Can help me someone, who work on it in firefox?
I need to create many WebIDLs, is possible to create a folder like "indexed". To add all files inside this folder, for example http://mxr.mozilla.org/mozilla-central/source/dom/

@Manishearth
Copy link
Member

cc @nox

Note that this is a pretty large project.

To start, you'll need to pick a backend and write Rust bindings for it. We were thinking SQLite4 or a LevelDB fork, probably the former.

@jdm
Copy link
Member

jdm commented Oct 26, 2015

@farodin91 We don't support subdirectories in dom/ yet; I don't think it's worth blocking on that.

@Manishearth
Copy link
Member

@jdm Technically we just need to use reexports and it will work fine.

@nox
Copy link
Contributor

nox commented Oct 26, 2015

@Manishearth SQLite 4 suffers from a complete lack of bindings and my days are unfortunately made of 24 hours like everyone. :(

@farodin91
Copy link
Contributor

@Manishearth I can start with building an rust api for SQLite 4.

@jdm
Copy link
Member

jdm commented Oct 26, 2015

That sounds valuable :)

@farodin91
Copy link
Contributor

I like to write a binding in rust for SQLite. Any prefer which lib to use for it?

@Manishearth
Copy link
Member

@farodin91
Copy link
Contributor

This is my first time to create an rust binding. Is there a small example for it

@jdm
Copy link
Member

jdm commented Oct 26, 2015

https://doc.rust-lang.org/book/ffi.html is a good start.

@nox
Copy link
Contributor

nox commented Oct 26, 2015

Please note that SQLite resides in a Fossil repository. I had started writing bindings for them, but it's very primitive for now. I can push that somewhere this week if you want.

@farodin91
Copy link
Contributor

I create an repo for this. I can start to work on it this week.
Thank you.

@farodin91
Copy link
Contributor

@nox Any update on pushing the in my repo?

@nox
Copy link
Contributor

nox commented Oct 31, 2015

Sorry things were a bit hectic for me this week.

@farodin91
Copy link
Contributor

No problem

@farodin91
Copy link
Contributor

I start work on it https://github.com/farodin91/sqlite-rs. But currently my build script doesn't work to build sqlite4 on linux. I have no idea.

@farodin91
Copy link
Contributor

Any update to pushing in my repo?

@farodin91
Copy link
Contributor

@nox Any updates?
It is also possible to use LevelDB with lib https://github.com/skade/leveldb.

@KiChjang
Copy link
Contributor

I'm picking this up. Will start by writing SQLite 4 Rust bindings.

@KiChjang KiChjang self-assigned this Apr 17, 2016
@KiChjang KiChjang added the C-assigned There is someone working on resolving the issue label Apr 17, 2016
@amarant
Copy link
Contributor

amarant commented Apr 17, 2016

It seems there is no commit in SQLite 4 since 2015-08-15 and never had an official release, doesn't levelDB seems more mature (already used for indexeddb in Chrome) ?

@Manishearth
Copy link
Member

That might just be because they intend SQLite 4 to be stable. SQLite is under active development, see https://www.sqlite.org/src/timeline . That might be SQLite 3, but I think the codebase is mostly shared.

@nox
Copy link
Contributor

nox commented Jul 25, 2016

I'm going to use SQLite3.

For database storage, we have two ways:

  • We can do like Gecko, and create a SQLite database per IndexedDB database.
    • 👍 We can open the database with any SQLite tool and we have everything at once.
    • 👎 We will never have concurrent transactions when one of them is a write transaction.


  • We can create one SQLite database per IndexedDB object store.
    • 👍 By using ATTACH, we can lock on a per-object store basis and still do transactions that encompass multiple object stores.
    • 👎 It becomes a bit harder to see everything from an IndexedDB database at once with SQLite tools.


For indices, we also have two ways, the old Gecko way and a very fancy way that I would like to experiment with:

  • We can do like Gecko, and have SQLite tables for IndexedDB indices. In Gecko elements from all object stores are stored in a single table and all the entries in all indices are also stored in two tables, one with a PK for unique indices, and another one for non-unique indices.
    • 👍 We can open the database with any SQLite tool and we have everything at once.
    • 👎 It duplicates a lot of data for each index.


  • We can do like the json1 SQLite extension and implement and document a "Serialised Structure Clone" binary subtype in SQLite, and then implement a function to extract a key path from this format (similar to the json function in json1). We can then use that method to create an index on an expression for each IndexedDB index we want. We can make that function return NULL when the key path is not found, and use a partial index to ignore such values.
    • 👍 It is quite cool as a show case of what fancy things we do.
    • 👍 We can enforce that the things we put in that database are actually serialised structure clones.
    • 👍 It makes IndexedDB indices piggyback SQLite indices.
    • 👎 It requires custom pluggable code into SQLite and these APIs aren't bound in the existing SQLite crates.


Some interesting links:

@nox
Copy link
Contributor

nox commented Jul 25, 2016

This would also require a reimplementation of the serialised structured clone format described here (or something similar to it that we can store and introspect directly from SQLite).

@nox
Copy link
Contributor

nox commented Jul 25, 2016

We can't use ATTACH for my first idea because its documentation states that it's not really robust when faced with crashes.

@KiChjang KiChjang removed their assignment Aug 1, 2016
@nox
Copy link
Contributor

nox commented Aug 18, 2016

There are various things necessary on the Servo side, at least these three things:

@nox nox removed their assignment Jan 20, 2017
@nox nox removed the C-assigned There is someone working on resolving the issue label Jan 20, 2017
@ferjm
Copy link
Contributor

ferjm commented Mar 23, 2017

Blocks #13942

@tigercosmos
Copy link
Contributor

hi @nox, do you know if the issue has advanced any further? Thanks!

@jdm
Copy link
Member

jdm commented Jan 10, 2019

It has not.

@rasviitanen
Copy link
Contributor

I am looking for a new task, and I thought this one was interessting. I have a few questions before I am comfortable claiming this issue.

As I understand it, IndexedDB should be implemented using a WAL to favor performance. This decision was taken in Gecko, and is seen in Chrome/IE. See change here. Despite the new 3.0 specification states it to be durable.

Since SQLite4 never got released, and SQLite3 not being the obvious choice, perhaps RocksDB is a valid option?

It is wildly used, and seems to fit indexeddb and servo quite well, i.e. fast and concurrent; embedded KV store.
https://rocksdb.org/
https://rocksdb.org/docs/support/faq.html

It also has great rust bindings through rust-rocksdb used by e.g. TiDB. This would make it a lot easier to get a working IndexedDB.

Thoughts?

@jdm
Copy link
Member

jdm commented Sep 6, 2019

Seems like it's worth a shot!

@rasviitanen
Copy link
Contributor

@highfive: assign me

@highfive highfive added the C-assigned There is someone working on resolving the issue label Sep 6, 2019
@highfive
Copy link

highfive commented Sep 6, 2019

Hey @rasviitanen! Thanks for your interest in working on this issue. It's now assigned to you!

@asutherland
Copy link

asutherland commented Sep 6, 2019

Just to provide some context on SQLite and other storage choices as they're being used in Gecko/Firefox:

Re: SQLite

  • SQLite 4 was an experiment and the fancy bits (WITHOUT ROWID in particular, which allows for tables to be effectively maintain the lexical row ordering directly without indirecting through primary keys) are now in SQLite 3.
  • Firefox is overhauling how we implement storage as it relates to PrivateBrowsing. Previously implementations had to be in-memory only and data would never touch disk. We're now moving to store data on disk in an encrypted form with the keys never persisted. We delete the storage at the end of the private browsing session. In the event of a crash, the data is encrypted and then only subject to analysis of what's on disk. SQLite's VFS layer makes this not too difficult, and SQLite's page-centric storage model potentially helps with the analysis-at-rest concern. (I haven't thought too much about how that would compare with log-structured-merge independent files on disk.)
  • Mozilla Corporation is a SQLite consortium member which gets us insanely professional levels of support in terms of investigations of problems we're experiencing involving SQLite, guidance, etc. They take writing safe C seriously and have an incredibly comprehensive test corpus.

Re: other options:

  • https://github.com/mozilla/rkv has been landed in Gecko as a rust layer on top of the LMDB engine. I think rkv/LMDB sounded more promising than it's turned out to be, especially with there being limitations like 512-byte key limits, but it sounds like the Browser Architecture Group team may be serious about keeping this around.

Re: selfish concerns on my part ;)

  • The existing Gecko IndexedDB implementation is a lot of fairly grungy C++ and we will be looking longer term to replace it with a rust implementation. It's not clear that Gecko could justify the increase in binary size of the RocksDB engine, so selfishly it would be nice if Servo used a databse implementation compatible with what Gecko is already using.
    • I think there may be in-tree https://github.com/jgallagher/rusqlite users already? But honestly, based on a quick skim of diesel, its ORM-ish mapping potentially seems like it allows for less accidental mismatches when binding statements.
  • That said, the Gecko implementation may have some architectural considerations that don't make sense for an initial servo IndexedDB implementation. Specifically, with fisssion potentially consolidating origins into a single process (but potentially also not), we may want to shift where we store the canonical state and perform caching. Especially for API's like https://github.com/WICG/kv-storage that build on IndexedDB and can potentially very performance-conscious as they're competing against localStorage.

bors-servo pushed a commit that referenced this issue Dec 9, 2019
Basic IndexedDB Functionality

<!-- Please describe your changes on the following line: -->
This PR consists of basic functionality for `IndexedDB`.
The database engine used is `Rkv`, and might not be the most optimal engine to use, so I created a *pluggable* engine. This makes it easy to change for eventual benchmarks etc.
Recently, `Rkv` has raised [warnings](https://github.com/mozilla/rkv) for using it in production, and the plan seems to be to change the backend to sqlite instead. If we expect that IndexedDB is finished after the issues in `Rkv` has been fixed, we should be able to use it after all. The ergonomics of Rkv is really good, and suits IndexedDB quite well.

What works:
* Basic Open
* Basic Put
* Basic Add
* Basic Get
* Basic Remove

Some things that don't work:
* Key generators
* Key ranges
* Aborting/Reverting transactions, including upgrades
* Closing/Removing a store/db
* Injection of keys
* Proper scheduling of transactions (they are started immediately atm)
* IDBIndex
* IDBCursor
* Manually committing transactions
* Some Error handling is missing
* ...  lots of other stuff

Implementation details worth noting:
* Transactions run in a custom thread pool. `read` and `write` transactions use the same pool, which in the future probably should be separate.
* IndexedDB is disabled by default, as it has a lot of troubles

I am making this PR pre-prematurely, as it is part of a course I take in school (and it's soon due date), so I would be very happy if *reviews can be done rather quickly*.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix (PARTLY) #6963

<!-- Either: -->
- [X] These changes do not require tests because:
There are many WebIDL tests that we can run to test the code. I was not able to run wpt tests with logging on windows, so test metadata is currently missing. I have, however, run some tests manually, and we can expect some of the tests to `PASS`.
Some examples of passing tests:
`idbobjectstore_put.htm`
`idbobjectstore_put2.htm`
`idbobjectstore_put3.htm`
`idbobjectstore_put5.htm`
`idbobjectstore_put7.htm`
`idbobjectstore_put9.htm`,
`idbobjectstore_put10.htm`
`idbobjectstore_put11.htm`
...
`idbfactory_open.htm`
`idbfactory_open2.htm`
`idbfactory_open3.htm`
`idbfactory_open4.htm`
...

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
bors-servo pushed a commit that referenced this issue Dec 9, 2019
Basic IndexedDB Functionality

<!-- Please describe your changes on the following line: -->
This PR consists of basic functionality for `IndexedDB`.
The database engine used is `Rkv`, and might not be the most optimal engine to use, so I created a *pluggable* engine. This makes it easy to change for eventual benchmarks etc.
Recently, `Rkv` has raised [warnings](https://github.com/mozilla/rkv) for using it in production, and the plan seems to be to change the backend to sqlite instead. If we expect that IndexedDB is finished after the issues in `Rkv` has been fixed, we should be able to use it after all. The ergonomics of Rkv is really good, and suits IndexedDB quite well.

What works:
* Basic Open
* Basic Put
* Basic Add
* Basic Get
* Basic Remove

Some things that don't work:
* Key generators
* Key ranges
* Aborting/Reverting transactions, including upgrades
* Closing/Removing a store/db
* Injection of keys
* Proper scheduling of transactions (they are started immediately atm)
* IDBIndex
* IDBCursor
* Manually committing transactions
* Some Error handling is missing
* ...  lots of other stuff

Implementation details worth noting:
* Transactions run in a custom thread pool. `read` and `write` transactions use the same pool, which in the future probably should be separate.
* IndexedDB is disabled by default, as it has a lot of troubles

I am making this PR pre-prematurely, as it is part of a course I take in school (and it's soon due date), so I would be very happy if *reviews can be done rather quickly*.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix (PARTLY) #6963

<!-- Either: -->
- [X] These changes do not require tests because:
There are many WebIDL tests that we can run to test the code. I was not able to run wpt tests with logging on windows, so test metadata is currently missing. I have, however, run some tests manually, and we can expect some of the tests to `PASS`.
Some examples of passing tests:
`idbobjectstore_put.htm`
`idbobjectstore_put2.htm`
`idbobjectstore_put3.htm`
`idbobjectstore_put5.htm`
`idbobjectstore_put7.htm`
`idbobjectstore_put9.htm`,
`idbobjectstore_put10.htm`
`idbobjectstore_put11.htm`
...
`idbfactory_open.htm`
`idbfactory_open2.htm`
`idbfactory_open3.htm`
`idbfactory_open4.htm`
...

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
bors-servo pushed a commit that referenced this issue Dec 12, 2019
Basic IndexedDB Functionality

<!-- Please describe your changes on the following line: -->
This PR consists of basic functionality for `IndexedDB`.
The database engine used is `Rkv`, and might not be the most optimal engine to use, so I created a *pluggable* engine. This makes it easy to change for eventual benchmarks etc.
Recently, `Rkv` has raised [warnings](https://github.com/mozilla/rkv) for using it in production, and the plan seems to be to change the backend to sqlite instead. If we expect that IndexedDB is finished after the issues in `Rkv` has been fixed, we should be able to use it after all. The ergonomics of Rkv is really good, and suits IndexedDB quite well.

What works:
* Basic Open
* Basic Put
* Basic Add
* Basic Get
* Basic Remove

Some things that don't work:
* Key generators
* Key ranges
* Aborting/Reverting transactions, including upgrades
* Closing/Removing a store/db
* Injection of keys
* Proper scheduling of transactions (they are started immediately atm)
* IDBIndex
* IDBCursor
* Manually committing transactions
* Some Error handling is missing
* ...  lots of other stuff

Implementation details worth noting:
* Transactions run in a custom thread pool. `read` and `write` transactions use the same pool, which in the future probably should be separate.
* IndexedDB is disabled by default, as it has a lot of troubles

I am making this PR pre-prematurely, as it is part of a course I take in school (and it's soon due date), so I would be very happy if *reviews can be done rather quickly*.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix (PARTLY) #6963

<!-- Either: -->
- [X] These changes do not require tests because:
There are many WebIDL tests that we can run to test the code. I was not able to run wpt tests with logging on windows, so test metadata is currently missing. I have, however, run some tests manually, and we can expect some of the tests to `PASS`.
Some examples of passing tests:
`idbobjectstore_put.htm`
`idbobjectstore_put2.htm`
`idbobjectstore_put3.htm`
`idbobjectstore_put5.htm`
`idbobjectstore_put7.htm`
`idbobjectstore_put9.htm`,
`idbobjectstore_put10.htm`
`idbobjectstore_put11.htm`
...
`idbfactory_open.htm`
`idbfactory_open2.htm`
`idbfactory_open3.htm`
`idbfactory_open4.htm`
...

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
bors-servo pushed a commit that referenced this issue Dec 12, 2019
Basic IndexedDB Functionality

<!-- Please describe your changes on the following line: -->
This PR consists of basic functionality for `IndexedDB`.
The database engine used is `Rkv`, and might not be the most optimal engine to use, so I created a *pluggable* engine. This makes it easy to change for eventual benchmarks etc.
Recently, `Rkv` has raised [warnings](https://github.com/mozilla/rkv) for using it in production, and the plan seems to be to change the backend to sqlite instead. If we expect that IndexedDB is finished after the issues in `Rkv` has been fixed, we should be able to use it after all. The ergonomics of Rkv is really good, and suits IndexedDB quite well.

What works:
* Basic Open
* Basic Put
* Basic Add
* Basic Get
* Basic Remove

Some things that don't work:
* Key generators
* Key ranges
* Aborting/Reverting transactions, including upgrades
* Closing/Removing a store/db
* Injection of keys
* Proper scheduling of transactions (they are started immediately atm)
* IDBIndex
* IDBCursor
* Manually committing transactions
* Some Error handling is missing
* ...  lots of other stuff

Implementation details worth noting:
* Transactions run in a custom thread pool. `read` and `write` transactions use the same pool, which in the future probably should be separate.
* IndexedDB is disabled by default, as it has a lot of troubles

I am making this PR pre-prematurely, as it is part of a course I take in school (and it's soon due date), so I would be very happy if *reviews can be done rather quickly*.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix (PARTLY) #6963

<!-- Either: -->
- [X] These changes do not require tests because:
There are many WebIDL tests that we can run to test the code. I was not able to run wpt tests with logging on windows, so test metadata is currently missing. I have, however, run some tests manually, and we can expect some of the tests to `PASS`.
Some examples of passing tests:
`idbobjectstore_put.htm`
`idbobjectstore_put2.htm`
`idbobjectstore_put3.htm`
`idbobjectstore_put5.htm`
`idbobjectstore_put7.htm`
`idbobjectstore_put9.htm`,
`idbobjectstore_put10.htm`
`idbobjectstore_put11.htm`
...
`idbfactory_open.htm`
`idbfactory_open2.htm`
`idbfactory_open3.htm`
`idbfactory_open4.htm`
...

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
bors-servo pushed a commit that referenced this issue Dec 12, 2019
Basic IndexedDB Functionality

<!-- Please describe your changes on the following line: -->
This PR consists of basic functionality for `IndexedDB`.
The database engine used is `Rkv`, and might not be the most optimal engine to use, so I created a *pluggable* engine. This makes it easy to change for eventual benchmarks etc.
Recently, `Rkv` has raised [warnings](https://github.com/mozilla/rkv) for using it in production, and the plan seems to be to change the backend to sqlite instead. If we expect that IndexedDB is finished after the issues in `Rkv` has been fixed, we should be able to use it after all. The ergonomics of Rkv is really good, and suits IndexedDB quite well.

What works:
* Basic Open
* Basic Put
* Basic Add
* Basic Get
* Basic Remove

Some things that don't work:
* Key generators
* Key ranges
* Aborting/Reverting transactions, including upgrades
* Closing/Removing a store/db
* Injection of keys
* Proper scheduling of transactions (they are started immediately atm)
* IDBIndex
* IDBCursor
* Manually committing transactions
* Some Error handling is missing
* ...  lots of other stuff

Implementation details worth noting:
* Transactions run in a custom thread pool. `read` and `write` transactions use the same pool, which in the future probably should be separate.
* IndexedDB is disabled by default, as it has a lot of troubles

I am making this PR pre-prematurely, as it is part of a course I take in school (and it's soon due date), so I would be very happy if *reviews can be done rather quickly*.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix (PARTLY) #6963

<!-- Either: -->
- [X] These changes do not require tests because:
There are many WebIDL tests that we can run to test the code. I was not able to run wpt tests with logging on windows, so test metadata is currently missing. I have, however, run some tests manually, and we can expect some of the tests to `PASS`.
Some examples of passing tests:
`idbobjectstore_put.htm`
`idbobjectstore_put2.htm`
`idbobjectstore_put3.htm`
`idbobjectstore_put5.htm`
`idbobjectstore_put7.htm`
`idbobjectstore_put9.htm`,
`idbobjectstore_put10.htm`
`idbobjectstore_put11.htm`
...
`idbfactory_open.htm`
`idbfactory_open2.htm`
`idbfactory_open3.htm`
`idbfactory_open4.htm`
...

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
bors-servo pushed a commit that referenced this issue Dec 13, 2019
Basic IndexedDB Functionality

<!-- Please describe your changes on the following line: -->
This PR consists of basic functionality for `IndexedDB`.
The database engine used is `Rkv`, and might not be the most optimal engine to use, so I created a *pluggable* engine. This makes it easy to change for eventual benchmarks etc.
Recently, `Rkv` has raised [warnings](https://github.com/mozilla/rkv) for using it in production, and the plan seems to be to change the backend to sqlite instead. If we expect that IndexedDB is finished after the issues in `Rkv` has been fixed, we should be able to use it after all. The ergonomics of Rkv is really good, and suits IndexedDB quite well.

What works:
* Basic Open
* Basic Put
* Basic Add
* Basic Get
* Basic Remove

Some things that don't work:
* Key generators
* Key ranges
* Aborting/Reverting transactions, including upgrades
* Closing/Removing a store/db
* Injection of keys
* Proper scheduling of transactions (they are started immediately atm)
* IDBIndex
* IDBCursor
* Manually committing transactions
* Some Error handling is missing
* ...  lots of other stuff

Implementation details worth noting:
* Transactions run in a custom thread pool. `read` and `write` transactions use the same pool, which in the future probably should be separate.
* IndexedDB is disabled by default, as it has a lot of troubles

I am making this PR pre-prematurely, as it is part of a course I take in school (and it's soon due date), so I would be very happy if *reviews can be done rather quickly*.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix (PARTLY) #6963

<!-- Either: -->
- [X] These changes do not require tests because:
There are many WebIDL tests that we can run to test the code. I was not able to run wpt tests with logging on windows, so test metadata is currently missing. I have, however, run some tests manually, and we can expect some of the tests to `PASS`.
Some examples of passing tests:
`idbobjectstore_put.htm`
`idbobjectstore_put2.htm`
`idbobjectstore_put3.htm`
`idbobjectstore_put5.htm`
`idbobjectstore_put7.htm`
`idbobjectstore_put9.htm`,
`idbobjectstore_put10.htm`
`idbobjectstore_put11.htm`
...
`idbfactory_open.htm`
`idbfactory_open2.htm`
`idbfactory_open3.htm`
`idbfactory_open4.htm`
...

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
bors-servo pushed a commit that referenced this issue Dec 17, 2019
Basic IndexedDB Functionality

<!-- Please describe your changes on the following line: -->
This PR consists of basic functionality for `IndexedDB`.
The database engine used is `Rkv`, and might not be the most optimal engine to use, so I created a *pluggable* engine. This makes it easy to change for eventual benchmarks etc.
Recently, `Rkv` has raised [warnings](https://github.com/mozilla/rkv) for using it in production, and the plan seems to be to change the backend to sqlite instead. If we expect that IndexedDB is finished after the issues in `Rkv` has been fixed, we should be able to use it after all. The ergonomics of Rkv is really good, and suits IndexedDB quite well.

What works:
* Basic Open
* Basic Put
* Basic Add
* Basic Get
* Basic Remove

Some things that don't work:
* Key generators
* Key ranges
* Aborting/Reverting transactions, including upgrades
* Closing/Removing a store/db
* Injection of keys
* Proper scheduling of transactions (they are started immediately atm)
* IDBIndex
* IDBCursor
* Manually committing transactions
* Some Error handling is missing
* ...  lots of other stuff

Implementation details worth noting:
* Transactions run in a custom thread pool. `read` and `write` transactions use the same pool, which in the future probably should be separate.
* IndexedDB is disabled by default, as it has a lot of troubles

I am making this PR pre-prematurely, as it is part of a course I take in school (and it's soon due date), so I would be very happy if *reviews can be done rather quickly*.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix (PARTLY) #6963

<!-- Either: -->
- [X] These changes do not require tests because:
There are many WebIDL tests that we can run to test the code. I was not able to run wpt tests with logging on windows, so test metadata is currently missing. I have, however, run some tests manually, and we can expect some of the tests to `PASS`.
Some examples of passing tests:
`idbobjectstore_put.htm`
`idbobjectstore_put2.htm`
`idbobjectstore_put3.htm`
`idbobjectstore_put5.htm`
`idbobjectstore_put7.htm`
`idbobjectstore_put9.htm`,
`idbobjectstore_put10.htm`
`idbobjectstore_put11.htm`
...
`idbfactory_open.htm`
`idbfactory_open2.htm`
`idbfactory_open3.htm`
`idbfactory_open4.htm`
...

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
bors-servo pushed a commit that referenced this issue Dec 18, 2019
Basic IndexedDB Functionality

<!-- Please describe your changes on the following line: -->
This PR consists of basic functionality for `IndexedDB`.
The database engine used is `Rkv`, and might not be the most optimal engine to use, so I created a *pluggable* engine. This makes it easy to change for eventual benchmarks etc.
Recently, `Rkv` has raised [warnings](https://github.com/mozilla/rkv) for using it in production, and the plan seems to be to change the backend to sqlite instead. If we expect that IndexedDB is finished after the issues in `Rkv` has been fixed, we should be able to use it after all. The ergonomics of Rkv is really good, and suits IndexedDB quite well.

What works:
* Basic Open
* Basic Put
* Basic Add
* Basic Get
* Basic Remove

Some things that don't work:
* Key generators
* Key ranges
* Aborting/Reverting transactions, including upgrades
* Closing/Removing a store/db
* Injection of keys
* Proper scheduling of transactions (they are started immediately atm)
* IDBIndex
* IDBCursor
* Manually committing transactions
* Some Error handling is missing
* ...  lots of other stuff

Implementation details worth noting:
* Transactions run in a custom thread pool. `read` and `write` transactions use the same pool, which in the future probably should be separate.
* IndexedDB is disabled by default, as it has a lot of troubles

I am making this PR pre-prematurely, as it is part of a course I take in school (and it's soon due date), so I would be very happy if *reviews can be done rather quickly*.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix (PARTLY) #6963

<!-- Either: -->
- [X] These changes do not require tests because:
There are many WebIDL tests that we can run to test the code. I was not able to run wpt tests with logging on windows, so test metadata is currently missing. I have, however, run some tests manually, and we can expect some of the tests to `PASS`.
Some examples of passing tests:
`idbobjectstore_put.htm`
`idbobjectstore_put2.htm`
`idbobjectstore_put3.htm`
`idbobjectstore_put5.htm`
`idbobjectstore_put7.htm`
`idbobjectstore_put9.htm`,
`idbobjectstore_put10.htm`
`idbobjectstore_put11.htm`
...
`idbfactory_open.htm`
`idbfactory_open2.htm`
`idbfactory_open3.htm`
`idbfactory_open4.htm`
...

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-content/dom Interacting with the DOM from web content C-assigned There is someone working on resolving the issue E-very-complex Very difficult. Do not attempt without significant relevant experience and motivation. I-enhancement No impact; the issue is a missing or proposed feature.
Projects
None yet
Development

No branches or pull requests