Problems displaying this newsletter? View online.
SQL Server Central
Featured Contents
Question of the Day
The Voice of the DBA
 

Large PRs are Bad

I heard a joke years ago that went something like this. When a developer gets a pull request for code review that's 100 lines long, they will open the file(s), look at the code, and ensure standards are being followed. They might run some code, they'd walk through the algorithm in their mind, and spend 10, 20, or more minutes examining how the change is built. If you give them a code review of 1000 lines, they'll just assume it's great and approve it in seconds.

I know that many developers don't find that funny. Often I meet people that think they're professional and they spend the time needed to examine the changes and ensure they work. I'm sure that many people do this often, and some people are very meticulous about their evaluation of the change. However, everyone gets busy and I know that often depending on who submitted the PR and how busy the reviewers are, the joke does reflect reality. The longer the PR, the less likely someone will either a) spend the time to carefully review it, or b) catch small mistakes.

There have been a few large profile outages in 2023, one of which was an Azure DevOps outage in Brazil. I'm not picking on Microsoft as AWS, GitHub, GCP, and others have had issues. I know GitHub is part of Microsoft, but it's also a separate enterprise that really runs on its own in many ways. The point is more that there will be issues, and some of these are related to the rapid changes of a DevOps or GitOps workflow where PRs aren't always reviewed clearly and cleanly.

In this case, there was a typo in how a process worked. A cleanup process was supposed to delete databases in Azure, but the typo had it deleting the logical servers. Those had many databases, not just old ones that needed cleanup. This PR, however, contained a lot of changes, as there was an upgrade to swap out older Azure Manager packages with Resource Manager packages. I don't know if the cleanup job was related here or included in a large PR, but in any case, the PR was reviewed as in the joke above. It was approved and things started failing.

This wasn't caught in testing as there wasn't great test coverage. You can say MS should have more tests, and they should, but there will never be enough test coverage. There also weren't any systems in their ring 0 (first) deployment that triggered this typo, so no one realized there was an issue. Again, ring 0 systems might not be representative of larger rings. Another reality that we aren't likely to fix in every situation.

Microsoft recovered the data, but it took a long time. I don't know how easy or feasible it is to create smaller PRs with something like this when you are upgrading packages in many files. I just know that the time that I make large-scale changes in code, with large PRs, often I find some problem somewhere. Especially if there are changes that aren't all the related. If too many different things get included, the potential for mistakes and problems goes up.

I think this is actually a good DevOps story. They ran their process and there was a mistake. They fixed it and have started to adjust their process to add more testing in this area and potentially ensure this doesn't happen again. The logging helped them diagnose the issue quickly once it was reported. Their ability to deploy on-demand meant that once the problem was understood, a fix could be quickly deployed. That's what DevOps is: it's not perfect, but it does allow us to understand, learn, and adapt quickly.

Now we just need to ensure that humans use the process in a way that other humans can more easily understand, with smaller PRs.

Steve Jones - SSC Editor

Join the debate, and respond to today's editorial on the forums

 
  Featured Contents
SQLServerCentral Article

The Hidden Impact of Microsoft Defender for Azure SQL

The xTEN Team from SQLServerCentral

A problem with the configuration of Microsoft Defender caused all activity on the server to get delayed.

Technical Article

How to Make Database Changes Without Breaking Everything

Additional Articles from SQLServerCentral

You’ve got an existing application with a database back end. You’re thinking about changing the database, and you don’t wanna break stuff.

External Article

Best Practices for Google Cloud Security

Additional Articles from MSSQLTips.com

Security is a concern whether it be on-premises or cloud-native. Google Cloud offers many products and services including SQL Server. What are some of the security controls that should be considered when using Google Cloud services?

Blog Post

From the SQL Server Central Blogs - Creating a Speaking Failures Support Group

Steve Jones - SSC Editor from The Voice of the DBA

Earlier this week the emails went out to speakers who submitted to the PASS Data Community Summit 2023 conference. These were acceptances and rejections, letting people know the results...

Blog Post

From the SQL Server Central Blogs - The two hardest concepts of security are Who? and Where?

Kenneth.Fisher from SQLStudies

I was having a conversation with some friends the other day and Jen McCown (blog|twitter) asked about SQL Server security ... Continue reading

Practical Database Auditing for Microsoft SQL Server and Azure SQL

Practical Database Auditing for Microsoft SQL Server and Azure SQL: Troubleshooting, Regulatory Compliance, and Governance

Site Owners from SQLServerCentral

Know how to track changes and key events in your SQL Server databases in support of application troubleshooting, regulatory compliance, and governance. This book shows how to use key features in SQL Server ,such as SQL Server Audit and Extended Events, to track schema changes, permission changes, and changes to your data. You’ll even learn how to track queries run against specific tables in a database. ss

 

  Question of the Day

Today's question (by Steve Jones - SSC Editor):

 

The Self Referencing CTE

What is returned by this code:
DECLARE @n int = 5; WITH cte(F,n) AS ( SELECT 1 AS F, @n AS n UNION ALL SELECT F*n AS F, n - 1 AS n FROM cte WHERE n > 1 ) SELECT F FROM cte WHERE n = 1 OPTION (MAXRECURSION 4) ; 

Think you know the answer? Click here, and find out if you are right.

 

 

  Yesterday's Question of the Day (by Steve Jones - SSC Editor)

Which Data Comes First?

In a SQL Server 2022 database, I run this code:

CREATE USER apiuser FOR LOGIN apiuser WITH DEFAULT_SCHEMA=webapi GO ALTER ROLE db_datareader ADD MEMBER apiuser GO CREATE TABLE dbo.Location (locationname VARCHAR(20)) GO INSERT dbo.Location (locationname) VALUES ('dbo schema') GO CREATE TABLE webapi.Location (locationname VARCHAR(20)) GO INSERT webapi.Location (locationname) VALUES ('webapi schema') GO CRE

I then log in as apiuser and run this code:

SELECT * FROM location

What is returned?

Answer: webapi schema

Explanation: The default schema for a user is checked first, if a schema isn't specified. Then the dbo schema is checked if an object is not found. Ref: No good reference I can find here, but try the code.

Discuss this question and answer on the forums

 

 

 

Database Pros Who Need Your Help

Here's a few of the new posts today on the forums. To see more, visit the forums.


