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

fixing GitPod mysql db, and try opening rails console in a gitpod terminal #8152

Merged
merged 10 commits into from
Jul 21, 2020

Conversation

jywarren
Copy link
Member

@jywarren jywarren commented Jul 16, 2020

Follow-up to #8145

Still seeing:

Wow, that leads us all the way back to: #3120 - it relates to myqsl version number, and this apparently worked on version 5.7. #4266 (comment)

The version GitPod has is: mysql Ver 8.0.20-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))

Alternatively we could insist on mariadb which is what we use in production.

Could we specify this via dockerfile? https://www.gitpod.io/blog/docker-in-gitpod/

i wonder -- could we use our existing Dockerfile? https://github.com/publiclab/plots2/blob/main/Dockerfile#L20 -- i guess?

@gitpod-io
Copy link

gitpod-io bot commented Jul 16, 2020

@codecov
Copy link

codecov bot commented Jul 16, 2020

Codecov Report

Merging #8152 into main will decrease coverage by 0.47%.
The diff coverage is 63.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8152      +/-   ##
==========================================
- Coverage   82.17%   81.69%   -0.48%     
==========================================
  Files         100      100              
  Lines        5755     5845      +90     
==========================================
+ Hits         4729     4775      +46     
- Misses       1026     1070      +44     
Impacted Files Coverage Δ
app/controllers/users_controller.rb 82.16% <ø> (ø)
app/controllers/wiki_controller.rb 85.00% <ø> (ø)
app/models/user.rb 87.68% <0.00%> (+1.28%) ⬆️
app/controllers/spam2_controller.rb 75.59% <56.38%> (-24.41%) ⬇️
app/controllers/admin_controller.rb 80.24% <100.00%> (+0.24%) ⬆️
app/models/comment.rb 77.51% <100.00%> (+0.62%) ⬆️
app/models/node.rb 91.18% <100.00%> (+0.12%) ⬆️
app/models/tag.rb 97.50% <100.00%> (ø)
app/services/execute_search.rb 88.88% <0.00%> (-5.56%) ⬇️
app/api/srch/search.rb 66.24% <0.00%> (-3.83%) ⬇️

@jywarren
Copy link
Member Author

Looks great!!!

@jywarren
Copy link
Member Author

Hmm... looks like there is still an error after #8145 --

Mysql2::Error: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'plots.node.nid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by: SELECT  node.nid, node.status, term_data.*, community_tags.* FROM `term_data` INNER JOIN `community_tags` ON `community_tags`.`tid` = `term_data`.`tid` INNER JOIN `community_tags` `node_tags_term_data_join` ON `node_tags_term_data_join`.`tid` = `term_data`.`tid` INNER JOIN `node` ON `node`.`nid` = `node_tags_term_data_join`.`nid` WHERE (node.status = 1) AND (community_tags.date > 1592278988) AND (name NOT LIKE '%:%') GROUP BY `term_data`.`name` ORDER BY count DESC LIMIT 24 OFFSET 0

at https://3000-f41187a1-294e-4061-8f10-f3a53a87eb09.ws-us02.gitpod.io/tags

We should debug this! Lots of notes back in #8145

@jywarren
Copy link
Member Author

It just looks like the solution:

mysql -e "SET @@global.sql_mode=(SELECT REPLACE(@@global.sql_mode, 'ONLY_FULL_GROUP_BY', ''));"

from #8145 (comment) didn't work. It's weird, I thought I'd confirmed it in the console but i guess I missed something.

We could keep tweaking the mysql config, or we could try switching to mariadb?

@jywarren
Copy link
Member Author

So we're still struggling with this issue:

Piwigo/Piwigo#376

Coming from this section, i believe:

https://github.com/publiclab/plots2/blob/main/app/controllers/tag_controller.rb#L15-L23

@keshavsethi
Copy link
Member

@jywarren it is working fine in #8162 Please review.
Thanks!!

@jywarren jywarren changed the title try opening rails console in a gitpod terminal fixing GitPod mysql db, and try opening rails console in a gitpod terminal Jul 21, 2020
@jywarren
Copy link
Member Author

Looking, this commit solved an identical looking bug in an earlier instance:

4544dc5

@jywarren
Copy link
Member Author

jywarren commented Jul 21, 2020

It involved adding more linked fields to the .group() command. We'd need to add the count -- plots.term_data.count to the select list here:

plots2/app/models/tag.rb

Lines 336 to 345 in c60aaab

def self.trending(limit = 5, start_date = DateTime.now - 1.month, end_date = DateTime.now)
Tag.select([:name])
.joins(:node_tag, :node)
.where('node.status = ?', 1)
.where('node.created > ?', start_date.to_i)
.where('node.created <= ?', end_date.to_i)
.distinct
.order('count DESC')
.limit(limit)
end

@icarito also recommended trying: sql_mode="TRADITIONAL" which i'll try first.

@jywarren
Copy link
Member Author

@icarito unfortunately mysql -e "SET @@global.sql_mode=TRADITIONAL;" didn't seem to work; the error remains. Thanks though!

@jywarren
Copy link
Member Author

We should apply this to this error too, with plots.node_revisions.vid:

Mysql2::Error: Expression #26 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'plots.node_revisions.vid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by: SELECT  `node`.`nid` AS t0_r0, `node`.`vid` AS t0_r1, `node`.`type` AS t0_r2, `node`.`language` AS t0_r3, `node`.`title` AS t0_r4, `node`.`uid` AS t0_r5, `node`.`status` AS t0_r6, `node`.`created` AS t0_r7, `node`.`changed` AS t0_r8, `node`.`comment` AS t0_r9, `node`.`promote` AS t0_r10, `node`.`moderate` AS t0_r11, `node`.`sticky` AS t0_r12, `node`.`tnid` AS t0_r13, `node`.`translate` AS t0_r14, `node`.`cached_likes` AS t0_r15, `node`.`comments_count` AS t0_r16, `node`.`drupal_node_revisions_count` AS t0_r17, `node`.`path` AS t0_r18, `node`.`main_image_id` AS t0_r19, `node`.`slug` AS t0_r20, `node`.`views` AS t0_r21, `node`.`latitude` AS t0_r22, `node`.`longitude` AS t0_r23, `node`.`precision` AS t0_r24, `node_revisions`.`vid` AS t1_r0, `node_revisions`.`nid` AS t1_r1, `node_revisions`.`uid` AS t1_r2, `node_revisions`.`title` AS t1_r3, `node_revisions`.`body` AS t1_r4, `node_revisions`.`teaser` AS t1_r5, `node_revisions`.`log` AS t1_r6, `node_revisions`.`timestamp` AS t1_r7, `node_revisions`.`format` AS t1_r8, `node_revisions`.`status` AS t1_r9 FROM `node` LEFT OUTER JOIN `node_revisions` ON `node_revisions`.`nid` = `node`.`nid` WHERE (node_revisions.status = 1 AND node.status = 1 AND (type = 'page' OR type = 'tool' OR type = 'place')) GROUP BY node_revisions.nid ORDER BY node_revisions.timestamp DESC LIMIT 30 OFFSET 0 excluded from capture: Not configured to send/capture in environment 'development'

@wikis = Node.includes(:revision)
.references(:node_revisions)
.group('node_revisions.nid')
.order(order_string)
.where("node_revisions.status = 1 AND node.status = 1 AND (type = 'page' OR type = 'tool' OR type = 'place')")
.page(params[:page])

It might need to be changed on other pages further down, too!

@jywarren
Copy link
Member Author

Interesting! Prior to this, it looks like our settings /had/ worked, because in #8107 we see this error:

Mysql2::Error: Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'plots.community_tags.uid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by: SELECT `community_tags`.* FROM `community_tags` LEFT OUTER JOIN `term_data` ON `term_data`.`tid` = `community_tags`.`tid` LEFT OUTER JOIN `tag_selections` ON `tag_selections`.`tid` = `community_tags`.`tid` WHERE (nid = 8 AND community_tags.tid IN (2,73,75)) GROUP BY `community_tags`.`tid` ORDER BY count(tag_selections.user_id) DESC

