mfoo

Activity Graph

Page 1 of 1

2019-04-08

[11:20:21] mfoo: has joined #RubyOnRails
[12:34:02] mfoo: Unicorn's documentation for HUP handling states that it "gracefully restarts all workers" - it seems to actually pause requests, then restart all workers at the same time. The effect is that requests hang (connections don't drop). Is there a minimum pool size such that there are always some available workers?
[12:36:50] mfoo: (note that Puma's documentation for USR1 specifies "restart workers in phases, a rolling restart" a number which I assume can be configured but can't find the config for yet
[17:11:00] mfoo: Ping timeout: 250 seconds

2017-09-15

[15:28:55] mfoo: has joined #RubyOnRails
[15:34:21] mfoo: Hi. I have a layout docs.html.haml which renders a head template containing a yield for stylesheets and a yield block for views. The controller calls render :index, layout: 'docs'. In development this works fine. After asset precompilation, none of the content_for blocks from the index view are rendered. Am I missing something?
[15:35:40] mfoo: *the head template has the yield for styleshsets. The layout has the yield for views
[15:37:03] mfoo: Actually, I see no content whatsoever from my layout, only the yield block
[15:41:42] mfoo: this will iterate. doesn't .where(id: id) work? This will move the work into the database.
[15:43:45] mfoo: Have you tried `.joins`?
[17:31:48] mfoo: Ping timeout: 240 seconds

2017-03-07

[13:30:58] mfoo: has joined #RubyOnRails
[13:32:50] mfoo: Hello - I'm looking to implement structured logging for aggregation in the ELK stack. I've used LogRage with the Logstash formatter, but this doesn't change non-request logs (exceptions, asset serving etc seem to use the rack logger). I've tried the logstasher gem but this prints each line of a backtrace as a separate JSON message. Is there anybody with experience of this or a guide that's around?
[13:33:33] mfoo: Ideally I'd like multiple appenders (human readable to a file, json to a file/socket)
[13:38:16] mfoo: matthewd: The breaking change was in 5.1.0, I'm on 3.2.22
[13:38:51] mfoo: matthewd: But the effect is the same - I believe the problem is the "logstasher" logger in this case
[13:39:33] mfoo: Mostly I'm looking for a guide on "how to do logging the right way" or similar - logs for machine consumption.
[13:40:13] mfoo: I can see many posts focussing on request logging, which is fine, but I would like to log stack traces in a structured way also
[15:06:06] mfoo: Can I ask why (in activesupport 3.2.22.3) ActiveSupport::Notifications::Instrumenter#instrument doesn't include the stack trace, only the class and the message?
[15:10:00] mfoo: workmad3: I'm trying to implement some structured logs, in this case using a JSON log formatter. The payload passed to the formatter contains the exception class name and message as an array, but this gets put there by ActiveSupport::Notifications::Instrumenter#instrument (if an uncaught exception bubbles into action controller). This means my logger doesn't have access to the stacktrace.
[15:10:58] mfoo: workmad3: ah, `$!.backtrace` exists, thanks
[15:13:45] mfoo: matthewd: I ofcourse appreciate that people don't anticipate all possible use cases. I was mostly trying to ask "am I doing this wrong, or is this an oversight"
[15:14:51] mfoo: I would also be happy with an answer such as "this was improved in version X"
[15:15:07] mfoo: To my detriment I hadn't checked the latest source
[15:15:17] mfoo: workmad3: ah, thanks
[15:16:18] mfoo: And a ruby version
[17:16:50] mfoo: Quit: leaving

2016-05-23

[10:42:48] mfoo: has joined #RubyOnRails
[12:57:33] mfoo: Quit: leaving

2016-05-20

[08:28:57] mfoo: has joined #RubyOnRails
[17:12:59] mfoo: Ping timeout: 250 seconds

2016-05-19

[09:58:56] mfoo: has joined #RubyOnRails
[10:11:13] mfoo: is there a message length limit here? I believe I just asked a fairly long question but don't see it
[10:15:43] mfoo: universa1: thanks, I'll split it up then
[10:17:54] mfoo: Hi all - I'm having an issue with rolling restarts on unicorn. The master successfully cycles the children after a SIGUP, yet occasionally they get stuck in a respawn loop due to a crash in initialisation.
[10:17:58] mfoo: This is from a call (in this case in a model, I'm unsure if are other triggers) to a function provided by a gem that didn't exist before the upgrade.
[10:18:04] mfoo: The gems have definitely been installed at this point and restarting the unicorn service brings it back up fine.
[10:18:11] mfoo: As I understand it the default option for unicorn is to set "preload_app" to false which disables shared memory allocation and forces rails to be reloaded when the unicorn worker comes up. We haven't changed this option.
[10:18:34] mfoo: why might my gems be causing problems here?
[10:19:00] mfoo: I assume the crash is on initialisation due to config.cache_classes=true
[10:19:08] mfoo: The initialiser is not our own code
[13:38:36] mfoo: Ping timeout: 276 seconds
[13:53:58] mfoo: has joined #RubyOnRails
[17:18:56] mfoo: Ping timeout: 276 seconds

2016-04-09

[17:03:01] mfoo: has joined #RubyOnRails
[17:07:54] mfoo: Hi guys, I need some help. I'm setting up rails deployment with capistrano. After precompilation rails is serving me a 204 No Content for my application.css and a file containing two newline characters for JS, yet I can see the file on disk with the same name as the asset being sent back to me has the expected content. I've tried clearing my browser cache and I'm not sure what's going on.
[18:57:02] mfoo: Ping timeout: 248 seconds

2016-03-31

[09:52:20] mfoo: has joined #RubyOnRails
[09:53:35] mfoo: Hello. Is a record obtained through activerecord pessimistic locking outside of a transaction ever released unless done manually? I don't see any locks in InnoDB in this case. Does the activerecord object have a finalizer on it that releases the lock?
[10:04:44] mfoo: ah, my connection has autocommit enabled. that's where my locks are going.
[10:04:50] mfoo: Quit: leaving

2016-03-16

[00:08:25] mfoo: Ping timeout: 240 seconds
[09:14:48] mfoo: has joined #RubyOnRails
[09:16:57] mfoo: Client Quit

2016-03-15

[14:31:41] mfoo: has joined #RubyOnRails
[14:32:24] mfoo: Is anybody using rolling restarts with unicorn? What criteria do you use to determine if the master is ready before sending QUIT to the old master? Checking that the new rails instances are listening on a port doesn't tell me if any of the old ones are still handling requests
[14:36:36] mfoo: tubbo: bleh, I was reading about USR2 + QUIT. This is much simpler, thanks
[14:36:52] mfoo: since I'm not upgrading unicorn
[20:54:32] mfoo: Ping timeout: 260 seconds
[23:53:01] mfoo: has joined #RubyOnRails

2016-03-05

[13:37:06] mfoo: has joined #RubyOnRails
[13:40:28] mfoo: Client Quit
[15:47:01] mfoo: has joined #RubyOnRails
[15:50:18] mfoo: Hi, I've got an application.css inside an empty app/assets/stylesheets.css in a rails 5 app. It contains "/*\n *= require_tree .\n *=require_self\n */". My app has started failing with "couldn't digest ActiveSupport::StringInquirer". If I delete the require_tree it does not fail. I have no styles in the directory. What could be broken?
[16:57:45] mfoo: Ping timeout: 250 seconds
[20:23:36] mfoo: has joined #RubyOnRails
[20:36:19] mfoo: Ping timeout: 248 seconds
[20:50:29] mfoo: has joined #RubyOnRails
[22:32:46] mfoo: Quit: leaving

2015-11-10

[10:10:46] mfoo: Quit: Leaving

2015-11-09

[13:51:32] mfoo: has joined #RubyOnRails
[13:53:22] mfoo: Hello. Does anybody know how I can get ActiveModel::Serialization to respect ActiveSupport::JSON::Encoding.escape_html_entities_in_json? I'm embedding some javascript inside an HTML page and the JS may contain </script>, introducing an XSS vulnerability.
[16:33:06] mfoo: has joined #ruby
[16:34:21] mfoo: hello - could I enquire as to how exception handling happens in ruby? I am used to begin/rescue but I see code here rescueing from a NameError outside a begin block. Why is line 456 evaluated in Ruby? https://github.com/rails-api/active_model_serializers/blob/0-8-stable/lib/active_model/serializer.rb#L454
[16:35:51] mfoo: ah, thanks adaedra, blubjr
[16:36:17] mfoo: adaedra, yes, indeed.
[16:36:31] mfoo: it's essentially loop unrolling
[16:36:53] mfoo: to generate a hash of attribute: value for serialization.
[16:37:06] mfoo: and define a method for that class so we don't have to iterate for every object of that class
[16:38:25] mfoo: luckily this code has died in the next version

2015-07-27

[12:01:19] mfoo: Quit: Leaving

2015-07-24

[07:38:42] mfoo: has joined #RubyOnRails
[17:13:21] mfoo: Ping timeout: 265 seconds
[20:36:08] mfoo: has joined #RubyOnRails

2015-07-23

[14:16:54] mfoo: has joined #RubyOnRails
[14:19:48] mfoo: It looks like I have a JBuilder template that's throwing an exception in a certain case. In the rails log I just get told that it couldn't find the template. I know it can because it works under other circumstances. How do I get to the underlying error? Rendering the views manually is a bit of a PITA from the rails console.
[14:30:52] mfoo: it's an old API, and unfortunately no I can't. I appreciate this is makes helping difficult. My question was how I see an underlying 'view cannot be found' exception (and why that happens rather than the actual exception bubbling up), rather than 'can you find what is causing my exception' :)
[14:31:29] mfoo: axilla, ^
[14:42:33] mfoo: axilla, seems to be https://github.com/rails/jbuilder/issues/40
[17:38:18] mfoo: Ping timeout: 246 seconds

2015-06-20

[21:20:21] mfoo: Ping timeout: 264 seconds

2015-06-16

[10:42:26] mfoo: Does anybody have experience with rolling out a new API version? I have some questions that I posted on SO yesterday but haven't had an answer to yet
[10:48:09] mfoo: just in case anybody does have experience and would like to answer, http://stackoverflow.com/questions/30852006/the-correct-way-to-version-rails-3-apis
[12:45:43] mfoo: this isn't the garbage collection conversation I was expecting
[12:47:47] mfoo: has anybody here had experience with releasing version 2 of an API in rails?
[12:48:31] mfoo: ddv: but must I copy all of my v1 controllers that aren't changing?
[12:49:01] mfoo: ddv: what about running specs on the new api? do I copy the v1 specs and make a tiny change? what about code duplication?
[12:49:56] mfoo: we must clean our desks due to a security policy (at least, keep them clear, not wash them)

2015-06-15

[08:54:42] mfoo: has joined #RubyOnRails
[08:56:40] mfoo: I've seen a lot of posts about containerising Rails using Docker. If people are spawning one rails instance per container, how does rails handle running migrations when they come up if you spawn multiple containers? Do people just spawn a single container with e.g. unicorn and run multiple rails workers inside it?

2015-05-21

[09:51:06] mfoo: has left #RubyOnRails: ()

2015-05-12

[16:50:15] mfoo: I'm trying to find some documentation on the recommended way to version APIs. Our Rails 3 application has a large number of controllers sitting under the Api::V1 namespace and objects using activemodel serializers. How do we introduce a breaking API change to a serializer for one REST route? Is it possible to introduce a version 2 without making a copy of all of the controllers and serializers used for version 1?
[16:52:28] mfoo: I'm also interested in the copying of the controller and serializer specs and how these should be versioned

2015-02-01

[09:25:21] mfoo: Is there an equivalent to mysql client's "-A" flag that can be given to rake db:migrate? I have a database that takes 10 minutes to run db:migrate on just for rails to discover there are no migrations to perform
[09:26:29] mfoo: -A disables metadata when connecting over mysql client, so you e.g. don't get tab completion for table names or column names
[09:26:53] mfoo: my assumption is that db:migrate is doing something similar, because like you said, reading a single value from a table is fast
[09:27:21] mfoo: the same migration on the same schema version on all of my other databases (which are much smaller) takes almost no time
[09:27:29] mfoo: mysql, yes.
[09:28:24] mfoo: the database has a few thousand tables in it, which is why the -A is necessary for connecting with mysql client
[09:28:51] mfoo: please no "re-architect your database" comments, we have much higher performance this way.
[09:29:44] mfoo: the migration only concerns about 15 tables that are controlled by rails
[09:29:55] mfoo: none of the large tables are controlled by rails either
[09:30:14] mfoo: no, infact i'm changing 0 tables
[09:30:37] mfoo: that's helpful, thanks :)
[09:31:22] mfoo: the puppet scripts perform db:migrate in the rollout phase all the time, even when there are no table changes, because db:migrate handles whether or not it's necessary and I don't believe there's a better way of determining if the migration is necessary
[09:32:02] mfoo: as above, the same schema version with db:migrate performed on it is almost instant on other much smaller databases, so I'm assuming it's related to the number of tables in the database but I don't know why this would cause db:migrate to be slow
[09:32:17] mfoo: I therefore am assuming it's to do with gathering table metadata, which seems unnecessary
[09:32:45] mfoo: jimbauds, historically, maybe 50, but 0 new ones
[09:33:33] mfoo: harly, I came here for suggestions because my assumption sounds weird. I'll have to enable the full query log and see what rails is doing I guess.
[09:35:16] mfoo: I am not asking about improvements to my situation, I'm asking what reason db:migrate might be slow on a fairly large database when there are no changes to be made
[09:36:00] mfoo: s/situation/database architecture
[09:38:09] mfoo: certainly it's strange, and certainly the tables could be moved to a different database, but I'm specifically asking what about having a lot of tables would make db:migrate slow when the schema version isn't changing. I.e. why would db:migrate need to care about those tables, surely it just checks a timestamp/schema version from the migrations table
[09:38:22] mfoo: so then, why is that check slow, what steps are performed to get there
[09:39:23] mfoo: harly, as above, in all of the other environments with fewer tables and on the same schema version, db:migrate takes a second or three
[09:40:29] mfoo: rushed, no
[09:50:55] mfoo: harly, now, that's actually a useful answer, thankyou
[09:54:56] mfoo: harly, so infact what should be happening (ignoring the fact that actual migrations will be slow due to dumping the schema, which is another problem) to fix slow migrations that perform no change is checking the output of db:migrate:status first?
[09:57:30] mfoo: harly, sure, I'll verify this in dev, but I'm 99% sure it is due to table count, I have no reason to believe the tables need to be scanned by rails during a migration.
[09:58:23] mfoo: I do know that db/schema.rb is updated in prod.
[10:05:01] mfoo: harly, thanks. Combining this with a check of Rails.env looks like it would work. We never need to import a production schema in dev (we can use a mysql schema dump anyway if we had to)

2014-12-02

[15:59:33] mfoo: ookieStore session store?
[15:59:33] mfoo: Hello. I'm confused by the rails security guide. Assuming I am using a non-default (say activerecord) session store, my cookies have my session ID in them. Let's assume I logged in from a public computer and didn't clear my cookies. What prevents somebody from reading that session ID and transmitting that with requests? I understand that it's safe from tampering but how is it different from storing the session token in a base64 encoded cookie using the C

2014-09-19

[14:16:51] mfoo: Hello. I'm reading the security guidelines. The session fixation suggestion is to call reset_session upon successful user login. http://guides.rubyonrails.org/security.html#session-fixation-countermeasures Am I correct in thinking that it's not possible for rails to expire sessions when using the CookieStore? (I.e. if somebody had a copy of the cookie containing a valid session ID, they could still impersonate a user after reset_session had been called)?

2014-01-15

[11:17:58] mfoo: Hello. I have a rails engine mounted. My engine's ApplicationController inherits from the parent ApplicationController. When config.cache_classes is false in the parent a page from the engine works fine until the page is refreshed and then it fails. This seems to be because the parent code is unloaded before the second request and is not loaded back again.
[11:19:40] mfoo: rushed, yes
[11:22:37] mfoo: in this case the parent application controller defines a bunch of non standard error handling as well as things like ensuring that devise authentication happens in each controller method
[11:41:59] mfoo: rushed, I fixed the issue bizarrely. Can somebody explain how the two lines in http://guides.rubyonrails.org/engines.html#using-a-controller-provided-by-the-application is different to http://pastebin.com/37xePag7 ? The rails guide code works properly and loads the parent application class as expected, while the engine in the paste shows an undefined constant ParentApplicationName after a refresh with config.cache_classes=false.
[17:00:07] mfoo: is it necessary to have the dummy application to rspec test an engine?
[17:34:00] mfoo: My engine requires some classes from the parent application (such as the User class for devise). How can I include these files? Is it done inside spec_helper.rb?

2013-10-25

[13:47:19] mfoo: Hi, my database.yml specifies a pool size of 5. Does activerecord's connection pool perform periodic liveness checks on database connections? I see the reaper can close long running connections
[13:47:28] mfoo: I'm using mysql if it makes a difference
[13:52:14] mfoo: my database restarted earlier and a while later somebody received a "database has gone away" error, which, had that connection been in the pool, it should have been recycled
[13:52:51] mfoo: It is a very low volume site. I see no information on configuring liveness check times

2013-06-13

[10:44:24] mfoo: Hi, is there any good documentation about how the activerecord connection pool behave in the case of database failure (let's say the service goes down / is unavailable)