Skip to content

Basic IndexedDB Functionality#25214

Closed
rasviitanen wants to merge 1 commit intoservo:mainfrom
rasviitanen:indexed_db
Closed

Basic IndexedDB Functionality#25214
rasviitanen wants to merge 1 commit intoservo:mainfrom
rasviitanen:indexed_db

Conversation

@rasviitanen
Copy link
Contributor

@rasviitanen rasviitanen commented Dec 9, 2019

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 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.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix (PARTLY) Implement IndexedDB. #6963
  • 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
    ...

@highfive
Copy link

highfive commented Dec 9, 2019

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @asajeffrey (or someone else) soon.

@highfive
Copy link

highfive commented Dec 9, 2019

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/webidls/IDBTransaction.webidl, components/script/dom/idbrequest.rs, components/script/dom/mod.rs, components/script/dom/window.rs, components/script/dom/idbobjectstore.rs and 14 more
  • @KiChjang: components/script/dom/webidls/IDBTransaction.webidl, components/net/lib.rs, components/script/dom/idbrequest.rs, components/script/dom/mod.rs, components/net/indexeddb/mod.rs and 24 more

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Dec 9, 2019
@highfive
Copy link

highfive commented Dec 9, 2019

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify net and script code, but no tests are modified. Please consider adding a test!

@jdm
Copy link
Member

jdm commented Dec 9, 2019

Please add a __dir__.ini to the indexeddb metadata directory to enable the new preference. This will make it possible for us to run the tests on CI and get the updated metadata you're looking for!

@rasviitanen rasviitanen force-pushed the indexed_db branch 3 times, most recently from 9ce7b52 to f062693 Compare December 9, 2019 18:04
@jdm
Copy link
Member

jdm commented Dec 9, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

⌛ Trying commit f062693 with merge e720b98...

bors-servo pushed a commit that referenced this pull request 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
Copy link
Contributor

💔 Test failed - status-taskcluster

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Dec 9, 2019
@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label Dec 9, 2019
@jdm
Copy link
Member

jdm commented Dec 9, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

⌛ Trying commit afbe66e with merge be4d861...

bors-servo pushed a commit that referenced this pull request 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
Copy link
Contributor

💔 Test failed - status-taskcluster

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Dec 9, 2019
@jdm
Copy link
Member

jdm commented Dec 9, 2019

Run wget https://community-tc.services.mozilla.com/api/queue/v1/task/P8Qk0aigQUKtiQRajoTYzg/runs/0/artifacts/public/test-wpt.log and then ./mach update-wpt test-wpt.log to update the metadata automatically. Don't forget to git add tests/wpt/metadata/IndexedDB to pick up any new ini files.

@rasviitanen
Copy link
Contributor Author

Huh, those are not the test results I was expecting. Looking at the test harness and databases that are created for each test, it looks like we must be able to create multiple databases with different names.

dbname = (dbname ? dbname : "testdb-" + new Date().getTime() + Math.random() );

It looks like this doesn't work at the moment, and everything essentially operates on the same database. I assume this is why e.g. idbobjectstores_add.htm fails. This probably explains why I have been able to get a lot more passes when running one test at a time. I think I just forgot to add a call to Open and it shouldn't be too difficult to fix.

Hopefully, we'll get more sensical test results once it's fixed.

@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label Dec 12, 2019
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Dec 17, 2019
@bors-servo
Copy link
Contributor

⌛ Testing commit fa8a94e with merge 9bda2c9...

bors-servo pushed a commit that referenced this pull request 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
Copy link
Contributor

💔 Test failed - status-taskcluster

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Dec 17, 2019
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Dec 17, 2019
@jdm
Copy link
Member

jdm commented Dec 18, 2019

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit f27c84f has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Dec 18, 2019
@bors-servo
Copy link
Contributor

⌛ Testing commit f27c84f with merge 9621c2a...

bors-servo pushed a commit that referenced this pull request 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. -->
@bors-servo
Copy link
Contributor

💔 Test failed - status-taskcluster

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Dec 18, 2019
@jdm
Copy link
Member

jdm commented Dec 18, 2019

Darn - lmdb-rkv-sys contains native Windows code that isn't compatible with UWP builds. The shortest path to success here is to have a dummy IDB backend that's used when cfg(target_vendor = "uwp") is true that means that we don't compile the rkv crates.

@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #23545) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jan 6, 2020
@bors-servo
Copy link
Contributor

🔒 Merge conflict

1 similar comment
@bors-servo
Copy link
Contributor

🔒 Merge conflict

This was referenced Aug 12, 2024
@jdm
Copy link
Member

jdm commented Oct 19, 2024

Closing in favour of #33044.

@jdm jdm closed this Oct 19, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jun 19, 2025
Adds indexeddb support to servo. At the moment heed is being used as the
backend, although this can be swapped out by implementing `KvsEngine`.
This PR adds a thread + a thread pool for Indexeddb related operations.
Also `database_access_task_source` is added for Indexeddb related
operations.

This is a partial rewrite of #25214. (Reopened due to branching issue)

Fixes #6963

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Rasmus Viitanen <rasviitanen@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-needs-rebase There are merge conflict errors. S-tests-failed The changes caused existing tests to fail.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants