flippercloud / flipper

🐬 Beautiful, performant feature flags for Ruby.
https://www.flippercloud.io/docs
MIT License
3.7k stars 413 forks source link

Sync error with flipper cloud #800

Closed danielsoto15 closed 9 months ago

danielsoto15 commented 10 months ago

https://github.com/flippercloud/flipper/blob/6c485feab14ccd953e01165c63de0b03ec3524e3/lib/flipper/adapters/sequel.rb#L107C77-L107C77

Screenshot 2023-12-19 at 8 39 35
bkeepers commented 10 months ago

@danielsoto15 Can you give us more information for replicating the error?

What version are you using of Sequel, Flipper, and Ruby?

jmoglesby commented 10 months ago

Answering for @danielsoto15

CleanShot 2023-12-19 at 12 22 42

CleanShot 2023-12-19 at 12 23 06

CleanShot 2023-12-19 at 12 23 49

jmoglesby commented 10 months ago

@bkeepers, Is this just as simple as changing:

features_sql = @feature_class.select(:key.qualify(feature_table).as(:feature_key))

to

features_sql = @feature_class.select(&:key.qualify(feature_table).as(:feature_key))

in the location @danielsoto15 linked to above? Seems you mean to call .qualify() on a string, not a symbol.

danielsoto15 commented 10 months ago

Yes and also on the following two lines after these line could need the same fix

jnunemaker commented 10 months ago

Weird. Any idea why this broke? Did sequel change? We haven't changed this part of the adapter in years.

How does this look for a fix: https://github.com/flippercloud/flipper/pull/802

Can you try locking bundler to that branch and see if it fixes your problem?

jmoglesby commented 10 months ago

@jnunemaker We're trying to make this happen, but... running into complications in our codebase that are slowing it down. I'm probably just an idiot and not doing this right. 😑

Would you mind helping me understand how this works when you have multiple gemspecs bundled into a single repository? If I'm referencing your fix branch for the flipper-sequel gem, do I also need to do that for the flipper-cloud gem? CleanShot 2023-12-20 at 10 26 45

Also, bundler still reports I'm getting 1.1.2 in the lockfile -- is that just because it falls back to reporting the last version tag when you import an untagged, or "ahead-of-tags" branch? CleanShot 2023-12-20 at 10 28 50

bkeepers commented 10 months ago

@jmoglesby this is how we do it in the Flipper Cloud gemfile:

flipper_version = {github: 'flippercloud/flipper', branch: "main"}
gem 'flipper', flipper_version
gem 'flipper-api', flipper_version
gem 'flipper-active_record', flipper_version

Also, bundler still reports I'm getting 1.1.2 in the lockfile -- is that just because it falls back to reporting the last version tag when you import an untagged, or "ahead-of-tags" branch?

Yeah, we don't usually bump Flipper::VERSION until right before a release.

jmoglesby commented 10 months ago

Ok, sorry for how long this took @jnunemaker, but I can now confirm your fix worked. Here's the error log from a flipper sync test when using flipper-cloud v1.1.2 and flipper-sequel v1.1.2:

Puma starting in single mode...                                                                                                                                                 │
│ * Puma version: 5.6.5 (ruby 2.7.6-p219) ("Birdie's Version")                                                                                                                    │
│ *  Min threads: 15                                                                                                                                                              │
│ *  Max threads: 15                                                                                                                                                              │
│ *  Environment: production                                                                                                                                                      │
│ *          PID: 1                                                                                                                                                               │
│ * Listening on http://0.0.0.0:3005                                                                                                                                              │
│ Use Ctrl-C to stop                                                                                                                                                              │
│ I, [2023-12-20T21:52:29.269066 #1]  INFO -- : [a1e10d1c67aeb0a8d73951d26875fc46] Started POST "/_flipper" for 3.85.165.104 at 2023-12-20 21:52:29 +0000                         │
│ I, [2023-12-20T21:52:29.290376 #1]  INFO -- : name=flipper_cloud action=start                                                                                                   │
│ F, [2023-12-20T21:52:29.292542 #1] FATAL -- : [a1e10d1c67aeb0a8d73951d26875fc46]                                                                                                │
│ [a1e10d1c67aeb0a8d73951d26875fc46] NoMethodError (undefined method `qualify' for :key:Symbol):                                                                                  │
│ [a1e10d1c67aeb0a8d73951d26875fc46]                                                                                                                                              │
│ [a1e10d1c67aeb0a8d73951d26875fc46] flipper-sequel (1.1.2) lib/flipper/adapters/sequel.rb:107:in `get_all'                                                                       │
│ [a1e10d1c67aeb0a8d73951d26875fc46] flipper (1.1.2) lib/flipper/adapters/dual_write.rb:31:in `get_all'                                                                           │
│ [a1e10d1c67aeb0a8d73951d26875fc46] flipper (1.1.2) lib/flipper/adapters/memoizable.rb:93:in `get_all'                                                                           │
│ [a1e10d1c67aeb0a8d73951d26875fc46] flipper (1.1.2) lib/flipper/dsl.rb:239:in `preload_all'                                                                                      │
│ [a1e10d1c67aeb0a8d73951d26875fc46] /usr/local/lib/ruby/2.7.0/delegate.rb:83:in `method_missing'                                                                                 │
│ [a1e10d1c67aeb0a8d73951d26875fc46] /usr/local/lib/ruby/2.7.0/forwardable.rb:235:in `preload_all'                                                                                │
│ [a1e10d1c67aeb0a8d73951d26875fc46] flipper (1.1.2) lib/flipper/middleware/memoizer.rb:83:in `memoized_call'                                                                     │
│ [a1e10d1c67aeb0a8d73951d26875fc46] flipper (1.1.2) lib/flipper/middleware/memoizer.rb:45:in `call'                                                                              │
│ [a1e10d1c67aeb0a8d73951d26875fc46] flipper (1.1.2) lib/flipper/middleware/setup_env.rb:45:in `call!'                                                                            │
│ [a1e10d1c67aeb0a8d73951d26875fc46] flipper (1.1.2) lib/flipper/middleware/setup_env.rb:40:in `call'                                                                             │
│ [a1e10d1c67aeb0a8d73951d26875fc46] actionpack (7.0.5) lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'                                                │
│ [a1e10d1c67aeb0a8d73951d26875fc46] actionpack (7.0.5) lib/action_dispatch/routing/mapper.rb:48:in `serve'                                                                       │
│ [a1e10d1c67aeb0a8d73951d26875fc46] actionpack (7.0.5) lib/action_dispatch/journey/router.rb:50:in `block in serve'                                                              │
│ [a1e10d1c67aeb0a8d73951d26875fc46] actionpack (7.0.5) lib/action_dispatch/journey/router.rb:32:in `each'                                                                        │
│ [a1e10d1c67aeb0a8d73951d26875fc46] actionpack (7.0.5) lib/action_dispatch/journey/router.rb:32:in `serve'                                                                       │
│ [a1e10d1c67aeb0a8d73951d26875fc46] actionpack (7.0.5) lib/action_dispatch/routing/route_set.rb:852:in `call'

But I get successful syncs when I lock to your fix branch #802 CleanShot 2023-12-20 at 16 05 02

Puma starting in single mode...                                                                                                                                                 │
│ * Puma version: 5.6.5 (ruby 2.7.6-p219) ("Birdie's Version")                                                                                                                    │
│ *  Min threads: 15                                                                                                                                                              │
│ *  Max threads: 15                                                                                                                                                              │
│ *  Environment: production                                                                                                                                                      │
│ *          PID: 1                                                                                                                                                               │
│ * Listening on http://0.0.0.0:3005                                                                                                                                              │
│ Use Ctrl-C to stop                                                                                                                                                              │
│ I, [2023-12-20T22:14:41.395378 #1]  INFO -- : [66292e2f9bc1b6e45af679f518d62561] Started POST "/_flipper" for 44.201.121.71 at 2023-12-20 22:14:41 +0000                        │
│ I, [2023-12-20T22:14:41.408416 #1]  INFO -- : name=flipper_cloud action=start
bkeepers commented 9 months ago

I think this was fixed by #802, but let us know if not.