Key: Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'plots.community_tags.uid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by -- so hopefully removing that setting and refactoring the other queries will help solve that too.

@jywarren
Copy link
Member Author

A

@jywarren jywarren closed this Jul 21, 2020
@jywarren jywarren reopened this Jul 21, 2020
@gitpod-io
Copy link

gitpod-io bot commented Jul 21, 2020

@jywarren
Copy link
Member Author

Oops, going to let this prebuild because i skipped and so it didn't undo that setting and still had an error on this page: https://3000-ccc8eba5-7723-4c89-9232-f9598f2cf475.ws-us02.gitpod.io/notes/admin/07-21-2020/blog-post

@jywarren
Copy link
Member Author

jywarren commented Jul 21, 2020

Hmm. I'm still seeing the this is incompatible with sql_mode=only_full_group_by from above. Not sure why...

Aha - ok, added another fixed group()!

@jywarren
Copy link
Member Author

That seems to have worked, but we now have:

Mysql2::Error: Expression #4 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'plots.community_tags.date' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by: SELECT `community_tags`.* FROM `community_tags` LEFT OUTER JOIN `term_data` ON `term_data`.`tid` = `community_tags`.`tid` LEFT OUTER JOIN `tag_selections` ON `tag_selections`.`tid` = `community_tags`.`tid` WHERE (nid = 8 AND community_tags.tid IN (2,76,73,74)) GROUP BY community_tags.tid, community_tags.uid ORDER BY count(tag_selections.user_id) DESC

@jywarren jywarren requested a review from a team as a code owner July 21, 2020 19:54
@jywarren
Copy link
Member Author

I think we've got this now. I've confirmed by browsing around a lot in GitPod!

@jywarren jywarren merged commit 122e8a7 into main Jul 21, 2020
@jywarren
Copy link
Member Author

🎉 🎉

dms-yondy pushed a commit to dms-yondy/plots2 that referenced this pull request Aug 7, 2020
…minal (publiclab#8152)

* try opening rails console in a gitpod terminal

* trying mysql -e "SET @@global.sql_mode=TRADITIONAL;"

* Tag.select('term_data.name, plots.term_data.count')

* 3 changes for "SELECT list is not in GROUP BY clause and contains nonaggregated column"

* Update .gitpod.yml

* Update node.rb

* add community_tags.date to group() in normal_tags()

* group by community_tags.created_at too

* added community_tags.updated_at and now it works!!!

* users controller group - node.nid, node_revisions.vid
nadimakhtar97 pushed a commit to nadimakhtar97/plots2 that referenced this pull request Sep 21, 2020
…minal (publiclab#8152)

* try opening rails console in a gitpod terminal

* trying mysql -e "SET @@global.sql_mode=TRADITIONAL;"

* Tag.select('term_data.name, plots.term_data.count')

* 3 changes for "SELECT list is not in GROUP BY clause and contains nonaggregated column"

* Update .gitpod.yml

* Update node.rb

* add community_tags.date to group() in normal_tags()

* group by community_tags.created_at too

* added community_tags.updated_at and now it works!!!

* users controller group - node.nid, node_revisions.vid
shubhangikori pushed a commit to shubhangikori/plots2 that referenced this pull request Oct 12, 2020
…minal (publiclab#8152)

* try opening rails console in a gitpod terminal

* trying mysql -e "SET @@global.sql_mode=TRADITIONAL;"

* Tag.select('term_data.name, plots.term_data.count')

* 3 changes for "SELECT list is not in GROUP BY clause and contains nonaggregated column"

* Update .gitpod.yml

* Update node.rb

* add community_tags.date to group() in normal_tags()

* group by community_tags.created_at too

* added community_tags.updated_at and now it works!!!

* users controller group - node.nid, node_revisions.vid
alvesitalo pushed a commit to alvesitalo/plots2 that referenced this pull request Oct 14, 2020
…minal (publiclab#8152)

* try opening rails console in a gitpod terminal

* trying mysql -e "SET @@global.sql_mode=TRADITIONAL;"

* Tag.select('term_data.name, plots.term_data.count')

* 3 changes for "SELECT list is not in GROUP BY clause and contains nonaggregated column"

* Update .gitpod.yml

* Update node.rb

* add community_tags.date to group() in normal_tags()

* group by community_tags.created_at too

* added community_tags.updated_at and now it works!!!

* users controller group - node.nid, node_revisions.vid
piyushswain pushed a commit to piyushswain/plots2 that referenced this pull request Oct 22, 2020
…minal (publiclab#8152)

* try opening rails console in a gitpod terminal

* trying mysql -e "SET @@global.sql_mode=TRADITIONAL;"

* Tag.select('term_data.name, plots.term_data.count')

* 3 changes for "SELECT list is not in GROUP BY clause and contains nonaggregated column"

* Update .gitpod.yml

* Update node.rb

* add community_tags.date to group() in normal_tags()

* group by community_tags.created_at too

* added community_tags.updated_at and now it works!!!

* users controller group - node.nid, node_revisions.vid
manchere pushed a commit to manchere/plots2 that referenced this pull request Feb 13, 2021
…minal (publiclab#8152)

* try opening rails console in a gitpod terminal

* trying mysql -e "SET @@global.sql_mode=TRADITIONAL;"

* Tag.select('term_data.name, plots.term_data.count')

* 3 changes for "SELECT list is not in GROUP BY clause and contains nonaggregated column"

* Update .gitpod.yml

* Update node.rb

* add community_tags.date to group() in normal_tags()

* group by community_tags.created_at too

* added community_tags.updated_at and now it works!!!

* users controller group - node.nid, node_revisions.vid
lagunasmel pushed a commit to lagunasmel/plots2 that referenced this pull request Mar 2, 2021
…minal (publiclab#8152)

* try opening rails console in a gitpod terminal

* trying mysql -e "SET @@global.sql_mode=TRADITIONAL;"

* Tag.select('term_data.name, plots.term_data.count')

* 3 changes for "SELECT list is not in GROUP BY clause and contains nonaggregated column"

* Update .gitpod.yml

* Update node.rb

* add community_tags.date to group() in normal_tags()

* group by community_tags.created_at too

* added community_tags.updated_at and now it works!!!

* users controller group - node.nid, node_revisions.vid
reginaalyssa pushed a commit to reginaalyssa/plots2 that referenced this pull request Oct 16, 2021
…minal (publiclab#8152)

* try opening rails console in a gitpod terminal

* trying mysql -e "SET @@global.sql_mode=TRADITIONAL;"

* Tag.select('term_data.name, plots.term_data.count')

* 3 changes for "SELECT list is not in GROUP BY clause and contains nonaggregated column"

* Update .gitpod.yml

* Update node.rb

* add community_tags.date to group() in normal_tags()

* group by community_tags.created_at too

* added community_tags.updated_at and now it works!!!

* users controller group - node.nid, node_revisions.vid
ampwang pushed a commit to ampwang/plots2 that referenced this pull request Oct 26, 2021
…minal (publiclab#8152)

* try opening rails console in a gitpod terminal

* trying mysql -e "SET @@global.sql_mode=TRADITIONAL;"

* Tag.select('term_data.name, plots.term_data.count')

* 3 changes for "SELECT list is not in GROUP BY clause and contains nonaggregated column"

* Update .gitpod.yml

* Update node.rb

* add community_tags.date to group() in normal_tags()

* group by community_tags.created_at too

* added community_tags.updated_at and now it works!!!

* users controller group - node.nid, node_revisions.vid
billymoroney1 pushed a commit to billymoroney1/plots2 that referenced this pull request Dec 28, 2021
…minal (publiclab#8152)

* try opening rails console in a gitpod terminal

* trying mysql -e "SET @@global.sql_mode=TRADITIONAL;"

* Tag.select('term_data.name, plots.term_data.count')

* 3 changes for "SELECT list is not in GROUP BY clause and contains nonaggregated column"

* Update .gitpod.yml

* Update node.rb

* add community_tags.date to group() in normal_tags()

* group by community_tags.created_at too

* added community_tags.updated_at and now it works!!!

* users controller group - node.nid, node_revisions.vid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants