Skip to content

Conversation

segiddins
Copy link
Contributor

@segiddins segiddins commented Jul 9, 2024

Description:

Ensured working via https://github.com/rubygems/gem_server_conformance


Tasks:

  • Describe the problem / feature
  • Write tests

I will abide by the code of conduct.

Copy link
Contributor

@indirect indirect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good!

I'm also interested to hear if this gave you any ideas about how we could improve the compact index gem for consumers, so their implementations could potentially be shorter/easier.

@segiddins segiddins force-pushed the segiddins/add-compact-index-support-for-private-sources branch 2 times, most recently from 8fbeaa2 to 8993ad0 Compare July 19, 2024 19:47
@segiddins segiddins marked this pull request as ready for review July 19, 2024 19:47
@segiddins segiddins force-pushed the segiddins/add-compact-index-support-for-private-sources branch 2 times, most recently from 80b1844 to 0c3e854 Compare July 21, 2024 23:17
@technicalpickles
Copy link
Contributor

Is there any extra configuration needed to enable this? Wanted to test locally, but see this when trying to bundle install against it:

HTTP GET http://localhost:9292/private/versions
HTTP 404 Not Found http://localhost:9292/private/versions
Bundler::Fetcher::FallbackError: Gem::Net::HTTPNotFound: http://localhost:9292/private/versions

@segiddins
Copy link
Contributor Author

@technicalpickles shouldn't be, what's showing up in the server logs?

@technicalpickles
Copy link
Contributor

Startup:

❯ bin/gemstash start                                                                                                                                                                      ─╯
Starting gemstash!
[2024-07-31 17:10:38 -0400] - INFO - [19490] Puma starting in cluster mode...
[2024-07-31 17:10:38 -0400] - INFO - [19490] * Puma version: 6.4.2 (ruby 3.3.2-p78) ("The Eagle of Durango")
[2024-07-31 17:10:38 -0400] - INFO - [19490] *  Min threads: 0
[2024-07-31 17:10:38 -0400] - INFO - [19490] *  Max threads: 16
[2024-07-31 17:10:38 -0400] - INFO - [19490] *  Environment: development
[2024-07-31 17:10:38 -0400] - INFO - [19490] *   Master PID: 19490
[2024-07-31 17:10:38 -0400] - INFO - [19490] *      Workers: 1
[2024-07-31 17:10:38 -0400] - INFO - [19490] *     Restarts: (✔) hot (✔) phased
[2024-07-31 17:10:38 -0400] - INFO - [19490] * Listening on http://0.0.0.0:9292
[2024-07-31 17:10:38 -0400] - INFO - [19490] Use Ctrl-C to stop
[2024-07-31 17:10:38 -0400] - INFO - [19490] ! WARNING: Detected running cluster mode with 1 worker.
[2024-07-31 17:10:38 -0400] - INFO - [19490] ! Running Puma in cluster mode with a single worker is often a misconfiguration.
[2024-07-31 17:10:38 -0400] - INFO - [19490] ! Consider running Puma in single-mode (workers = 0) in order to reduce memory overhead.
[2024-07-31 17:10:38 -0400] - INFO - [19490] ! Set the `silence_single_worker_warning` option to silence this warning message.
/Users/josh.nichols/workspace/gemstash/lib/gemstash/web.rb:10: warning: Skipping set of ruby2_keywords flag for initialize (method accepts keywords or method does not accept argument splat)
[2024-07-31 17:10:38 -0400] - INFO - [19490] - Worker 0 (PID: 19492) booted in 0.36s, phase: 0

During bundle update bigdecimal --conservative:

[2024-07-31 17:10:47 -0400] - INFO - Rewriting '/private/versions' to '/versions'
[2024-07-31 17:10:47 -0400] - INFO - Rewriting '/private/api/v1/dependencies' to '/api/v1/dependencies'
[2024-07-31 17:10:47 -0400] - INFO - Rewriting '/private/api/v1/dependencies?gems=redacted-gem' to '/api/v1/dependencies?gems=redacted-gem'
[2024-07-31 17:10:47 -0400] - INFO - Querying dependencies: redacted-gem
[2024-07-31 17:10:47 -0400] - INFO - Rewriting '/private/api/v1/dependencies?gems=bigdecimal' to '/api/v1/dependencies?gems=bigdecimal'
[2024-07-31 17:10:47 -0400] - INFO - Querying dependencies: bigdecimal

@segiddins
Copy link
Contributor Author

I'll revisit this once there's a version of sqlite for jruby that supports what I used here

