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

stop explicitly setting sql_auto_is_null to zero #44667

Closed
xiankaing opened this issue Mar 11, 2022 · 1 comment · Fixed by #45134
Closed

stop explicitly setting sql_auto_is_null to zero #44667

xiankaing opened this issue Mar 11, 2022 · 1 comment · Fixed by #45134

Comments

@xiankaing
Copy link

xiankaing commented Mar 11, 2022

Why I'm raising this?

RDS Proxy pins connections if you set variables like sql_auto_is_null
There is a setting to EXCLUDE_VARIABLE_SETS but it is global in nature (all variables).
RDS Proxy allows scaling to many db connections from the rails perspective, without creating tonnes of actual db connections. AWS RDS MySQL maxes out at 16000 connections.
via https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Limits.html

Ask

Consider removing variables['sql_auto_is_null'] = 0 in


Since at least MySQL 5.7 this has been defaulted to false.
https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_sql_auto_is_null
It was defaulted to true in MySQL 5.0
see: https://downloads.mysql.com/docs/refman-5.0-en.pdf page 560 (search for sql_auto_is_null)

System configuration

Rails version:
Rails 4.2.11.3
Ruby version:
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin19]

But this applies to everything using at least MySQL 5.7+
since https://web.archive.org/web/20100315185851/http://dev.rubyonrails.org/ticket/6778 was fixed
(over 10 years ago)

<h2 class="summary" style="font-family: arial, verdana, &quot;Bitstream Vera Sans&quot;, helvetica, sans-serif; font-weight: bold; letter-spacing: -0.018em; font-size: 16px; margin: 0px 0px 0.8em; color: rgb(0, 0, 0); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">PATCH] find :conditions =&gt; 'id is null' returns a record with a non-null id</h2>

Reported by: | timc | Assigned to: | bitsweat
(https://web.archive.org/web/20100315185851/http://dev.rubyonrails.org/ticket/6778#comment:description)PATCH] find :conditions => 'id is null' returns a record with a non-null id
Reported by:	timc	Assigned to:	bitsweat
Priority:	normal	Milestone:	1.2
Component:	ActiveRecord	Version:	1.1.6
Severity:	normal	Keywords:	find mysql null
Cc:			
Description 
Aa is an empty class, subclassing ActiveRecord::Base. It has one column called 'nothing'

a = Aa.new

=> #<Aa:0xb723dacc @new_record=true, @attributes={"nothing"=>nil}>

a.save

=> true

Aa.find(:first, :conditions => 'id is null')

=> #<Aa:0xb7237050 @attributes={"id"=>"3", "nothing"=>nil}>

Aa.find(:first, :conditions => 'id is null')

=> nil

note the two find calls are identical, but the first call returns an unexpected result.

the log says:

SQL (0.000243) BEGIN SQL (0.000226) INSERT INTO aas (nothing) VALUES(NULL) SQL (0.003979) COMMIT Aa Load (0.001234) SELECT * FROM aas WHERE (id is null) LIMIT 1 Aa Load (0.000842) SELECT * FROM aas WHERE (id is null) LIMIT 1

version info: rails 1.1.6 mysql Ver 14.12 Distrib 5.0.26, for pc-linux-gnu (i686) using readline 5.1 mysql 2.7 gem Gentoo Linux
@HParker
Copy link
Contributor

HParker commented Mar 21, 2022

Looks like the default is off all the way back to 5.5: https://downloads.mysql.com/docs/refman-5.5-en.a4.pdf (page 567)

which is the minimum supported version via

if database_version < "5.5.8"
raise "Your version of MySQL (#{database_version}) is too old. Active Record supports MySQL >= 5.5.8."
end

Seems safe to remove it.

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