Skip to content

Conversation

@CathyRye
Copy link

No description provided.

wadetandy and others added 30 commits July 16, 2020 09:27
We didn't have a version lock on standardrb, and since it's still
pre-1.0, a lot of the default rules are changing, which means it
introduces breakages to our tests. This locks the version to the latest
as of now and applys the fixes to get it passing
Fix standard lint errors; lock version
If an active_record has_many association provides the `inverse_of`
option, we can infer better filter name for the opposite side of a
many_to_many relationship
…e-record-adapter

Fix: filter_datetime_eq method in ActiveRecord adapter doesn't supprt nil
The Debugger was adding data to the chunks Array via the
ActiveSupport::Notification handlers `on_data`, and `on_render`. When
the debugger is disabled, this Array is never flushed, and it is not
GC'd since it's referenced in a class instance variable.

This change returns early in both event handlers if the debugger
is not enabled. We also mark the utility methods in the debugger
as private so they cannot be accessed outside of the class (and add
data to chunks).
Patch memory leak in Graphiti::Debugger.
There's some larger refactoring needed but this is the simplest possible
fix for the issue. There are three overall problems with the validator:

* Called for read operations, but meant to validate writes. I'm not sure
why this was ever the case, perhaps to eventually validate reads as
well.
* Called in multiple places (proxy and runner)
* References `params[:action]`, which couples us to Rails

So the ideal refactoring would be to only call the validator within
`ResourceProxy#save`, which addresses all the above.

The problem is one specific test looks at the metadata of a sideposted
resource (occasionally it's helpful to see things like "what parent
object is sideposting me"). Because read operations would go through the
validator and `id` would be typecast, this test now fails because it
sees `id` as a string instead of an integer, because it is no longer
being typecast.

I think I'm fine just updating the spec, but again this PR is to do the
simplest thing possible. So I instead added the very specific logic "if
validating id, and not a create operation, AND id is not writable, don't
attempt to typecast". The larger refactoring can come later.

Finally, the other future refactoring would be to avoid merging `id`
into `attributes` when not a create operation. Part of the issue here is
the deserializer is called even on reads (per above), which complicates
things further. So a good future approach would be to only call the
validator within `ResourceProxy#save`, then address deserialization
separately afterwards.
If you were passing a scope override for an update or destroy operation,
that scope wouldn't be properly honored. This PR ensures an error will
be correctly thrown if no record is found.

The downside is we look up the record twice, now, but I think we should
get a fix in ASAP.
Ensure scope override is honored on update/destroy
Avoid need for writable PK on update
Fix conditional rendering of an extra_attribute (:readable)
This was causing some pretty extreme performance problems for a couple
of our users, and it seems I've been the only one to ever encounter this
strange edge case, which is easy enough to override in my specific
resource in the two places I've seen it.
If we are trying to filter a resource by an id attribute but that
attribute is nil, we should raise an error. If we allow the resource
resolution to continue, the result will be an empty "where" clause and
taking the first result. This is a problem when sending `null` as the
relationship ID on a CREATE or UPDATE, as it would just associate
(and update!) the first record returned by the unscoped where clause.

We should probably have a check further up the stack as well in the
request validator or similar, but this at least puts a quick stop to the
issue and blows up these invalid requests while we take time to make a
more pleasant experience for API consumers.
jkeen and others added 18 commits March 28, 2024 13:03
## [1.7.1](v1.7.0...v1.7.1) (2024-04-18)

### Bug Fixes

* properly display .find vs .all in debugger statements ([d2a7a03](d2a7a03))
* rescue error from sideloads updated_at calculation, defaulting to the current time ([661e3b5](661e3b5))
* fix: require necessary ActiveSupport parts in proper order
* fix: make gem compatible with older ActiveSupport versions
## [1.7.2](v1.7.1...v1.7.2) (2024-06-11)

### Bug Fixes

* require necessary ActiveSupport parts in proper order ([bb2a488](bb2a488))
## [1.7.3](v1.7.2...v1.7.3) (2024-06-26)

### Bug Fixes

* require OpenStruct explicitly ([#475](#475)) ([e0fa18a](e0fa18a))
In ActiveRecord 7.2 the `clear_active_connections` was (re)moved to the `connection_handler` property.
## [1.7.4](v1.7.3...v1.7.4) (2024-09-11)

### Bug Fixes

* update ActiveRecord adapter w/ support for Rails 7.2+ ([#478](#478)) ([8313e33](8313e33))
## [1.7.5](v1.7.4...v1.7.5) (2024-09-16)

### Bug Fixes

* Fixes error in version check for ActiveRecord adapter introduced in [#478](#478) ([#479](#479)) ([42c82c3](42c82c3))
## [1.7.6](v1.7.5...v1.7.6) (2024-11-06)

### Bug Fixes

* Gem version check ([#483](#483)) ([68e2492](68e2492))
## [1.7.7](v1.7.6...v1.7.7) (2025-03-15)

### Bug Fixes

* change class attribute behavior on endpoint method to work in ruby 3.2+ ([#493](#493)) ([04f1f3c](04f1f3c))
zvkemp and others added 10 commits March 16, 2025 11:35
## [1.7.8](v1.7.7...v1.7.8) (2025-03-16)

### Bug Fixes

* compare URI-decoded path params ([#482](#482)) ([20b80dd](20b80dd))
* correct issue with many_to_many when one of the models has a prefix to the intersection model association ([#449](#449)) ([dc28a4f](dc28a4f))
* lazy constantize relation resources ([#492](#492)) ([3cc2983](3cc2983))
## [1.7.9](v1.7.8...v1.7.9) (2025-03-16)

### Bug Fixes

* update version check for clear active connections active record deprecation ([#491](#491)) ([4e764f6](4e764f6))
…472)

Previously, sideloading in Graphiti used an unbounded number of threads, which could decrease performance due to resource contention and exhaust the ActiveRecord connection pool, leading to timeouts and connection errors.

This commit introduces a thread pool based on ActiveRecord's global_thread_pool_async_query_executor, limiting the maximum number of resources that can be sideloaded concurrently. With a properly configured connection pool, this ensures that the ActiveRecord connection pool is not exhausted by the sideloading process.
# [1.8.0](v1.7.9...v1.8.0) (2025-03-17)

### Features

* add thread pool with promises to limit concurrent sideloading ([#472](#472)) ([2998852](2998852))
## [1.8.1](v1.8.0...v1.8.1) (2025-03-17)
@jkeen jkeen deleted the master branch March 21, 2025 18:49
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.