@segiddins segiddins force-pushed the segiddins/add-compact-index-support-for-private-sources branch from 88c97fc to 6bf4489 Compare October 3, 2024 01:08
@segiddins segiddins force-pushed the segiddins/add-compact-index-support-for-private-sources branch 2 times, most recently from 408a581 to 10aeb06 Compare November 20, 2024 16:10
@martinemde
Copy link
Contributor

Hey @segiddins, the jdbc-sqlite3 seems like a long term blocker at this point. Is the performance greatly affected by not having string_agg? I'd be willing to fix it up to see if we can get this in if you don't have time, but I could use some context about that choice.

@segiddins
Copy link
Contributor Author

It's the only way to get an array out of SQLite unfortunately. I wish we knew what jruby usage was like :/

@technicalpickles
Copy link
Contributor

Would it feasible to disable compact index on jruby until the blocker is fixed? That way, non-jruby users would get the benefit. We could also keep a PR open to enable it on jruby, so we have a reminder and/or place to validate fixes.

@simi
Copy link
Contributor

simi commented Feb 25, 2025

CI logs are not reachable anymore. Would you mind to rebase this and update deps? Seems there are some news at jruby/activerecord-jdbc-adapter#1149 (comment).

@segiddins segiddins force-pushed the segiddins/add-compact-index-support-for-private-sources branch from 10aeb06 to 770c564 Compare February 25, 2025 19:24
@martinemde
Copy link
Contributor

martinemde commented Feb 27, 2025

When I was looking closely at JRuby compact index results, they were coming out ordered differently even with identical code (and even aggregated as a separate query with its own sort) so I suspect jdbc-sqlite3 is not behaving identically to cruby's adapters. The order might be because of time field precision differences since we sort by created_at. Just a hunch.

@martinemde
Copy link
Contributor

What do you think of skipping conformance tests for jruby and releasing compact index as experimental on jruby for now? We can see it's passing for most other rubies, and with the conformance tests working, we have a reasonably high confidence that this is a working implementation. We also don't know if anyone runs their gemstash as jruby, but we could wait for feedback to try to diagnose these issues if we find people need it.


Sequel.migration do
change do
alter_table :versions do # TODO: backfill info_checksum, sha256, required_ruby_version, required_rubygems_version
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@indirect any thoughts on how best to do this, now that the PR is passing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a gemstash update or gemstash sync command that would be a standard idempotent way to reindex/update after a new version is released?

Have we done a migration like this before?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I think a command to migrate or update is the way to go, with some docs about how to update to the newer version.

Copy link
Contributor

@technicalpickles technicalpickles Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we need an explicit command? I found Gemstash::Env.migrate which handles running migrations. That is called in Gemstash::Env.db, so basically anytime the db is accessed it is automatically migrated before rturning a connection.

edit: I see now, it's more about the backfill than the migration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we'll need to do something to detect if the backfill has been done, and disable compact indexes with a warning. Tht'd be a good place to tell the user to run a command.

schema.rb Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • delete

@rsanheim
Copy link

What do you think of skipping conformance tests for jruby and releasing compact index as experimental on jruby for now?

This sounds like a great plan, as I know compact index support would help a lot for our usage of gemstash at Doximity (and we are not on jruby).

Also, getting this merged would possibly nudge jruby/genstash users to debug and fix any follow up issues if needed. 😏

@segiddins
Copy link
Contributor Author

It's passing on jruby now ;)

Copy link
Contributor

@martinemde martinemde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only small style stuff and calling out boilerplate comments. Looks great.

@auth.check("fetch")
end

# Comment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review feedback

end
end

# Comment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional feedback

Comment on lines +38 to +42
fetch_from_storage
return result if result

build_result
store_result
result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: With a few tweaks and this change you could remove all mentions of @result and the attr_reader :result.

Suggested change
fetch_from_storage
return result if result
build_result
store_result
result
result = fetch_from_storage
return result if result
result = build_result
store_result(result)
result

It also avoids the need to do @result = nil in the rescue for race condition.

Comment on lines +92 to +91
@result = file.read
resource.save("versions.list" => @result)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...You'd just need to store to a temp var here.

Comment on lines +159 to +161
# before
Gemstash::GemPusher.new(auth, read_gem("example", "0.1.0")).serve
# after
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing test?

@segiddins segiddins force-pushed the segiddins/add-compact-index-support-for-private-sources branch from 413a113 to d6dacf3 Compare July 9, 2025 18:57
@segiddins segiddins force-pushed the segiddins/add-compact-index-support-for-private-sources branch from d6dacf3 to 2853517 Compare July 9, 2025 19:40
@technicalpickles
Copy link
Contributor

Started work on backfil logic over on #412

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

Successfully merging this pull request may close these issues.

7 participants