Skip to content
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

Rooms model's method select_server gives error on postgres #4

Closed
naumenko opened this issue Aug 3, 2012 · 5 comments
Closed

Rooms model's method select_server gives error on postgres #4

naumenko opened this issue Aug 3, 2012 · 5 comments
Labels

Comments

@naumenko
Copy link

naumenko commented Aug 3, 2012

Just to let you know this method on postgres gives error

This method can be overridden to change the way the server is selected

before a room is created

This one selects the server with less rooms in it

def select_server
BigbluebuttonServer.
select("bigbluebutton_servers.*, count(bigbluebutton_rooms.id) as room_count").
joins(:rooms).group(:server_id).order("room_count ASC").first
end

Error:
ActiveRecord::StatementInvalid (PG::Error: ERROR: column "bigbluebutton_servers.id" must appear in the GROUP BY clause or be used in an aggregate function

@naumenko
Copy link
Author

naumenko commented Aug 3, 2012

One more thing is that when server was already assigned to the room, then there is no need (or even against user's selection) to forcibly select another server with less number of rooms

@daronco
Copy link
Member

daronco commented Aug 20, 2012

@naumenko thanks for the issue. We haven't used it with postgres yet, so I didn't know about this error. If you found a way to fix it and are willing to submit a pull request it would be great. Otherwise I'll try it someday in the future.

Also, you are probably right about the selection of servers. The idea was to dynamically select a server when a meeting is about to be started (https://github.com/mconf/bigbluebutton_rails/blob/master/app/models/bigbluebutton_room.rb#L119), as a way to balance the load. But that's not really effective and it's not the best way to do it. It as well might be better to let the application associate servers and rooms.
If you have any ideas about this, feel free to suggest here!

@mkuchhal
Copy link

I found a solution for the PG error; just replace the parameter in the group_by clause. The second line of the query should look like this:

joins(:rooms).group("bigbluebutton_servers.id").order("room_count ASC").first

I can create a pull request for this but I dont have a mysql server setup and so wont be able to test against that.

Hopefully that helped though it is 2 years too late.

@daronco
Copy link
Member

daronco commented Sep 25, 2014

@mkuchhal, yes, send a pull request, please. If the changes are really that small, we can start testing the gem on mysql and postgres to support both.

@daronco
Copy link
Member

daronco commented Feb 11, 2016

Closing this because it's an old issue. If PostgreSQL is supported in the future, this will be solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants