Thursday, May 5, 2022

Spring Check-In

In February, when we realized this year's Ruby and Rails EOLs had significant implications for our shop, I tilted a lot of effort towards getting blacklight 7.x "in order" for our migration.

I am almost seeing the daylight of "and now we can migrate our remaining apps on to Ruby 3/Rails 6+/Blacklight 7+", but this effort, combined with the drumbeat of project development work and team management... it has been a really intense spring.

Along the way I've become a maintainer of code4lib/ruby-oai, where there are now a tiny handful of inherited PRs (3, with unclear interest) and tickets (6, one of which is Ruby 3 compatibility and a major rev) - after hacking through 12 unattended PRs running back to 2015 or so. This also took me on a brief detour into configuring shared-cache SQLite and ActiveRecord, though the tests that initiated it turned out to be unnecessary. 

We've cut a release of Blacklight's OAI provider making use of that ruby-oai release (now down to a single ticket for cutting an additional release at difference ruby/linter requirements).

We're plowing through a bunch of Blacklight tickets - there's a pretty dramatic dent in the open PRs, and I think the tickets that apply to 7.x with consensus support are all merged.

That's leaving the release of a Blacklight 7-friendly refactor of the blacklight_range_limit plugin, which is nearly done.

I'm fairly certain that the "rampage of feckless merge commits" (thanks code4lib#blacklight) around all this has annoyed my co-committers to no end; I can verify that more than one direct message has essentially said "I cannot remember why I opened that PR". I think, though, that cleaning it all out makes the project(s) more approachable in addition to being required work for our team.

Trey Pendragon has made a stalwart effort towards getting the Blacklight committers on a regular meeting schedule again, and I'm slowly trying to re-articulate myself to some form of the Samvera conversation. Somehow in all this I've also been volunteering on a DLF planning committee and recruiting, but fingers crossed that link will be dead soon and I'll be able to rejuvenate our efforts towards the other vacancy on our team.

I am hopeful that all this also indicates a mutual, if unvoiced, recognition and rejection of the malaise of the last two (or five!) years. On the other hand: At the end of last summer, my boss of 15 years announced his retirement at year's end. I intended to apply for that job, but it's gone unposted. I have to admit the possibility, then, that a part of all this is a sublimation of the anxiety and frustration of that situation - and with a backdrop of pandemics, wars, and dismaying politics, it's very easy to slip into thinking that work is the air around you.

I've maintained some resolve towards weaning myself off Twitter as the way to stay on top of both professional developments and distant friendships - cleaned up the feed, and just not posted. Hilariously, thanks to the aforementioned recruiting, I've had a taste of the LinkedIn experience and... it is not for me. I've experimented with mastodon, but I want to make an effort towards the blog - and frankly, towards slower interactions. The summer will tell how successful that is.

Wednesday, April 27, 2022

ActiveRecord, SQLite, URI Database name tokens

Blogging an answer I posted at Stack Overflow:

I ran into an issue recently with a library I was testing - the in-memory SQLite database wasn't shared between threads in the testing process. This can be accommodated in SQLite with a shared cache, and this should be usable in ActiveRecord by configuring the database connection with a URI filename... but it wasn't working.

If your SQLite build did not set the SQLITE_USE_URI flag to true, then after SQLite v3.38.2 it will default to false. As the folks at S/O observe, you will see files created with the name of the URI token.

You can work around this by passing the appropriate bit switches to SQLite via the flags parameter on your ActiveRecord connection.

In particular, you will want:

  • SQLite3::Constants::Open::READWRITE (0x02)
  • SQLite3::Constants::Open::CREATE (0x04)
  • SQLite3::Constants::Open::URI (0x40)
... which is to say:

ActiveRecord::Base.establish_connection {

adapter: "sqlite3",

database: "file::memory:?cache=shared",

flags: 70 # SQLite3::Constants::Open::READWRITE | CREATE | URI