SQL Server 2016 - Development and T-SQL
Syntax issue while trying to create index on filegroup - Ok so this is driving me nuts.  My syntax is incorrect on this statement: create index IX_Service_Start_Date ON ivc_cds.CDS_Claim_Header (Service_Start_Date ) WITH (FILLFACTOR = 98, SORT_IN_TEMPDB = ON ) on ServiceStartDatePartitionScheme ( Service_Start_Date ) ON [DefFG] Error: Incorrect syntax near the keyword 'ON'. I'm trying to create the above index on the filegroup DefFG.  I've […]
SQL Server 2019 - Development
Cannot resolve the collation conflict on Azure between master database and db - We have an Azure datanbase which up to today has been working fine However after our latest deployment, we are unable to run our application connected neither can I connect Azure Data Studio - Profiler to the Azure database. I get the following error message: Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in […]
Select from view on FileTable throws error - I have a view that computes some fields, using SubString and CharIndex. When I do a Select *, it works great. When I add some conditions, specifying conditions for the COMPUTED FIELDS, the query bombs claiming that invalid arguments were passed to the SubString function.   Those computed fields all get computed correctly - there […]
SQL Azure - Development
Database Snapshot Alternative in SQL MI - Hi, Database Snapshot feature is not supported in SQL MI. Is there an alternative for having point in time readonly copy in same SQL MI.
Reporting Services
SSRS 2019 not able to setup URL Reservations with port 443 - HI . here is the setup i have  - Windows Server 2022 and SSRS 2019  i setup IIS and setup a test site using the SSL cert and that is working fine and since have disabled it i am trying to setup SSRS 2019 to work with HTTPS and it doesn't want to work for […]
'see' and edit text box items when they are obscured by other items - Really new to SSRS Report builder and no training. I have different items and backgrounds that have visibility dependent upon query fields. This means that the items are layered and have differing parent items. I can tab through all the items and adjust their properties but, when it comes to text boxes, I need to […]
Dynamically generate a new instance of a subreport for every selected parameter - Hello. I have 2 parameter fields I'm passing through to a sub-report to get it to populate. They are 'Year' (only 1 selected) and 'ID' (multiple selected). I'd like to dynamically generate a new instance of the sub-report (aka, template) for each selected parameter. For example... Let's say the ID's selected are "1,5,13' and the […]
General
Unintended consequences (Oh sh!t moments) - I firmly believe that one characteristic of good developers is understanding and being able to anticipate unintended consequences.  Today I experienced this in a fairly inconsequential thing, but my analytic mind took over. I was entering an order for K-cups on the Keurig website, and got an error when finalizing the order saying my Mastercard […]
Strategies and Ideas
Hash value in a primary key? - Hello, Problem: in a dwh table, we are getting duplicates based on some fields that represent the primary key of a table, but this is not a true duplicate cause one of the fields come with lower/upper case, and should be considered as sensitive, the issue is that our database is insensitive case so we […]
Contests!
SQL Server 2024 or 2025? - Take a guess when the next version of SQL Server will release. Give me a date, and I'll send a prize to whoever is closest (or maybe 2 people that are equidistant), and posted earliest here. To make it more interesting, if you post in 2023, you get leeway of a week. If you post […]
PostgreSQL
TSQL To Postgres - Unpivot/Union All - I am trying to convert this TSQL:INSERT INTO temp_FieldFlowsFact   SELECT [Account],[Calendar day],[Financial year],[Period] ,CASE WHEN [Metric] like '%R12M%' THEN 'R12M' WHEN [Metric] like '%R6M%' THEN 'R6M' WHEN [Metric] like '%R3M%' THEN 'R3M' ELSE 'Periodic' END AS [Period type] ,[Metric],[Metric Value] FROM ( ----Calculating Rolling FTRs SELECT  [Account], [Calendar day] ,[Financial year],[Period] ,[Issue] ,SUM([Issue]) OVER […]
TSQL To Postgres - Unpivot/Union All - I am trying to convert this TSQL:INSERT INTO temp_FieldFlowsFact   SELECT [Account],[Calendar day],[Financial year],[Period] ,CASE WHEN [Metric] like '%R12M%' THEN 'R12M' WHEN [Metric] like '%R6M%' THEN 'R6M' WHEN [Metric] like '%R3M%' THEN 'R3M' ELSE 'Periodic' END AS [Period type] ,[Metric],[Metric Value] FROM ( ----Calculating Rolling FTRs SELECT  [Account], [Calendar day] ,[Financial year],[Period] ,[Issue] ,SUM([Issue]) OVER […]
Job Postings
SSRS Contractor Needed - Hello, I have someone who has reached out to me in need of a contractor to build out their SSRS environment and make changes to a dashboard I gave them that we use at my current employer. They are also looking for someone with Power BI knowledge that can help them link their on-premises SQL […]
SQL Server 2022 - Administration
Kerberos Configuration Manager connection error with SQL 2022 - Hello experts, I'm trying to use Kerberos Configuration Manager on an instance of SQL Server 2022 and get this error when I try to connect: "Error Unable to connect to server, please ensure that the server name is correct, SQL Server is installed properly, and the user has administrator permissions. If the problem persists, please […]
SQL Server 2022 - Development
How to import csv file into a sql table and include filename - Hi everyone, I have a directory of many csv files such as C:\Temp\NP-001.csv C:\Temp\NP-002.csv C:\Temp\NP-003.csv In each csv file, there are 5 columns: Name, DOB, MemberID, Address, Email We need to somehow loop through each csv file and bulk insert or openrowset information to a sql table. The final result would be like a sql […]
 

 

RSS FeedTwitter

This email has been sent to newsletter@newslettercollector.com. To be removed from this list, please click here. If you have any problems leaving the list, please contact the webmaster@sqlservercentral.com. This newsletter was sent to you because you signed up at SQLServerCentral.com.
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
webmaster@sqlservercentral.com

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -