Skip to content

Commit 924c9d8

Browse files
authored
Merge pull request #374 from dbt-msft/more-nolocks
add nolock to more metadata calls to avoid deadlocks
2 parents 2fdf9be + 2900836 commit 924c9d8

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

dbt/include/sqlserver/macros/adapters/apply_grants.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
select
33
GRANTEE as grantee,
44
PRIVILEGE_TYPE as privilege_type
5-
from INFORMATION_SCHEMA.TABLE_PRIVILEGES
5+
from INFORMATION_SCHEMA.TABLE_PRIVILEGES with (nolock)
66
where TABLE_CATALOG = '{{ relation.database }}'
77
and TABLE_SCHEMA = '{{ relation.schema }}'
88
and TABLE_NAME = '{{ relation.identifier }}'

dbt/include/sqlserver/macros/adapters/columns.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
c.max_length as character_maximum_length,
1010
c.precision as numeric_precision,
1111
c.scale as numeric_scale
12-
from [{{ 'tempdb' if '#' in relation.identifier else relation.database }}].sys.columns c
13-
inner join sys.types t
12+
from [{{ 'tempdb' if '#' in relation.identifier else relation.database }}].sys.columns c with (nolock)
13+
inner join sys.types t with (nolock)
1414
on c.user_type_id = t.user_type_id
1515
where c.object_id = object_id('{{ 'tempdb..' ~ relation.include(database=false, schema=false) if '#' in relation.identifier else relation }}')
1616
)

dbt/include/sqlserver/macros/adapters/metadata.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
column_name,
9393
ordinal_position as column_index,
9494
data_type as column_type
95-
from INFORMATION_SCHEMA.COLUMNS
95+
from INFORMATION_SCHEMA.COLUMNS with (nolock)
9696

9797
)
9898

@@ -129,7 +129,7 @@
129129
{% call statement('list_schemas', fetch_result=True, auto_begin=False) -%}
130130
USE {{ database }};
131131
select name as [schema]
132-
from sys.schemas
132+
from sys.schemas with (nolock)
133133
{% endcall %}
134134
{{ return(load_result('list_schemas').table) }}
135135
{% endmacro %}

0 commit comments

Comments
 (0)