Automatically upgrade HSQLDB to 2.5.0#1345
Conversation
|
This PR is mostly in alignment with the test PR I submitted #847 ages ago that upgraded HSQLDB (which incidentally also included thoughts and commits about Lucene upgrades). I've been using a derivative of that PR for about a year now, without issues. |
|
Thank you, @fxthomas ! I just tested the upgrade from a fresh 10.4.1 installation and it seems to be working as expected. Let me know if you need more info. |
|
@harawata Thanks a lot for the testing! I'll close the old PR then. One thing I'm still uneasy about is that the controlled upgrade procedure requires that nothing opens a connection to the data source while we're doing it (otherwise the database would be in fact upgraded, but without backup, and without the additional protection of doing During my tests this was the case, but with how it is currently setup this is not in fact guaranteed. I was wondering if there was a better way? |
|
In my understanding, airsonic uses HSQLDB in If we need to care about users who use HSQLDB in server-client mode, that's a different story. |
|
That's definitely out of scope. What I was pointing at was more along the lines of : theoretically our own code could start using the I'm not sure what logic Spring uses to start dependencies, but the chain here looks like this: If somehow Spring decides to switch the order, then we're in trouble. |
|
The order looks solid to me, but it should be reviewed by someone who has deep knowledge about the internals of airsonic and Spring. :) |
|
I have been looking forward to this very much. However, there are currently several PR related to DB(or DB testing). @fxthomas #1340, #1358, #1364, #1367, #1368, #1369, #1363 , and this PR. If the order is simply shown, the gaze of the committers may be concentrated. |
|
@tesshucom A nice puzzle indeed, although I don't mind rebasing this -- it is part of development! 😄 I initially set the milestone for this to 11.0, so that the next major release could be the "big upgrade", but this was not really the result of a consensus. Ideally I'd like for this and Spring Boot 2 to be done on the same release. Since these 2 are relatively risky upgrades it would make sense to get feedback on both at the same time, and finalize the release once we have a stable release candidate. What do you think of this plan? |
|
Well, I'm not dissatisfied with any plan. 😉 What we know is that if a scenario is shown to some extent, there will probably be more committers that will preferentially collaborate on high priority topics. A series of PR is an engineer's concern and can be useful later. But #1340 is a problem for some users, and there are people who are in trouble now. randomnicode mentions Hikari. Or assuming there is a problem with the current implementation, #1340 is declared as a block item. Anyway, by closing what is definitely a high priority, the number of puzzle pieces is reduced. |
| LOG.info("Shutting down database..."); | ||
| try (Statement st = conn.createStatement()) { | ||
| st.execute("SHUTDOWN SCRIPT"); | ||
| } |
There was a problem hiding this comment.
shouldn't we just use the datasource jdbctemplate injected into this class?
getJdbcTemplate().execute("SHUTDOWN SCRIPT");
There was a problem hiding this comment.
I would actually prefer to add another statement immediately afterwards to check if the connection is reestablished after shutdown. Maybe we could retrieve the new db version?
getJdbcTemplate().query*("SELECT version FROM whateversystemtable", ...);
There was a problem hiding this comment.
We cannot actually use the DataSource that Airsonic is going to use after the upgrade, because it will be closed. I did not find any way to restore the connection after a SHUTDOWN, do you have an idea?
There was a problem hiding this comment.
Hmmm, then how do we expect the application to start up after the shutdown? Do people have to start the application twice?
One idea is to shutdown the connection pool and then restart it... But the Db might still be shutting down.
Maybe your best bet is to hold the Thread and sleep until the DB has successfully shut down so it can be restarted.
| public void cleanDataBase() { | ||
| daoHelper.getJdbcTemplate().execute("DROP SCHEMA PUBLIC CASCADE"); | ||
| dataBasePopulated = false; | ||
| } |
There was a problem hiding this comment.
Any idea why this is part of the PR?
It'll slow down the tests... Was it polluting the db for the next test? Aren't the tests just start and stop jukebox?
There was a problem hiding this comment.
I am not really satisfied with this, but this was the only way I could find to actually run these tests without running into issues of the db being polluted. I did not have too much time to investigate, but do you see better ways?
There was a problem hiding this comment.
Not sure why your db is getting polluted between the tests, but I don't see anything in the tests that is writing to the db. They all seem to be read operations. They just start and stop jukeboxes for two different jukeboxes. I don't think this should be part of the PR.
There was a problem hiding this comment.
There is more info in the original PR in #876. I'll probably try to get it working at some point, but this'll take more digging.
There was a problem hiding this comment.
ooo, a mystery... hmm, that doesn't look like a test pollution. That looks like just the db shutdown for some reason. Don't know between which tests (in the same suite or the different suite)
Try removing line 41 so it stops trying to dirty the context cache (so it doesn't shut down) and see if that works?
https://github.com/airsonic/airsonic/pull/1345/files#diff-ea6a8f7e7b1cf96c312355d408705c7dR41
|
|
||
| assertNull("Error in getUserByName().", userDao.getUserByName("sindre2", true)); | ||
| assertNull("Error in getUserByName().", userDao.getUserByName("sindre ", true)); | ||
| assertNotNull("Error in getUserByName().", userDao.getUserByName("sindre ", true)); |
There was a problem hiding this comment.
👍 vaguely remember fixing this test... I'm not sure i remember why this is behaving differently
There was a problem hiding this comment.
|
Sorry for commenting on this pr a bit late. I've commented on the relevant code sections. Aside from that, here are my general thoughts on the PR:
That's about it. All the other checks about presence or absence of files are redundant in my opinion, and it's not like we do anything anyway about them. The connection pool will establish anyway no matter what we return from those checks. Just get out of the way and let the driver do it's thing (which we do anyway at the end of the day). So, in short, I would restructure the PR:
That should be all you need. |
|
One more note, regarding landing the PRs:
|
|
So, aside from PR comments:
Me too.
That may actually be a good idea. I'm going to restructure the PR in order to do this.
I don't trust the HSQLDB upgrade process, so I'd rather check my assumptions at each step. The checks are not there for the sole purpose of checking, they're here to warn users that something may have been wrong, instead of finding it out much later after they removed the backup. |
bd5f4fb to
9ad91c4
Compare
4aeaf56 to
7771acf
Compare
b12074d to
6911a35
Compare
|
@airsonic/maintainers will merge that this week-end! |
Signed-off-by: Iwao AVE! <harawata@gmail.com>
…default. To change the behavior, append 'sql.enforce_size=false' to the default JDBC URL. http://hsqldb.org/doc/guide/dbproperties-chapt.html#N1580D Signed-off-by: Iwao AVE! <harawata@gmail.com>
…configurable via 'sql.nulls_first' property. http://hsqldb.org/doc/guide/dbproperties-chapt.html#N159E5 Signed-off-by: Iwao AVE! <harawata@gmail.com>
…dded with spaces before comparison'. This behavior is configurable via 'sql.pad_space' property. http://hsqldb.org/doc/guide/dbproperties-chapt.html#N15A42 Signed-off-by: Iwao AVE! <harawata@gmail.com>
Signed-off-by: Iwao AVE! <harawata@gmail.com>
…s-is as a column name
6911a35 to
76b7b50
Compare
I am piggybacking on @harawata's work in #876 to add an automatic upgrade to HSQLDB 2.5.0, rebased on current master.
I tried to make this as safe and controlled as possible, and I've also been running HSQLDB 2.5.0 in production with the same upgrade method for a few weeks now, without noticing issues.
Thoughts and tests are most welcome!