Allocation of environment handle failed

Issue #6 resolved
Aaron Bartell created an issue

I am getting the following error on a v7.1 machine. I have never had this error before on any machine.

Allocation of environment handle failed: <error message could not be retrieved>

The Ruby database connection used to work on this machine and then stopped working. We do not know what was changed. Some notes about the system.

IBM i OS: v7.1

QCCSID: 37

PowerRuby version: prV2R1

The above error is from line 2485 in ibm_db.c.

Below is the full error. A smallest of small Rails app was created to produce this error; basically configured database.yml to point at a schema created with CREATE COLLECTION but didn't even configure any model objects.

I thought about doing a PASE CLI trace like we previously did with the "fetch columns" error, but in this case it never works.

##Any ideas on what to check?

$ rails s -p444
Cannot convert between code set  (CCSID 1208) and code set  (CCSID 37)
=> Booting WEBrick
=> Rails 4.1.8 application starting in development on http://0.0.0.0:444
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
[2016-10-12 13:11:53] INFO  WEBrick 1.3.1
[2016-10-12 13:11:53] INFO  ruby 2.1.5 (2014-11-13) [powerpc-aix6.1]
[2016-10-12 13:11:53] INFO  WEBrick::HTTPServer#start: pid=20467 port=444


Started GET "/" for 172.16.0.107 at 2016-10-12 13:11:57 -0700
Cannot convert between code set  (CCSID 819) and code set  (CCSID 37)
Cannot convert between code set  (CCSID 819) and code set  (CCSID 37)
Cannot convert between code set  (CCSID 819) and code set  (CCSID 37)
Cannot convert between code set  (CCSID 819) and code set  (CCSID 37)
Cannot convert between code set  (CCSID 819) and code set  (CCSID 37)

RuntimeError (Failed to connect to [*LOCAL] due to: uncaught throw :"Allocation of environment handle failed: <error message could not be retrieved>"):
  ibm_db-2.5.14-powerpc-aix (6) lib/active_record/connection_adapters/ibm_db_adapter.rb:541:in `rescue in ibm_db_connection'
  ibm_db-2.5.14-powerpc-aix (6) lib/active_record/connection_adapters/ibm_db_adapter.rb:510:in `ibm_db_connection'
  activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
  activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
  activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
  activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
  /PowerRuby/prV2R1/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
  activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
  activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
  /PowerRuby/prV2R1/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
  activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
  activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
  activerecord (4.1.8) lib/active_record/connection_handling.rb:113:in `retrieve_connection'
  activerecord (4.1.8) lib/active_record/connection_handling.rb:87:in `connection'
  activerecord (4.1.8) lib/active_record/query_cache.rb:51:in `restore_query_cache_settings'
  activerecord (4.1.8) lib/active_record/query_cache.rb:43:in `rescue in call'
  activerecord (4.1.8) lib/active_record/query_cache.rb:32:in `call'
  activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
  activerecord (4.1.8) lib/active_record/migration.rb:380:in `call'
  actionpack (4.1.8) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.1.8) lib/active_support/callbacks.rb:82:in `run_callbacks'
  actionpack (4.1.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.1.8) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.1.8) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
  actionpack (4.1.8) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  actionpack (4.1.8) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.1.8) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.1.8) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.1.8) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.1.8) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.1.8) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  activesupport (4.1.8) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  actionpack (4.1.8) lib/action_dispatch/middleware/static.rb:84:in `call'
  rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
  railties (4.1.8) lib/rails/engine.rb:514:in `call'
  railties (4.1.8) lib/rails/application.rb:144:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  rack (1.5.2) lib/rack/content_length.rb:14:in `call'
  rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
  /PowerRuby/prV2R1/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
  /PowerRuby/prV2R1/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
  /PowerRuby/prV2R1/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'


  Rendered /PowerRuby/prV2R1/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/rescues/_source.erb (1.0ms)
  Rendered /PowerRuby/prV2R1/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.3ms)
  Rendered /PowerRuby/prV2R1/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.6ms)
  Rendered /PowerRuby/prV2R1/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (66.9ms)

Comments (16)

  1. Former user Account Deleted

    Ok, SQL_SUCCESS_WITH_INFO should fix the problem.

    Can you test this for me??

    #ifndef PASE /* IBM i difference */
            rc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &(conn_res->henv));
            /* IBM i only one env handle, SQL_SUCCESS_WITH_INFO is good */
            if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) {
                rc = SQL_SUCCESS;
            }
    #else /* PASE */
    
  2. Aaron Bartell reporter

    I am finally getting to this. I am taking a slightly longer route of fully documenting this experience so others can learn. Specifically, I am documenting how to setup a chroot environment with gcc + PowerRuby and then recompiling the ruby-ibm_db gem. Should be able to finish testing this today.

  3. Aaron Bartell reporter

    The customer now has this installed on their machine and it appears to have addressed the issue.

    Do we still need to abide by the rule of not changing the version of the ibm_db gem? It would be great if we could increment the version so we could differentiate between versions.

  4. Former user Account Deleted

    ... installed on their machine and it appears to have addressed the issue.

    Good. However, for the record, we are not just guessing about software fixes. That is to say, 'testing' is science, not luck on lottery numbers. Although should i ever hit the Powerball, i plan on cashing the check.

    ... different versions

    mmm ... not my thing grasshopper. I believe correct answer is I do not recall the issue senator.

  5. Aaron Bartell reporter

    That is to say, 'testing' is science, not luck on lottery numbers.

    Agreed. I think we need to further flesh out our unit tests before we can consider this a production release.

    mmm ... not my thing grasshopper. I believe correct answer is I do not recall the issue senator.

    This goes back to your comments about needing lawyer review of code if version number changes. I was wondering if that landscape had changed at all or if we're still bound by the same chains.

  6. Former user Account Deleted

    Nothing has changed Mr WikiLeaks. Rule is no review patches are considered 10-20 lines of code or less. This is about 3 lines, so cool. Version changes are reviewed.

  7. Former user Account Deleted

    Agreed. I think we need to further flesh out our unit tests before we can consider this a production release.

    I disagree. Perhaps i should be more forceful. There is nothing in this simple fix that needs further testing.

  8. Aaron Bartell reporter

    (Julian steps up to the mic)

    I wouldn't have brought it up if you hadn't already mentioned it publicly. What are the differences of your contributions to this project vs. others like ibmichroot? In short, it's very awkward; especially since I'm the one doing the final compile and distribution to the downloads section of this repo.

    Thanks for the clarification on whether testing is needed.

  9. Former user Account Deleted

    Ah, my own wiki leak. However, rule remains same, patches are cool (10-20 lines), versions are reviewed.

    What are the differences of your contributions to this project vs. others like ibmichroot?

    Chroot is a bunch of scripts. Scripts, well, below any measurable intellectual domain, sort of example stuff (nodejs example, php example, shell example, etc.). Anyone can write scripts (no offence), much more like breathing air. More importantly, breathing air is not reviewed. On other hand, review code, this case, compiled c code arrives from other sources like Perzl, and AIX toolbox. In case of AIX toolbox, of course, legal review already occurred (also IBMers). Perzl, is, of course, independent.

    In short, it's very awkward; especially since I'm the one doing the final compile and distribution to the downloads section of this repo.

    Not sure i understand awkward. Compile a chunk of code seems always same flavour ice cream.

  10. Aaron Bartell reporter

    Not sure i understand awkward. Compile a chunk of code seems always same flavour ice cream.

    Ruby Gems bases delineation on the version of a gem. Or better stated, I can have the same gem with different versions in the same directory (i.e. /ruby/gemset/appname-dev/gems/ibm_db-1.0 vs. /ruby/gemset/appname-dev/gems/ibm_db-1.1) if I follow the Ruby Gem conventions. From a Gemfile I can then lock myself to a particular version of ibm_db. Instead I have to setup completely different directories and manage them for this single gem. And even after I do that I have to insert additional puts statements (i.e. puts 'ibm_db version 2.14.5+5') to confirm the Ruby runtime picked up the version of ibm_db I was expecting.

    In short, it's one more tick mark against doing open source on IBM i. I am not wanting to club the messenger but instead I am asking the Ranger-messenger to deliver this community-message back to the those ( @ThePrez ?) that can gripe to C-level people.

  11. Former user Account Deleted

    Mmm ... i think we may be ok if we added a 4th field to version like 2.14.5.(1-n) for patches to help gem install mechanism. After all we really are just patching code, aka, essentially a PTF/bug fix of current release in IBM i vocabulary.

    so ...

    ASSUMING gem install will work as four level version 2.14.5.n (.5, .6, .7, etc), would this work for you???

    Then, future, if we really update to a new version of ibm_db/ rails, etc., we stay lock step with LUW versioning.

    What do you think???

  12. Aaron Bartell reporter

    That's better because we can actually differentiate. For reference, Ruby Gems use semantic versioning (i.e. 0.0.0). I did find some gems that use a fourth level (i.e. 0.0.0.0) We can do the same.

    I think this is a good approach because I suspect we will need to upgrade ibm_db once PowerRuby supports Rails 5.0.

  13. Former user Account Deleted

    Great problem solved! As 'final compile' person (no good deed you know), can you update project gem spec (git push)? Also give a little test to see 2.14.5.n gem install as you hoped?

    gem.version = '2.5.14'
    --to--
    gem.version = '2.5.14.n'
    
    Where n is any integer you like to represent the 'PTF' (or patch).
    

    BTW -- I watched movie Oblivion other night (Tom Cruise ). 'Are we still an effective team?'

  14. Former user Account Deleted

    In case you did not see movie, only answer is, "Yes, we are an effective team.". Otherwise alien flying robot units 'retire' you immediately. I plan to work forever.

  15. Former user Account Deleted

    issue env handle solved. Open another if you still want to chant about build version issues.

  16. Log in to comment