Delta Indexing - Delayed Jobs is not working - thinking-sphinx

The code is working fine with delayed jobs and its making queue in delayed_jobs table and workers are processing them, but still we are getting exception on destroying object
here is the trace
vendor/bundle/ruby/1.9.1/gems/riddle-1.5.1/lib/riddle/client.rb:639:in `recv'
vendor/bundle/ruby/1.9.1/gems/riddle-1.5.1/lib/riddle/client.rb:639:in `block in request'
vendor/bundle/ruby/1.9.1/gems/riddle-1.5.1/lib/riddle/client.rb:538:in `connect'
vendor/bundle/ruby/1.9.1/gems/riddle-1.5.1/lib/riddle/client.rb:623:in `request'
vendor/bundle/ruby/1.9.1/gems/riddle-1.5.1/lib/riddle/client.rb:226:in `run'
vendor/bundle/ruby/1.9.1/gems/riddle-1.5.1/lib/riddle/client.rb:338:in `query'
vendor/bundle/ruby/1.9.1/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/search.rb:414:in `block (2 levels) in populate'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/notifications.rb:123:in `block in instrument'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/notifications.rb:123:in `instrument'
vendor/bundle/ruby/1.9.1/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/search.rb:518:in `log'
vendor/bundle/ruby/1.9.1/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/search.rb:527:in `log'
vendor/bundle/ruby/1.9.1/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/search.rb:413:in `block in populate'
vendor/bundle/ruby/1.9.1/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/search.rb:568:in `call'
vendor/bundle/ruby/1.9.1/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/search.rb:568:in `retry_on_stale_index'
vendor/bundle/ruby/1.9.1/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/search.rb:411:in `populate'
vendor/bundle/ruby/1.9.1/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/search.rb:176:in `method_missing'
vendor/bundle/ruby/1.9.1/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/search_methods.rb:395:in `search_for_id'
vendor/bundle/ruby/1.9.1/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/active_record.rb:268:in `delete_in_index'
vendor/bundle/ruby/1.9.1/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/active_record.rb:348:in `block in toggle_deleted'
vendor/bundle/ruby/1.9.1/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/active_record.rb:34
.
.
.
app/controllers/received_messages_controller.rb:142:in `destroy'
The question when delayed job delta has been added then why its trying to hit thinking sphinx directly ?
Here is the define index bloc
define_index do
if Rails.env.production?
set_property :delta => FlyingSphinx::DelayedDelta
else
set_property :delta => true
end
indexes message.subject
has user_id, read, created_at
where "users_user_messages.is_active = 'Y'"
end

What's happening here is that Thinking Sphinx is checking whether the object exists in Sphinx before marking it as deleted - and the only way to do that is to search for it. There is some error handling that's built into Thinking Sphinx though, that should catch (and ignore) errors from Sphinx, so I'm a little unsure as to why you're seeing exceptions being raised.
Can you share the error description that appears before the stack trace?
Also, this is unrelated to Delayed Job.

Related

Jekyll Requiring "excerpt" Liquid Tag in YAML Front Matter

I've got a blog built on Jekyll 3.0.1 based on this Kasper theme with some modification. I've removed all the posts but one in an effort to reduce the degrees of freedom in the problem I'm having. The site builds fine when I include an "excerpt" tag and a value for it inside the post's YAML front matter, but when I remove this I get an error (shown below). I've tried using an "excerpt_separator" tag and value in the _config.yml file and putting the separator in the post, but this doesn't help. Just for the hell of it I even put in a default "excerpt" tag and value inside the _config.yml and this didn't help either. It seems to me like my Jekyll installation is no longer auto-generating excerpts properly since it does build when I manually include an "excerpt" in the post's YAML front matter.
Here is the Github repository:
https://github.com/jtelszasz/kasper-trial
users-MacBook-Air:kasper-trial user$ jekyll serve --trace
Configuration file: /Users/user/Documents/kasper-trial/_config.yml
Source: /Users/user/Documents/kasper-trial
Destination: /Users/user/Documents/kasper-trial/_site
Incremental build: disabled. Enable with --incremental
Generating...
Deprecation: Collection#map should be called on the #docs array directly.
Called by /Users/user/Documents/kasper-trial/_plugins/rssgenerator.rb:46:in `block in generate'.
Deprecation: Collection#count should be called on the #docs array directly.
Called by /Users/user/Documents/kasper-trial/_plugins/rssgenerator.rb:49:in `rescue in block in generate'.
Deprecation: Collection#reverse should be called on the #docs array directly.
Called by /Users/user/Documents/kasper-trial/_plugins/rssgenerator.rb:51:in `block in generate'.
Deprecation: Document#title is now a key in the #data hash.
Called by /Users/user/Documents/kasper-trial/_plugins/rssgenerator.rb:53:in `block (3 levels) in generate'.
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-3.0.1/lib/jekyll/document.rb:471:in `method_missing': undefined method `excerpt' for #<Jekyll::Document _posts/2015-11-30-blah.md collection=posts> (NoMethodError)
from /Users/user/Documents/kasper-trial/_plugins/rssgenerator.rb:55:in `block (3 levels) in generate'
from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rss/maker/base.rb:57:in `new_item'
from /Users/user/Documents/kasper-trial/_plugins/rssgenerator.rb:52:in `block (2 levels) in generate'
from /Users/user/Documents/kasper-trial/_plugins/rssgenerator.rb:51:in `each'
from /Users/user/Documents/kasper-trial/_plugins/rssgenerator.rb:51:in `block in generate'
from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rss/maker/base.rb:438:in `make'
from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rss/maker/base.rb:402:in `make'
from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rss/maker.rb:28:in `make'
from /Users/user/Documents/kasper-trial/_plugins/rssgenerator.rb:41:in `generate'
from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-3.0.1/lib/jekyll/site.rb:154:in `block in generate'
from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-3.0.1/lib/jekyll/site.rb:153:in `each'
from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-3.0.1/lib/jekyll/site.rb:153:in `generate'
from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-3.0.1/lib/jekyll/site.rb:58:in `process'
from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-3.0.1/lib/jekyll/command.rb:28:in `process_site'
from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-3.0.1/lib/jekyll/commands/build.rb:60:in `build'
from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-3.0.1/lib/jekyll/commands/build.rb:35:in `process'
from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-3.0.1/lib/jekyll/commands/serve.rb:26:in `block (2 levels) in init_with_program'
from /usr/local/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `call'
from /usr/local/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `block in execute'
from /usr/local/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `each'
from /usr/local/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `execute'
from /usr/local/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/lib/mercenary/program.rb:42:in `go'
from /usr/local/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/lib/mercenary.rb:19:in `program'
from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-3.0.1/bin/jekyll:17:in `<top (required)>'
from /usr/local/bin/jekyll:23:in `load'
from /usr/local/bin/jekyll:23:in `<main>'
You have a problem in _plugins/rssgenerator.rb line 55.
item.description = parser.convert(post.excerpt)
should be :
item.description = parser.convert(post.to_liquid['excerpt'])
Remove it and use standard jekyll file to generate your feed (find it here).
In _config.yml add :
excerpt_separator: "<!--excerpt-->"
Your post :
---
layout: post
title: Post Title
description: "blah."
modified: 2014-12-17
category: articles
tags: [futbol]
---
excerpt
<!--excerpt-->
asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf

ActiveRecord::ConnectionTimeoutError after switching DB cluster node

Environment
I have a rails 3.2.x app load balanced between 2 webservers: web1 and web2. Each webserver points to a clustered IP for the mysql database. The database is 2 servers clustered (by rackspace). 1 database is active at a time until failover.
Error
On our latest failover web1 started sending ActiveRecord::ConnectionTimeoutError on Middleware/Rack/ActiveRecord::QueryCache#call (stack trace below) while web2 had no errors. Note, this occurred after the DB was stable and 100% switched to the other node.
Theory
My theory is that the session or cache or connection referenced the old node and once switched it could not find said connection. This does seem odd since both DB nodes are clustered, serving on the same clustered IP and are replicated.
Temporary solution
Our interim solution was to restart web1 rails server, this worked.
Questions
1) I was wondering if I could get an explanation of what might be happening here
2) Is there a configuration setting that could prevent this in the future.
Stack Trace
Error message
ActiveRecord::ConnectionTimeoutError: could not obtain a database connection within 5 seconds (waited 5.000268907 seconds). The max pool size is currently 5; consider increasing it.
…record/connection_adapters/abstract/connection_pool.rb: 258:in block (2 levels) in checkout'
…record/connection_adapters/abstract/connection_pool.rb: 242:inloop'
…record/connection_adapters/abstract/connection_pool.rb: 242:in block in checkout'
/usr/local/lib/ruby/1.9.1/monitor.rb: 211:inmon_synchronize'
…record/connection_adapters/abstract/connection_pool.rb: 239:in checkout'
…record/connection_adapters/abstract/connection_pool.rb: 102:inblock in connection'
/usr/local/lib/ruby/1.9.1/monitor.rb: 211:in mon_synchronize'
…record/connection_adapters/abstract/connection_pool.rb: 101:inconnection'
…record/connection_adapters/abstract/connection_pool.rb: 410:in retrieve_connection'
…nnection_adapters/abstract/connection_specification.rb: 171:inretrieve_connection'
…nnection_adapters/abstract/connection_specification.rb: 145:in connection'
…s/activerecord-3.2.19/lib/active_record/query_cache.rb: 67:inrescue in call'
…s/activerecord-3.2.19/lib/active_record/query_cache.rb: 61:in call'
…record/connection_adapters/abstract/connection_pool.rb: 479:incall'
…ack-3.2.19/lib/action_dispatch/middleware/callbacks.rb: 28:in block in call'
…s/activesupport-3.2.19/lib/active_support/callbacks.rb: 405:in_run__862588711471957735__call__1324336831638990183__callbacks'
…s/activesupport-3.2.19/lib/active_support/callbacks.rb: 405:in __run_callback'
…s/activesupport-3.2.19/lib/active_support/callbacks.rb: 385:in_run_call_callbacks'
…s/activesupport-3.2.19/lib/active_support/callbacks.rb: 81:in run_callbacks'
…ack-3.2.19/lib/action_dispatch/middleware/callbacks.rb: 27:incall'
…ack-3.2.19/lib/action_dispatch/middleware/remote_ip.rb: 31:in call'
…/gems/airbrake-3.1.14/lib/airbrake/rails/middleware.rb: 13:incall'
….19/lib/action_dispatch/middleware/debug_exceptions.rb: 16:in call'
…2.19/lib/action_dispatch/middleware/show_exceptions.rb: 56:incall'
…by/1.9.1/gems/railties-3.2.19/lib/rails/rack/logger.rb: 32:in call_app'
…by/1.9.1/gems/railties-3.2.19/lib/rails/rack/logger.rb: 16:inblock in call'
…ivesupport-3.2.19/lib/active_support/tagged_logging.rb: 22:in tagged'
…by/1.9.1/gems/railties-3.2.19/lib/rails/rack/logger.rb: 16:incall'
…ck-3.2.19/lib/action_dispatch/middleware/request_id.rb: 22:in call'
…/ruby/1.9.1/gems/rack-1.4.5/lib/rack/methodoverride.rb: 21:incall'
…/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/runtime.rb: 17:in call'
…9.1/gems/airbrake-3.1.14/lib/airbrake/user_informer.rb: 16:in_call'
…9.1/gems/airbrake-3.1.14/lib/airbrake/user_informer.rb: 12:in call'
…le/ruby/1.9.1/gems/railties-3.2.19/lib/rails/engine.rb: 484:incall'
…by/1.9.1/gems/railties-3.2.19/lib/rails/application.rb: 231:in call'
…gems/railties-3.2.19/lib/rails/railtie/configurable.rb: 30:inmethod_missing'
…r-3.0.13/lib/phusion_passenger/rack/request_handler.rb: 96:in `process_request'

How do I tell Jekyll/Maruku which post has the Markdown syntax error?

How do I tell Jekyll/Maruku to tell me which file has my Mardown syntax error?
The build warning only tells me so much:
$ jekyll --safe
Configuration from /homne/me/_config.yml
Building site: /homne/me -> /homne/me/_site
___________________________________________________________________________
| Maruku tells you:
+---------------------------------------------------------------------------
| Could not find ref_id = "md_entityhellip" for md_link([md_entity("hellip")],"md_entityhellip")
| Available refs are ["png", "2", "3", "4", "5", "6"]
+---------------------------------------------------------------------------
!/home/eoin/.rvm/gems/ruby-1.9.3-p385/gems/maruku-0.6.1/lib/maruku/errors_management.rb:49:in `maruku_error'
!/home/eoin/.rvm/gems/ruby-1.9.3-p385/gems/maruku-0.6.1/lib/maruku/output/to_html.rb:716:in `to_html_link'
!/home/eoin/.rvm/gems/ruby-1.9.3-p385/gems/maruku-0.6.1/lib/maruku/output/to_html.rb:970:in `block in array_to_html'
!/home/eoin/.rvm/gems/ruby-1.9.3-p385/gems/maruku-0.6.1/lib/maruku/output/to_html.rb:961:in `each'
!/home/eoin/.rvm/gems/ruby-1.9.3-p385/gems/maruku-0.6.1/lib/maruku/output/to_html.rb:961:in `array_to_html'
\___________________________________________________________________________
Not creating a link for ref_id = "md_entityhellip".Successfully generated site: /homne/me -> /homne/me/_site
The next version of Jekyll will have better error reporting with MaRuKu and include the path to the file that caused the error.
The current master branch on GitHub should be stable enough that you could use it for testing purposes. Feedback would be welcome if you do decide to test it out. Thanks!

Octopress can't build with Code Block

I try to do something like this Octopress code block
But I can't make it work.
It always shows the following error. My machine is Windows 7.
$ rake generate
## Generating Site with Jekyll
unchanged sass/screen.scss
Configuration from d:/MyProject/Git/octopress/_config.yml
Building site: source -> public
Liquid Exception: No such file or directory - python c:/Ruby193/lib/ruby/gems/1.
9.1/gems/pygments.rb-0.3.7/lib/pygments/mentos.py in 2013-01-06-octopress.markdo
wn
c:/Ruby193/lib/ruby/gems/1.9.1/gems/posix-spawn-0.3.6/lib/posix/spawn.rb:162:in
`spawn'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/posix-spawn-0.3.6/lib/posix/spawn.rb:162:in
`spawn'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/posix-spawn-0.3.6/lib/posix/spawn.rb:307:in
`popen4'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/pygments.rb-0.3.7/lib/pygments/popen.rb:41:i
n `start'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/pygments.rb-0.3.7/lib/pygments/popen.rb:203:
in `mentos'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/pygments.rb-0.3.7/lib/pygments/popen.rb:192:
in `highlight'
d:/MyProject/Git/octopress/plugins/pygments_code.rb:24:in `pygments'
d:/MyProject/Git/octopress/plugins/pygments_code.rb:14:in `highlight'
d:/MyProject/Git/octopress/plugins/code_block.rb:82:in `render'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/liquid-2.3.0/lib/liquid/block.rb:94:in `bloc
k in render_all'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/liquid-2.3.0/lib/liquid/block.rb:92:in `coll
ect'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/liquid-2.3.0/lib/liquid/block.rb:92:in `rend
er_all'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/liquid-2.3.0/lib/liquid/block.rb:82:in `rend
er'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/liquid-2.3.0/lib/liquid/template.rb:124:in `
render'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/liquid-2.3.0/lib/liquid/template.rb:132:in `
render!'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-0.12.0/lib/jekyll/convertible.rb:79:i
n `do_layout'
d:/MyProject/Git/octopress/plugins/post_filters.rb:167:in `do_layout'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-0.12.0/lib/jekyll/post.rb:195:in `ren
der'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-0.12.0/lib/jekyll/site.rb:200:in `blo
ck in render'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-0.12.0/lib/jekyll/site.rb:199:in `eac
h'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-0.12.0/lib/jekyll/site.rb:199:in `ren
der'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-0.12.0/lib/jekyll/site.rb:41:in `proc
ess'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-0.12.0/bin/jekyll:264:in `<top (requi
red)>'
c:/Ruby193/bin/jekyll:23:in `load'
c:/Ruby193/bin/jekyll:23:in `<main>'
Build Failed
Without code block, it works fine. I have installed python 2.73 and 3.3 for windows but not luck.
I have tried pygments 0.3.7 and rubypython 0.6.3 as well. It doesn't work.
The funny thing is I google hours and hours,and I don't see anyone else have the same problem.
I must miss something very simple.
I finally fixed the problem. It turns out the PATH for Python wasn't set correctly.
It seems like Python doesn't set up the path automatically.
All I have to do is to add the path.

NoMethodError when requesting datetime element

I try to request a datetime entry in my database with ruby on rails. This works just fine in a linux environment but in my windows environment I get a NoMethodError. When debugging it I found out that the errors occurs at line 201 of the schema_definitions.rb when casting the datetime string to a time
def fast_string_to_time(string)
if string =~ Format::ISO_DATETIME
microsec = ($7.to_f * 1_000_000).to_i <<====== This is line 201
new_time $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i, microsec
end
end
When watching the $7 I get nil, seems that $7 is not initialized. What is $7 in this context? My string is
2011-04-01 10:48:57
This is the part of the trace after validate is called on an entry of an array that should contain the date
activerecord (3.0.1) lib/active_record/connection_adapters/abstract/schema_definitions.rb:201:in `fast_string_to_time'
activerecord (3.0.1) lib/active_record/connection_adapters/abstract/schema_definitions.rb:139:in `string_to_time'
activerecord (3.0.1) lib/active_record/connection_adapters/abstract/schema_definitions.rb:78:in `type_cast'
activerecord (3.0.1) lib/active_record/attribute_methods/read.rb:83:in `read_attribute'
activerecord (3.0.1) lib/active_record/base.rb:1558:in `attributes'
activerecord (3.0.1) lib/active_record/base.rb:1558:in `each'
activerecord (3.0.1) lib/active_record/base.rb:1558:in `attributes'
activerecord (3.0.1) lib/active_record/attribute_methods.rb:57:in `attribute_method?'
activemodel (3.0.1) lib/active_model/attribute_methods.rb:394:in `match_attribute_method?'
activemodel (3.0.1) lib/active_model/attribute_methods.rb:393:in `each'
activemodel (3.0.1) lib/active_model/attribute_methods.rb:393:in `match_attribute_method?'
activemodel (3.0.1) lib/active_model/attribute_methods.rb:378:in `respond_to?'
activerecord (3.0.1) lib/active_record/attribute_methods.rb:52:in `respond_to?'
activerecord (3.0.1) lib/active_record/callbacks.rb:268:in `deprecated_callback_method'
activerecord (3.0.1) lib/active_record/validations.rb:57:in `valid?'
Format::ISO_DATETIME is a Regexp:
/\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)(.\d+)?\z/
The 7th capture is the fractional seconds (e.g. ".123"), which is converted to a float and then converted to microseconds. In your string, $7 would be nil, but that's not a problem, because nil.to_f is just 0.0.
Try executing nil.to_f in a console to make sure you get 0.0.
Are you sure the NoMethodError is caused by that line? Can you post the backtrace?