New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Master SQL syntax is used on all shards #48
Comments
Hi @pelizza, Can you provide a failing test for this case? the Octopus spec suite have configuration for running different shards using different databases. btw, What is the query that is going wrong? Thanks, Thiago. |
I have a similar / exactly the same issue: My master DB is MySQL, and I am trying to use shards to connect to a number of MS SQL servers (legacy environments) via tiny-tds. |
Yep, MSSql adapter is pretty complicated. This is a issue between the MSSql adapter and Octopus. I will keep this issue open for future investigation, but keep in mynd that in extreme situations you could rewrite using find_by_sql. Thanks, Thiago |
Hi Thiago, I found a number of issues and some work arounds. Will post both Thomas On Wed, Dec 14, 2011 at 10:18 AM, Thiago Pradi
|
Hi Thiago, Two databases: one sqlite for users and stuff, on SQL Server for orders and stuff, these will be sharded across many in production. core_development: development: shards.yml octopus:
order.rb: Use in development to overcome some oddities...#octopus_establish_connection Octopus.config[Rails.env]['stella'] SQL Server table name and primary id column for Tiny TDSoctopus_set_table_name 'Order' alias_attribute :id, :order_id end run all tests in console: Order.using(:stella).first test2: It works if I change shards.yml so that the SQL server adapter is the master:
Of course that then screws up any and all accesses to the sqlite shards. I found another odditity: In other configurations, it tries to connect to the right shard but with the wrong syntax, e.g. trying to use Limit and Offest on SQL server instead of TOP N, or trying to escape strings with N'some-text' on MySQL ans sqlite (which should only happen on SQL Server.... Thomas |
And one more hint. If I use the first version of the shards.yml file (where SQL server is not the master) and I run this in the console: |
+1 class User < ActiveRecord::Base And User.first works fine in deelopment, but I get a similar error in production maybe because rails doesn't reload the classes in this environment. |
Hi guys, Can you guys confirm if this commit (821c330) solves your issues? Thanks. |
I'm going to close this issue, since I think it's fixed on master. Thanks |
In our current application we have a master wich is a PostgreSQL database and two shards wich are on Ms SQLServer. The problem we are facing is that the PostgreSQL syntax is being used on the queries performed on the shards.
We confirmed this behavior by setting the master as one a SQL Server too.
Here is the query performed on a shard (SQLServer database) generated when a PostgreSQL adapter is master:
SELECT [FASE2].* FROM [FASE2] JOIN fase2_enviar ON fase2.id = fase2_enviar.id LIMIT 50
And here is the 'correct' query when all adapters are SQLServer:
SELECT TOP(50) [FASE2].* FROM [FASE2] JOIN fase2_enviar ON fase2.id = fase2_enviar.id
The text was updated successfully, but these errors were encountered: