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

Closing one of multiple db objects for the same db file causes failure #209

Closed
brodycj opened this issue Mar 17, 2015 · 2 comments
Closed

Comments

@brodycj
Copy link
Contributor

brodycj commented Mar 17, 2015

While it is possible to support db connection objects to the same db file, closing one of the db connection objects quietly breaks the other db connection.

UPDATED REPRODUCTION SCENARIO: The following reproduction scenario fails with a timeout:

        if (!isWebSql) test(suiteName + ' close one of multiple db handle', function () {
          var dbname = 'multi-handle-db-close-one.db';
          var dbw = openDatabase(dbname, "1.0", "Demo", DEFAULT_SIZE);
          var dbr = openDatabase(dbname, "1.0", "Demo", DEFAULT_SIZE);

          stop(1);

          dbw.transaction(function (tx) {
            tx.executeSql('DROP TABLE IF EXISTS tt');
            tx.executeSql('CREATE TABLE IF NOT EXISTS tt (test_data)');
            tx.executeSql('INSERT INTO tt VALUES (?)', ['My-test-data']);
          }, function(error) {
            console.log("ERROR: " + error.message);
            ok(false, error.message);
            start(1);
          }, function() {
            dbw.close(function () {
              dbr.readTransaction(function (tx) {
                tx.executeSql('SELECT test_data from tt', [], function (tx, result) {
                  equal(result.rows.item(0).test_data, 'My-test-data', 'read data from reader handle');
                  start(1);
                });
              }, function(error) {
                console.log("ERROR: " + error.message);
                ok(false, error.message);
                start(1);
              });
            }, function (error) {
              ok(false, 'close error callback not to be called after database is closed');
              start(1);
            });
          });
        });

This issue was discovered by consideration of some CoffeeScript/Javascript restructuring and possible redesign to support solution to #184.

brodycj pushed a commit that referenced this issue Mar 17, 2015
brodycj pushed a commit that referenced this issue Mar 17, 2015
brodycj pushed a commit that referenced this issue Mar 17, 2015
Discovered this while working on a solution for #184 & #209.

Minor cleanup of comments.
@brodycj
Copy link
Contributor Author

brodycj commented Mar 18, 2015

IMPORTANT NOTE (implementation): if a db handle object has been closed, it should abort all attempts to execute SQL statements and transactions, and should reject any future attempt to close with an error callback (as already tested in commit 2e31d46).

brodycj pushed a commit that referenced this issue Mar 18, 2015
Clean separation between SQL tests (which should apply to both Web SQL and this plugin) and plugin-specific tests.

Add reproduction of minor bug #204.

Move reproduction of #209 to section with plugin-specific tests.

Mark some plugin db tests that were added by Mark Oppenheim (mailto:[email protected]) as "Needed to support some large-scale applications".

Test repeatedly open and close db two ways (whether or not to wait for open callback before closing db)

Add another test of repeatedly open and delete db (wait for open callback before deleting db)

Needed for #184/#204/#209/#210/#211/#213.
brodycj pushed a commit that referenced this issue Mar 18, 2015
…ase that is being opened (#184).

Document related txLocks & openDBs map objects.

Mark other bugs to be fixed (#204/#209/#210).
brodycj pushed a commit that referenced this issue Mar 18, 2015
CHANGES:
- Use per-db state to properly handle transactions requested on a database that is being opened (#184).
- Report an error upon attempt to close database multiple times.

TEST:
- Reproduce BUGs #204/#209
- Expand some existing scenarios
- Prepare test suite for upcoming fixes and improvements (#184/#204/#209/#210/#211/#213)
brodycj pushed a commit that referenced this issue Mar 18, 2015
CHANGES:
- Use per-db state to properly handle transactions requested on a database that is being opened (#184).
- Report an error upon attempt to close database multiple times.

TEST:
- Reproduce BUGs #204/#209
- Expand some existing scenarios
- Prepare test suite for upcoming fixes and improvements (#184/#204/#209/#210/#211/#213)
@brodycj
Copy link
Contributor Author

brodycj commented Aug 1, 2016

Fixed in documentation: using the close method will close the database on the native side and invalidate all handles on the JavaScript side. For reference: https://www.infoq.com/articles/0-bugs-policy

A FUTURE TODO is to add a dispose method that will simply invalidate a single database handle object. The database would be closed on the native side once all handles on the JavaScript side are invalidated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant