Tuesday, March 20, 2012
background color and background image after SP1
after installing sp1 for sql server 2005 the properties "background
color" and "background image" do not show in HTML. They do show in TIF
or PDF export. Also the header and footer are rendered correctly in
HTML. Only the body of the report is always white!
Any suggestions?
Thank you
BennoI too am having this problem. I have found the following on the MS site. I
believe this applies to the problem, however, I have not tried this solution.
http://support.microsoft.com/?kbid=921395
"Benno" wrote:
> Hi,
> after installing sp1 for sql server 2005 the properties "background
> color" and "background image" do not show in HTML. They do show in TIF
> or PDF export. Also the header and footer are rendered correctly in
> HTML. Only the body of the report is always white!
> Any suggestions?
> Thank you
> Benno
>
Thursday, March 8, 2012
AWE RAM (SQL 2K not recognizing available AWE RAM)
with SP3. The boot.ini is set with /3gb /PAE. The server
system properties list 8GB of RAM. Within SQL Server
sp_configure AWE running is set to 1. SQL Server Memory
properties the Maximum is set to 5.12 GB. But SQL Server
does not recognize AWE setting. I look in the SQL Server
errorlog after the server was rebooted and did not list
AWE memory settings. The Server Performance Monitor
Counter under SQL Server Memory Manager with Target Server
Memory list 2.7GB. This should be 5.12 GB of memory for
SQL Server.
Please help me resolve this problem.
Mike
________________________________________
__________________
[boot loader]
timeout=10
default=multi(0)disk(0)rdisk(0)partition
(1)\WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINN
T="Microsoft
Windows 2000 Advanced Server" /fastdetect /3gb /PAE
________________________________________
___________________
sp_configure "show advanced options", 1
RECONFIGURE
GO
sp_configure "awe enabled", 1
RECONFIGURE
GO
sp_configure "max server memory", 5120
RECONFIGURE
GO
sp_configure "min server memory", 0
RECONFIGURE
GO
________________________________________
___________________
Output from SP_CONFIGURE
name minimum
maximum config_value run_value
-- -- --
-- --
affinity mask -2147483648
2147483647 0 0
allow updates 0
1 0 0
awe enabled 0
1 1 1
c2 audit mode 0
1 0 0
cost threshold for parallelism 0
32767 5 5
Cross DB Ownership Chaining 0
1 0 0
cursor threshold -1
2147483647 -1 -1
default full-text language 0
2147483647 1033 1033
default language 0
9999 0 0
fill factor (%) 0
100 0 0
index create memory (KB) 704
2147483647 0 0
lightweight pooling 0
1 0 0
locks 5000
2147483647 0 0
max degree of parallelism 0
32 0 0
max server memory (MB) 4
2147483647 5120 5120
max text repl size (B) 0
2147483647 65536 65536
max worker threads 32
32767 255 255
media retention 0
365 0 0
min memory per query (KB) 512
2147483647 1024 1024
min server memory (MB) 0
2147483647 0 0
nested triggers 0
1 1 1
network packet size (B) 512
65536 4096 4096
open objects 0
2147483647 0 0
priority boost 0
1 0 0
query governor cost limit 0
2147483647 0 0
query wait (s) -1
2147483647 -1 -1
recovery interval (min) 0
32767 0 0
remote access 0
1 1 1
remote login timeout (s) 0
2147483647 20 20
remote proc trans 0
1 0 0
remote query timeout (s) 0
2147483647 600 600
scan for startup procs 0
1 1 0
set working set size 0
1 0 0
show advanced options 0
1 1 1
two digit year cutoff 1753
9999 2049 2049
user connections 0
32767 0 0
user options 0
32767 56 56> I have a server with SQL Server 2000 Enterprise Edition
> with SP3. The boot.ini is set with /3gb /PAE. The server
> system properties list 8GB of RAM. Within SQL Server
> sp_configure AWE running is set to 1. SQL Server Memory
> properties the Maximum is set to 5.12 GB. But SQL Server
> does not recognize AWE setting. I look in the SQL Server
> errorlog after the server was rebooted and did not list
> AWE memory settings. The Server Performance Monitor
> Counter under SQL Server Memory Manager with Target Server
> Memory list 2.7GB. This should be 5.12 GB of memory for
> SQL Server.
> Please help me resolve this problem.
> Mike
> ________________________________________
__________________
> [boot loader]
> timeout=10
> default=multi(0)disk(0)rdisk(0)partition
(1)\WINNT
> [operating systems]
> multi(0)disk(0)rdisk(0)partition(1)\WINN
T="Microsoft
> Windows 2000 Advanced Server" /fastdetect /3gb /PAE
> ________________________________________
___________________
> sp_configure "show advanced options", 1
> RECONFIGURE
> GO
> sp_configure "awe enabled", 1
> RECONFIGURE
> GO
> sp_configure "max server memory", 5120
> RECONFIGURE
> GO
> sp_configure "min server memory", 0
> RECONFIGURE
> GO
> ________________________________________
___________________
> Output from SP_CONFIGURE
> name minimum
> maximum config_value run_value
> -- -- --
> -- --
> affinity mask -2147483648
> 2147483647 0 0
> allow updates 0
> 1 0 0
> awe enabled 0
> 1 1 1
> c2 audit mode 0
> 1 0 0
> cost threshold for parallelism 0
> 32767 5 5
> Cross DB Ownership Chaining 0
> 1 0 0
> cursor threshold -1
> 2147483647 -1 -1
> default full-text language 0
> 2147483647 1033 1033
> default language 0
> 9999 0 0
> fill factor (%) 0
> 100 0 0
> index create memory (KB) 704
> 2147483647 0 0
> lightweight pooling 0
> 1 0 0
> locks 5000
> 2147483647 0 0
> max degree of parallelism 0
> 32 0 0
> max server memory (MB) 4
> 2147483647 5120 5120
> max text repl size (B) 0
> 2147483647 65536 65536
> max worker threads 32
> 32767 255 255
> media retention 0
> 365 0 0
> min memory per query (KB) 512
> 2147483647 1024 1024
> min server memory (MB) 0
> 2147483647 0 0
> nested triggers 0
> 1 1 1
> network packet size (B) 512
> 65536 4096 4096
> open objects 0
> 2147483647 0 0
> priority boost 0
> 1 0 0
> query governor cost limit 0
> 2147483647 0 0
> query wait (s) -1
> 2147483647 -1 -1
> recovery interval (min) 0
> 32767 0 0
> remote access 0
> 1 1 1
> remote login timeout (s) 0
> 2147483647 20 20
> remote proc trans 0
> 1 0 0
> remote query timeout (s) 0
> 2147483647 600 600
> scan for startup procs 0
> 1 1 0
> set working set size 0
> 1 0 0
> show advanced options 0
> 1 1 1
> two digit year cutoff 1753
> 9999 2049 2049
> user connections 0
> 32767 0 0
> user options 0
> 32767 56 56
--
Hi Mike,
Check that the SQL Server startup account has the Lock Pages in Memory
privilege:
http://msdn.microsoft.com/library/d...-us/adminsql/ad
_1_server_1fnd.asp
Eric Crdenas
Senior support professional
This posting is provided "AS IS" with no warranties, and confers no rights.|||I already suggested that...
Andrew J. Kelly SQL MVP
"Eric Crdenas [MSFT]" <ecardena@.online.microsoft.com> wrote in message
news:dAsRybjNEHA.308@.cpmsftngxa10.phx.gbl...
> --
> Hi Mike,
> Check that the SQL Server startup account has the 'Lock Pages in Memory'
> privilege:
>
http://msdn.microsoft.com/library/d...-us/adminsql/ad
> _1_server_1fnd.asp
> --
> Eric Crdenas
> Senior support professional
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
AWE RAM (SQL 2K not recognizing available AWE RAM)
with SP3. The boot.ini is set with /3gb /PAE. The server
system properties list 8GB of RAM. Within SQL Server
sp_configure AWE running is set to 1. SQL Server Memory
properties the Maximum is set to 5.12 GB. But SQL Server
does not recognize AWE setting. I look in the SQL Server
errorlog after the server was rebooted and did not list
AWE memory settings. The Server Performance Monitor
Counter under SQL Server Memory Manager with Target Server
Memory list 2.7GB. This should be 5.12 GB of memory for
SQL Server.
Please help me resolve this problem.
Mike
__________________________________________________ ________
[boot loader]
timeout=10
default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microso ft
Windows 2000 Advanced Server" /fastdetect /3gb /PAE
__________________________________________________ _________
sp_configure "show advanced options", 1
RECONFIGURE
GO
sp_configure "awe enabled", 1
RECONFIGURE
GO
sp_configure "max server memory", 5120
RECONFIGURE
GO
sp_configure "min server memory", 0
RECONFIGURE
GO
__________________________________________________ _________
Output from SP_CONFIGURE
name minimum
maximum config_value run_value
-- -- --
-- --
affinity mask -2147483648
2147483647 0 0
allow updates 0
1 0 0
awe enabled 0
1 1 1
c2 audit mode 0
1 0 0
cost threshold for parallelism 0
32767 5 5
Cross DB Ownership Chaining 0
1 0 0
cursor threshold -1
2147483647 -1 -1
default full-text language 0
2147483647 1033 1033
default language 0
9999 0 0
fill factor (%) 0
100 0 0
index create memory (KB) 704
2147483647 0 0
lightweight pooling 0
1 0 0
locks 5000
2147483647 0 0
max degree of parallelism 0
32 0 0
max server memory (MB) 4
2147483647 5120 5120
max text repl size (B) 0
2147483647 65536 65536
max worker threads 32
32767 255 255
media retention 0
365 0 0
min memory per query (KB) 512
2147483647 1024 1024
min server memory (MB) 0
2147483647 0 0
nested triggers 0
1 1 1
network packet size (B) 512
65536 4096 4096
open objects 0
2147483647 0 0
priority boost 0
1 0 0
query governor cost limit 0
2147483647 0 0
query wait (s) -1
2147483647 -1 -1
recovery interval (min) 0
32767 0 0
remote access 0
1 1 1
remote login timeout (s) 0
2147483647 20 20
remote proc trans 0
1 0 0
remote query timeout (s) 0
2147483647 600 600
scan for startup procs 0
1 1 0
set working set size 0
1 0 0
show advanced options 0
1 1 1
two digit year cutoff 1753
9999 2049 2049
user connections 0
32767 0 0
user options 0
32767 56 56
> I have a server with SQL Server 2000 Enterprise Edition
> with SP3. The boot.ini is set with /3gb /PAE. The server
> system properties list 8GB of RAM. Within SQL Server
> sp_configure AWE running is set to 1. SQL Server Memory
> properties the Maximum is set to 5.12 GB. But SQL Server
> does not recognize AWE setting. I look in the SQL Server
> errorlog after the server was rebooted and did not list
> AWE memory settings. The Server Performance Monitor
> Counter under SQL Server Memory Manager with Target Server
> Memory list 2.7GB. This should be 5.12 GB of memory for
> SQL Server.
> Please help me resolve this problem.
> Mike
> __________________________________________________ ________
> [boot loader]
> timeout=10
> default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
> [operating systems]
> multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microso ft
> Windows 2000 Advanced Server" /fastdetect /3gb /PAE
> __________________________________________________ _________
> sp_configure "show advanced options", 1
> RECONFIGURE
> GO
> sp_configure "awe enabled", 1
> RECONFIGURE
> GO
> sp_configure "max server memory", 5120
> RECONFIGURE
> GO
> sp_configure "min server memory", 0
> RECONFIGURE
> GO
> __________________________________________________ _________
> Output from SP_CONFIGURE
> name minimum
> maximum config_value run_value
> -- -- --
> -- --
> affinity mask -2147483648
> 2147483647 0 0
> allow updates 0
> 1 0 0
> awe enabled 0
> 1 1 1
> c2 audit mode 0
> 1 0 0
> cost threshold for parallelism 0
> 32767 5 5
> Cross DB Ownership Chaining 0
> 1 0 0
> cursor threshold -1
> 2147483647 -1 -1
> default full-text language 0
> 2147483647 1033 1033
> default language 0
> 9999 0 0
> fill factor (%) 0
> 100 0 0
> index create memory (KB) 704
> 2147483647 0 0
> lightweight pooling 0
> 1 0 0
> locks 5000
> 2147483647 0 0
> max degree of parallelism 0
> 32 0 0
> max server memory (MB) 4
> 2147483647 5120 5120
> max text repl size (B) 0
> 2147483647 65536 65536
> max worker threads 32
> 32767 255 255
> media retention 0
> 365 0 0
> min memory per query (KB) 512
> 2147483647 1024 1024
> min server memory (MB) 0
> 2147483647 0 0
> nested triggers 0
> 1 1 1
> network packet size (B) 512
> 65536 4096 4096
> open objects 0
> 2147483647 0 0
> priority boost 0
> 1 0 0
> query governor cost limit 0
> 2147483647 0 0
> query wait (s) -1
> 2147483647 -1 -1
> recovery interval (min) 0
> 32767 0 0
> remote access 0
> 1 1 1
> remote login timeout (s) 0
> 2147483647 20 20
> remote proc trans 0
> 1 0 0
> remote query timeout (s) 0
> 2147483647 600 600
> scan for startup procs 0
> 1 1 0
> set working set size 0
> 1 0 0
> show advanced options 0
> 1 1 1
> two digit year cutoff 1753
> 9999 2049 2049
> user connections 0
> 32767 0 0
> user options 0
> 32767 56 56
Hi Mike,
Check that the SQL Server startup account has the Lock Pages in Memory
privilege:
http://msdn.microsoft.com/library/de...us/adminsql/ad
_1_server_1fnd.asp
Eric Crdenas
Senior support professional
This posting is provided "AS IS" with no warranties, and confers no rights.
|||I already suggested that...
Andrew J. Kelly SQL MVP
"Eric Crdenas [MSFT]" <ecardena@.online.microsoft.com> wrote in message
news:dAsRybjNEHA.308@.cpmsftngxa10.phx.gbl...
> --
> Hi Mike,
> Check that the SQL Server startup account has the 'Lock Pages in Memory'
> privilege:
>
http://msdn.microsoft.com/library/de...us/adminsql/ad
> _1_server_1fnd.asp
> --
> Eric Crdenas
> Senior support professional
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
AWE RAM (SQL 2K not recognizing available AWE RAM)
The boot.ini is set with /3gb /PAE. The server system properties list 8GB of RAM. Within SQL Server sp_configure AWE running is set to 1. SQL Server Memory properties the Maximum is set to 5.12 GB. But SQL Server does not recognize AWE setting.
I look in the SQL Server errorlog after the server was rebooted and did not list AWE memory settings.
The Server Performance Monitor Counter under SQL Server Memory Manager with Target Server Memory list 2.7GB.
This should be 5.12 GB of memory for SQL Server.
Please help me resolve this problem.
Mike
__________________________________________________________
[boot loader]
timeout=10
default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft
Windows 2000 Advanced Server" /fastdetect /3gb /PAE
___________________________________________________________
sp_configure "show advanced options", 1
RECONFIGURE
GO
sp_configure "awe enabled", 1
RECONFIGURE
GO
sp_configure "max server memory", 5120
RECONFIGURE
GO
sp_configure "min server memory", 0
RECONFIGURE
GO
___________________________________________________________
Output from SP_CONFIGURE
name minimum
maximum config_value run_value
-- -- --
-- --
affinity mask -2147483648
2147483647 0 0
allow updates 0
1 0 0
awe enabled 0
1 1 1
c2 audit mode 0
1 0 0
cost threshold for parallelism 0
32767 5 5
Cross DB Ownership Chaining 0
1 0 0
cursor threshold -1
2147483647 -1 -1
default full-text language 0
2147483647 1033 1033
default language 0
9999 0 0
fill factor (%) 0
100 0 0
index create memory (KB) 704
2147483647 0 0
lightweight pooling 0
1 0 0
locks 5000
2147483647 0 0
max degree of parallelism 0
32 0 0
max server memory (MB) 4
2147483647 5120 5120
max text repl size (B) 0
2147483647 65536 65536
max worker threads 32
32767 255 255
media retention 0
365 0 0
min memory per query (KB) 512
2147483647 1024 1024
min server memory (MB) 0
2147483647 0 0
nested triggers 0
1 1 1
network packet size (B) 512
65536 4096 4096
open objects 0
2147483647 0 0
priority boost 0
1 0 0
query governor cost limit 0
2147483647 0 0
query wait (s) -1
2147483647 -1 -1
recovery interval (min) 0
32767 0 0
remote access 0
1 1 1
remote login timeout (s) 0
2147483647 20 20
remote proc trans 0
1 0 0
remote query timeout (s) 0
2147483647 600 600
scan for startup procs 0
1 1 0
set working set size 0
1 0 0
show advanced options 0
1 1 1
two digit year cutoff 1753
9999 2049 2049
user connections 0
32767 0 0
user options 0
32767 56 56> I have a server with SQL Server 2000 Enterprise Edition
> with SP3. The boot.ini is set with /3gb /PAE. The server
> system properties list 8GB of RAM. Within SQL Server
> sp_configure AWE running is set to 1. SQL Server Memory
> properties the Maximum is set to 5.12 GB. But SQL Server
> does not recognize AWE setting. I look in the SQL Server
> errorlog after the server was rebooted and did not list
> AWE memory settings. The Server Performance Monitor
> Counter under SQL Server Memory Manager with Target Server
> Memory list 2.7GB. This should be 5.12 GB of memory for
> SQL Server.
> Please help me resolve this problem.
> Mike
> __________________________________________________________
> [boot loader]
> timeout=10
> default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
> [operating systems]
> multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft
> Windows 2000 Advanced Server" /fastdetect /3gb /PAE
> ___________________________________________________________
> sp_configure "show advanced options", 1
> RECONFIGURE
> GO
> sp_configure "awe enabled", 1
> RECONFIGURE
> GO
> sp_configure "max server memory", 5120
> RECONFIGURE
> GO
> sp_configure "min server memory", 0
> RECONFIGURE
> GO
> ___________________________________________________________
> Output from SP_CONFIGURE
> name minimum
> maximum config_value run_value
> -- -- --
> -- --
> affinity mask -2147483648
> 2147483647 0 0
> allow updates 0
> 1 0 0
> awe enabled 0
> 1 1 1
> c2 audit mode 0
> 1 0 0
> cost threshold for parallelism 0
> 32767 5 5
> Cross DB Ownership Chaining 0
> 1 0 0
> cursor threshold -1
> 2147483647 -1 -1
> default full-text language 0
> 2147483647 1033 1033
> default language 0
> 9999 0 0
> fill factor (%) 0
> 100 0 0
> index create memory (KB) 704
> 2147483647 0 0
> lightweight pooling 0
> 1 0 0
> locks 5000
> 2147483647 0 0
> max degree of parallelism 0
> 32 0 0
> max server memory (MB) 4
> 2147483647 5120 5120
> max text repl size (B) 0
> 2147483647 65536 65536
> max worker threads 32
> 32767 255 255
> media retention 0
> 365 0 0
> min memory per query (KB) 512
> 2147483647 1024 1024
> min server memory (MB) 0
> 2147483647 0 0
> nested triggers 0
> 1 1 1
> network packet size (B) 512
> 65536 4096 4096
> open objects 0
> 2147483647 0 0
> priority boost 0
> 1 0 0
> query governor cost limit 0
> 2147483647 0 0
> query wait (s) -1
> 2147483647 -1 -1
> recovery interval (min) 0
> 32767 0 0
> remote access 0
> 1 1 1
> remote login timeout (s) 0
> 2147483647 20 20
> remote proc trans 0
> 1 0 0
> remote query timeout (s) 0
> 2147483647 600 600
> scan for startup procs 0
> 1 1 0
> set working set size 0
> 1 0 0
> show advanced options 0
> 1 1 1
> two digit year cutoff 1753
> 9999 2049 2049
> user connections 0
> 32767 0 0
> user options 0
> 32767 56 56
--
Hi Mike,
Check that the SQL Server startup account has the ?Lock Pages in Memory?
privilege:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adminsql/ad
_1_server_1fnd.asp
--
Eric Cárdenas
Senior support professional
This posting is provided "AS IS" with no warranties, and confers no rights.|||I already suggested that...
--
Andrew J. Kelly SQL MVP
"Eric Cárdenas [MSFT]" <ecardena@.online.microsoft.com> wrote in message
news:dAsRybjNEHA.308@.cpmsftngxa10.phx.gbl...
> > I have a server with SQL Server 2000 Enterprise Edition
> > with SP3. The boot.ini is set with /3gb /PAE. The server
> > system properties list 8GB of RAM. Within SQL Server
> > sp_configure AWE running is set to 1. SQL Server Memory
> > properties the Maximum is set to 5.12 GB. But SQL Server
> > does not recognize AWE setting. I look in the SQL Server
> > errorlog after the server was rebooted and did not list
> > AWE memory settings. The Server Performance Monitor
> > Counter under SQL Server Memory Manager with Target Server
> > Memory list 2.7GB. This should be 5.12 GB of memory for
> > SQL Server.
> >
> > Please help me resolve this problem.
> >
> > Mike
> >
> > __________________________________________________________
> > [boot loader]
> > timeout=10
> > default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
> > [operating systems]
> > multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft
> > Windows 2000 Advanced Server" /fastdetect /3gb /PAE
> > ___________________________________________________________
> > sp_configure "show advanced options", 1
> > RECONFIGURE
> > GO
> > sp_configure "awe enabled", 1
> > RECONFIGURE
> > GO
> > sp_configure "max server memory", 5120
> > RECONFIGURE
> > GO
> > sp_configure "min server memory", 0
> > RECONFIGURE
> > GO
> > ___________________________________________________________
> > Output from SP_CONFIGURE
> > name minimum
> > maximum config_value run_value
> > -- -- --
> > -- --
> > affinity mask -2147483648
> > 2147483647 0 0
> > allow updates 0
> > 1 0 0
> > awe enabled 0
> > 1 1 1
> > c2 audit mode 0
> > 1 0 0
> > cost threshold for parallelism 0
> > 32767 5 5
> > Cross DB Ownership Chaining 0
> > 1 0 0
> > cursor threshold -1
> > 2147483647 -1 -1
> > default full-text language 0
> > 2147483647 1033 1033
> > default language 0
> > 9999 0 0
> > fill factor (%) 0
> > 100 0 0
> > index create memory (KB) 704
> > 2147483647 0 0
> > lightweight pooling 0
> > 1 0 0
> > locks 5000
> > 2147483647 0 0
> > max degree of parallelism 0
> > 32 0 0
> > max server memory (MB) 4
> > 2147483647 5120 5120
> > max text repl size (B) 0
> > 2147483647 65536 65536
> > max worker threads 32
> > 32767 255 255
> > media retention 0
> > 365 0 0
> > min memory per query (KB) 512
> > 2147483647 1024 1024
> > min server memory (MB) 0
> > 2147483647 0 0
> > nested triggers 0
> > 1 1 1
> > network packet size (B) 512
> > 65536 4096 4096
> > open objects 0
> > 2147483647 0 0
> > priority boost 0
> > 1 0 0
> > query governor cost limit 0
> > 2147483647 0 0
> > query wait (s) -1
> > 2147483647 -1 -1
> > recovery interval (min) 0
> > 32767 0 0
> > remote access 0
> > 1 1 1
> > remote login timeout (s) 0
> > 2147483647 20 20
> > remote proc trans 0
> > 1 0 0
> > remote query timeout (s) 0
> > 2147483647 600 600
> > scan for startup procs 0
> > 1 1 0
> > set working set size 0
> > 1 0 0
> > show advanced options 0
> > 1 1 1
> > two digit year cutoff 1753
> > 9999 2049 2049
> > user connections 0
> > 32767 0 0
> > user options 0
> > 32767 56 56
> --
> Hi Mike,
> Check that the SQL Server startup account has the 'Lock Pages in Memory'
> privilege:
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adminsql/ad
> _1_server_1fnd.asp
> --
> Eric Cárdenas
> Senior support professional
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
AWE RAM (SQL 2K not recognizing available AWE RAM)
with SP3. The boot.ini is set with /3gb /PAE. The
server system properties list 8GB of RAM. Within SQL
Server sp_configure AWE running is set to 1. When I look
in the SQL Server error log it tells me that 8 processors
and 2048 MB RAM where detected. SQL Server Memory
properties are set with the Maximum to 5.12 GB. But SQL
Server does not recognize AWE setting. The Server
Performance Monitor Counter under SQL Server Memory
Manager with Target Server Memory list 2.7GB. This
should be 5.12 GB of memory for SQL Server.
Please help me resolve this problem.
Mike
__________________________________________________________
[boot loader]
timeout=10
default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft
Windows 2000 Advanced Server" /fastdetect /3gb /PAE
__________________________________________________________
_
sp_configure "show advanced options", 1
RECONFIGURE
GO
sp_configure "awe enabled", 1
RECONFIGURE
GO
sp_configure "max server memory", 5120
RECONFIGURE
GO
sp_configure "min server memory", 0
RECONFIGURE
GO
__________________________________________________________
_
Output from SP_CONFIGURE
name minimum
maximum config_value run_value
-- -- --
-
-- --
affinity mask -2147483648
2147483647 0 0
allow updates 0
1 0 0
awe enabled 0
1 1 1
c2 audit mode 0
1 0 0
cost threshold for parallelism 0
32767 5 5
Cross DB Ownership Chaining 0
1 0 0
cursor threshold -1
2147483647 -1 -1
default full-text language 0
2147483647 1033 1033
default language 0
9999 0 0
fill factor (%) 0
100 0 0
index create memory (KB) 704
2147483647 0 0
lightweight pooling 0
1 0 0
locks 5000
2147483647 0 0
max degree of parallelism 0
32 0 0
max server memory (MB) 4
2147483647 5120 5120
max text repl size (B) 0
2147483647 65536 65536
max worker threads 32
32767 255 255
media retention 0
365 0 0
min memory per query (KB) 512
2147483647 1024 1024
min server memory (MB) 0
2147483647 0 0
nested triggers 0
1 1 1
network packet size (B) 512
65536 4096 4096
open objects 0
2147483647 0 0
priority boost 0
1 0 0
query governor cost limit 0
2147483647 0 0
query wait (s) -1
2147483647 -1 -1
recovery interval (min) 0
32767 0 0
remote access 0
1 1 1
remote login timeout (s) 0
2147483647 20 20
remote proc trans 0
1 0 0
remote query timeout (s) 0
2147483647 600 600
scan for startup procs 0
1 1 0
set working set size 0
1 0 0
show advanced options 0
1 1 1
two digit year cutoff 1753
9999 2049 2049
user connections 0
32767 0 0
user options 0
32767 56 56Do you have Lock Pages In Memory set properly? See this:
http://support.microsoft.com/default.aspx?scid=kb;en-us;811891&Product=sql2k
--
Andrew J. Kelly SQL MVP
"Mike" <anonymous@.discussions.microsoft.com> wrote in message
news:9ede01c4349c$357f8a70$a401280a@.phx.gbl...
> I have a server with SQL Server 2000 Enterprise Edition
> with SP3. The boot.ini is set with /3gb /PAE. The
> server system properties list 8GB of RAM. Within SQL
> Server sp_configure AWE running is set to 1. When I look
> in the SQL Server error log it tells me that 8 processors
> and 2048 MB RAM where detected. SQL Server Memory
> properties are set with the Maximum to 5.12 GB. But SQL
> Server does not recognize AWE setting. The Server
> Performance Monitor Counter under SQL Server Memory
> Manager with Target Server Memory list 2.7GB. This
> should be 5.12 GB of memory for SQL Server.
> Please help me resolve this problem.
> Mike
> __________________________________________________________
> [boot loader]
> timeout=10
> default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
> [operating systems]
> multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft
> Windows 2000 Advanced Server" /fastdetect /3gb /PAE
> __________________________________________________________
> _
> sp_configure "show advanced options", 1
> RECONFIGURE
> GO
> sp_configure "awe enabled", 1
> RECONFIGURE
> GO
> sp_configure "max server memory", 5120
> RECONFIGURE
> GO
> sp_configure "min server memory", 0
> RECONFIGURE
> GO
> __________________________________________________________
> _
> Output from SP_CONFIGURE
> name minimum
> maximum config_value run_value
> -- -- --
> -
> -- --
> affinity mask -2147483648
> 2147483647 0 0
> allow updates 0
> 1 0 0
> awe enabled 0
> 1 1 1
> c2 audit mode 0
> 1 0 0
> cost threshold for parallelism 0
> 32767 5 5
> Cross DB Ownership Chaining 0
> 1 0 0
> cursor threshold -1
> 2147483647 -1 -1
> default full-text language 0
> 2147483647 1033 1033
> default language 0
> 9999 0 0
> fill factor (%) 0
> 100 0 0
> index create memory (KB) 704
> 2147483647 0 0
> lightweight pooling 0
> 1 0 0
> locks 5000
> 2147483647 0 0
> max degree of parallelism 0
> 32 0 0
> max server memory (MB) 4
> 2147483647 5120 5120
> max text repl size (B) 0
> 2147483647 65536 65536
> max worker threads 32
> 32767 255 255
> media retention 0
> 365 0 0
> min memory per query (KB) 512
> 2147483647 1024 1024
> min server memory (MB) 0
> 2147483647 0 0
> nested triggers 0
> 1 1 1
> network packet size (B) 512
> 65536 4096 4096
> open objects 0
> 2147483647 0 0
> priority boost 0
> 1 0 0
> query governor cost limit 0
> 2147483647 0 0
> query wait (s) -1
> 2147483647 -1 -1
> recovery interval (min) 0
> 32767 0 0
> remote access 0
> 1 1 1
> remote login timeout (s) 0
> 2147483647 20 20
> remote proc trans 0
> 1 0 0
> remote query timeout (s) 0
> 2147483647 600 600
> scan for startup procs 0
> 1 1 0
> set working set size 0
> 1 0 0
> show advanced options 0
> 1 1 1
> two digit year cutoff 1753
> 9999 2049 2049
> user connections 0
> 32767 0 0
> user options 0
> 32767 56 56
>
>|||The SQL Server service account is listed in the Lock
pages in memory is set the same way three other servers
that work correctly.
Is this server not recognizing this setting?
Please help me with this problem.
Thanks,
Mike
>--Original Message--
>Do you have Lock Pages In Memory set properly? See this:
>http://support.microsoft.com/default.aspx?scid=kb;en-
us;811891&Product=sql2k
>--
>Andrew J. Kelly SQL MVP
>
>"Mike" <anonymous@.discussions.microsoft.com> wrote in
message
>news:9ede01c4349c$357f8a70$a401280a@.phx.gbl...
>> I have a server with SQL Server 2000 Enterprise Edition
>> with SP3. The boot.ini is set with /3gb /PAE. The
>> server system properties list 8GB of RAM. Within SQL
>> Server sp_configure AWE running is set to 1. When I
look
>> in the SQL Server error log it tells me that 8
processors
>> and 2048 MB RAM where detected. SQL Server Memory
>> properties are set with the Maximum to 5.12 GB. But
SQL
>> Server does not recognize AWE setting. The Server
>> Performance Monitor Counter under SQL Server Memory
>> Manager with Target Server Memory list 2.7GB. This
>> should be 5.12 GB of memory for SQL Server.
>> Please help me resolve this problem.
>> Mike
>>
__________________________________________________________
>> [boot loader]
>> timeout=10
>> default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
>> [operating systems]
>> multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft
>> Windows 2000 Advanced Server" /fastdetect /3gb /PAE
__________________________________________________________
>> _
>> sp_configure "show advanced options", 1
>> RECONFIGURE
>> GO
>> sp_configure "awe enabled", 1
>> RECONFIGURE
>> GO
>> sp_configure "max server memory", 5120
>> RECONFIGURE
>> GO
>> sp_configure "min server memory", 0
>> RECONFIGURE
>> GO
__________________________________________________________
>> _
>> Output from SP_CONFIGURE
>> name minimum
>> maximum config_value run_value
>> -- -- --
--
>> -
>> -- --
>> affinity mask -2147483648
>> 2147483647 0 0
>> allow updates 0
>> 1 0 0
>> awe enabled 0
>> 1 1 1
>> c2 audit mode 0
>> 1 0 0
>> cost threshold for parallelism 0
>> 32767 5 5
>> Cross DB Ownership Chaining 0
>> 1 0 0
>> cursor threshold -1
>> 2147483647 -1 -1
>> default full-text language 0
>> 2147483647 1033 1033
>> default language 0
>> 9999 0 0
>> fill factor (%) 0
>> 100 0 0
>> index create memory (KB) 704
>> 2147483647 0 0
>> lightweight pooling 0
>> 1 0 0
>> locks 5000
>> 2147483647 0 0
>> max degree of parallelism 0
>> 32 0 0
>> max server memory (MB) 4
>> 2147483647 5120 5120
>> max text repl size (B) 0
>> 2147483647 65536 65536
>> max worker threads 32
>> 32767 255 255
>> media retention 0
>> 365 0 0
>> min memory per query (KB) 512
>> 2147483647 1024 1024
>> min server memory (MB) 0
>> 2147483647 0 0
>> nested triggers 0
>> 1 1 1
>> network packet size (B) 512
>> 65536 4096 4096
>> open objects 0
>> 2147483647 0 0
>> priority boost 0
>> 1 0 0
>> query governor cost limit 0
>> 2147483647 0 0
>> query wait (s) -1
>> 2147483647 -1 -1
>> recovery interval (min) 0
>> 32767 0 0
>> remote access 0
>> 1 1 1
>> remote login timeout (s) 0
>> 2147483647 20 20
>> remote proc trans 0
>> 1 0 0
>> remote query timeout (s) 0
>> 2147483647 600 600
>> scan for startup procs 0
>> 1 1 0
>> set working set size 0
>> 1 0 0
>> show advanced options 0
>> 1 1 1
>> two digit year cutoff 1753
>> 9999 2049 2049
>> user connections 0
>> 32767 0 0
>> user options 0
>> 32767 56 56
>>
>>
>
>.
>|||According to the results of sp_configure your run value is still set to 0
for AWE. Did you restart the server? And are you absolutely sure you have
SQL EE? What does xp_msver show?
--
Andrew J. Kelly SQL MVP
"Mike" <anonymous@.discussions.microsoft.com> wrote in message
news:a04c01c434f9$3dde5ae0$a401280a@.phx.gbl...
> The SQL Server service account is listed in the Lock
> pages in memory is set the same way three other servers
> that work correctly.
> Is this server not recognizing this setting?
> Please help me with this problem.
> Thanks,
> Mike
>
> >--Original Message--
> >Do you have Lock Pages In Memory set properly? See this:
> >http://support.microsoft.com/default.aspx?scid=kb;en-
> us;811891&Product=sql2k
> >
> >--
> >Andrew J. Kelly SQL MVP
> >
> >
> >"Mike" <anonymous@.discussions.microsoft.com> wrote in
> message
> >news:9ede01c4349c$357f8a70$a401280a@.phx.gbl...
> >>
> >> I have a server with SQL Server 2000 Enterprise Edition
> >> with SP3. The boot.ini is set with /3gb /PAE. The
> >> server system properties list 8GB of RAM. Within SQL
> >> Server sp_configure AWE running is set to 1. When I
> look
> >> in the SQL Server error log it tells me that 8
> processors
> >> and 2048 MB RAM where detected. SQL Server Memory
> >> properties are set with the Maximum to 5.12 GB. But
> SQL
> >> Server does not recognize AWE setting. The Server
> >> Performance Monitor Counter under SQL Server Memory
> >> Manager with Target Server Memory list 2.7GB. This
> >> should be 5.12 GB of memory for SQL Server.
> >>
> >> Please help me resolve this problem.
> >>
> >> Mike
> >>
> >>
> __________________________________________________________
> >> [boot loader]
> >> timeout=10
> >> default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
> >> [operating systems]
> >> multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft
> >> Windows 2000 Advanced Server" /fastdetect /3gb /PAE
> >>
> __________________________________________________________
> >> _
> >> sp_configure "show advanced options", 1
> >> RECONFIGURE
> >> GO
> >> sp_configure "awe enabled", 1
> >> RECONFIGURE
> >> GO
> >> sp_configure "max server memory", 5120
> >> RECONFIGURE
> >> GO
> >> sp_configure "min server memory", 0
> >> RECONFIGURE
> >> GO
> >>
> __________________________________________________________
> >> _
> >> Output from SP_CONFIGURE
> >> name minimum
> >> maximum config_value run_value
> >> -- -- --
> --
> >> -
> >> -- --
> >> affinity mask -2147483648
> >> 2147483647 0 0
> >> allow updates 0
> >> 1 0 0
> >> awe enabled 0
> >> 1 1 1
> >> c2 audit mode 0
> >> 1 0 0
> >> cost threshold for parallelism 0
> >> 32767 5 5
> >> Cross DB Ownership Chaining 0
> >> 1 0 0
> >> cursor threshold -1
> >> 2147483647 -1 -1
> >> default full-text language 0
> >> 2147483647 1033 1033
> >> default language 0
> >> 9999 0 0
> >> fill factor (%) 0
> >> 100 0 0
> >> index create memory (KB) 704
> >> 2147483647 0 0
> >> lightweight pooling 0
> >> 1 0 0
> >> locks 5000
> >> 2147483647 0 0
> >> max degree of parallelism 0
> >> 32 0 0
> >> max server memory (MB) 4
> >> 2147483647 5120 5120
> >> max text repl size (B) 0
> >> 2147483647 65536 65536
> >> max worker threads 32
> >> 32767 255 255
> >> media retention 0
> >> 365 0 0
> >> min memory per query (KB) 512
> >> 2147483647 1024 1024
> >> min server memory (MB) 0
> >> 2147483647 0 0
> >> nested triggers 0
> >> 1 1 1
> >> network packet size (B) 512
> >> 65536 4096 4096
> >> open objects 0
> >> 2147483647 0 0
> >> priority boost 0
> >> 1 0 0
> >> query governor cost limit 0
> >> 2147483647 0 0
> >> query wait (s) -1
> >> 2147483647 -1 -1
> >> recovery interval (min) 0
> >> 32767 0 0
> >> remote access 0
> >> 1 1 1
> >> remote login timeout (s) 0
> >> 2147483647 20 20
> >> remote proc trans 0
> >> 1 0 0
> >> remote query timeout (s) 0
> >> 2147483647 600 600
> >> scan for startup procs 0
> >> 1 1 0
> >> set working set size 0
> >> 1 0 0
> >> show advanced options 0
> >> 1 1 1
> >> two digit year cutoff 1753
> >> 9999 2049 2049
> >> user connections 0
> >> 32767 0 0
> >> user options 0
> >> 32767 56 56
> >>
> >>
> >>
> >>
> >
> >
> >.
> >
Friday, February 24, 2012
Avoiding deadlock
I have a stored procedure spUpdateClient, which takes as params a number of properties of a client application that wants to register its existence with the database. The sp just needs to add a new row or update an existing row with this data.
I tried to accomplish this with code somethign like this. (The table I'm updating is called Client, and its primary key is ClientId, which is a value passed into the sp from the client.)
IF (SELECT COUNT(ClientId) FROM Clients WHERE ClientId=@.ClientId) = 0
BEGIN
-- client not found, create it
INSERT INTO Clients (ClientId, Hostname, Etc)
VALUES (@.ClientId, @.Hostname, @.Etc)
ENDELSE
BEGIN
-- client was found, update it
UPDATE Clients
SET Hostname=@.Hostname, Etc=@.Etc
WHERE ClientId=@.ClientId
END
But the client apps call this every second or so, so soon enough I started getting primary key violations. It looks like one client would make two calls nearly at the same time, both would get a 0 value on the SELECT line, so both would try to insert a new row with the same ClientId. No good.
So then I added
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
BEGIN TRANSACTION
at the top, and a COMMIT at the bottom. I thought the first one in would get to run the whole sp, and the next one in would have to wait for the first to be done.
Instead I'm now getting deadlock errors.
If I understand the docs right, that's because the exclusive lock is not placed on the Clients table until the INSERT happens, not at the SELECT. So when two calls to the sp happen at nearly the same time (call them A and B), A does the SELECT and that locks Clients so nobody else can update it. Then B does the SELECT, locking Clients so nobody else (including A) can update it. Now A needs to exclusively lock Clients to do its INSERT, but B still has that read lock on it, and they're deadlocked.
I could catch the deadlock in my client app after SQL Server kills one of the transactions, but it seems to me there should be some way to set a lock at the top of the sp that says "nobody else can enter this sp until I exit it". Any such thing?
Thanks.
Nate Hekman
You can change your code to the following:
BEGIN TRANSACTION
IF NOT EXISTS(SELECT * FROM Clients WITH(SERIALIZABLE, XLOCK)WHERE ClientId=@.ClientId)
BEGIN
-- client not found, create it
INSERT INTO Clients (ClientId, Hostname, Etc)
VALUES (@.ClientId, @.Hostname, @.Etc)
ENDELSE
BEGIN
-- client was found, update it
UPDATE Clients
SET Hostname=@.Hostname, Etc=@.Etc
WHERE ClientId=@.ClientId
ENDCOMMIT
The XLOCK hint in the SELECT statement will ensure that if the rows exists you lock it exclusively so the update will work fine. And the SERIALIZABLE hint will ensure that if the row doesn't exist you lock the key range for the new row. This will prevent the deadlock from happening.
Another approach is to do the following:
|||BEGIN TRANSACTION
UPDATE Clients WITH(SERIALIZABLE)
SET Hostname=@.Hostname, Etc=@.Etc
WHERE ClientId=@.ClientId
IF @.@.ROWCOUNT = 0BEGIN
-- client not found, create it
INSERT INTO Clients (ClientId, Hostname, Etc)
VALUES (@.ClientId, @.Hostname, @.Etc)
ENDCOMMIT
This is a very good understanding of why you are getting a deadlock :) You can cause it to single thread by adding an LOCK hint to the existence check. Also, change from using a count to exists, it will be better as it just needs to see a single row, rather than counting them all. No need for serializable here now, but make sure ClientId is indexed right (and if it is the declare primary key that should be fine)
BEGIN TRANSACTION
IF EXISTS (SELECT 1
FROM Clients WITH (XLOCK)
WHERE ClientId=@.ClientId)
BEGIN
-- client not found, create it
INSERT INTO Clients (ClientId, Hostname, Etc)
VALUES (@.ClientId, @.Hostname, @.Etc)
END
ELSE
BEGIN
-- client was found, update it
UPDATE Clients
SET Hostname=@.Hostname, Etc=@.Etc
WHERE ClientId=@.ClientId
END
COMMIT TRANSACTION
An alternative is to just ignore the deadlock as you know why it occurs, and since you are only keeping a single copy, it is just as good and will be fast enough...
Another alternative would be to switch to an insert only methodology and just pump rows into a table. It would give you counts of visits, actual times of visits, etc. You could also glean the same information as you have now with no locking problems at all.
--clientId, visitDate would be the likely UNIQUE constraint
--if they are > .003 seconds apart, which I don't know based on your needs
create table clientVisit
(
clientVisitId int identity primary key,
clientId guid,
visitDate datetime default (getdate()),
hostName varchar(?),
etc varchar(?)
)
then just insert... It will take more disk space, but it should be just as fast. You could then pull the data off periodically and get the same information, plus some.
|||I didn't think that:
BEGIN TRANSACTION
IF NOT EXISTS(SELECT * FROM Clients WITH(SERIALIZABLE, UPDLOCK)
WHERE ClientId=@.ClientId)
Would suffice since a SHARED lock compatible with an UPDATE lock? In this case, the second could still read there to be no rows.
(I did overlook that you need to increase the isolation level just in case READ_COMMITTED_SNAPSHOT is enabled. And I didn't realize you could put lock hints on UPDATE statements :)
Thanks!
|||You are right. This should be XLOCK instead.|||Wow, thanks for the excellent replies everyone! I'm very new at T-SQL so all this locking stuff is a lot to mull over. But you've given me several good approaches that I think will work just great.
Thanks again.
Nate
|||IF (SELECT COUNT(ClientId) FROM Clients WHERE ClientId=@.ClientId) = 0
BEGIN
-- client not found, create it
INSERT INTO Clients (ClientId, Hostname, Etc)
VALUES (@.ClientId, @.Hostname, @.Etc)
END
ELSE
BEGIN
-- client was found, update it
UPDATE Clients
SET Hostname=@.Hostname, Etc=@.Etc
WHERE ClientId=@.ClientId
END
This problem's interesting and I'm sure lots of people have encountered before.
There are some things I still don't understand.
If we set the isolation level as Serializable and use XLOCK for the SELECT as follows:
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
BEGIN TRANSACTION
IF (SELECT COUNT(ClientId) FROM Clients (WITH XLOCK) WHERE ClientId=@.ClientId) = 0
BEGIN
-- client not found, create it
INSERT INTO Clients (ClientId, Hostname, Etc)
VALUES (@.ClientId, @.Hostname, @.Etc)
END
ELSE
BEGIN
-- client was found, update it
UPDATE Clients
SET Hostname=@.Hostname, Etc=@.Etc
WHERE ClientId=@.ClientId
END
COMMIT TRANSACTION
As Nate Hekman first wrote:
If I understand the docs right, that's because the exclusive lock is not placed on the Clients table until the INSERT happens, not at the SELECT. So when two calls to the sp happen at nearly the same time (call them A and B), A does the SELECT and that locks Clients so nobody else can update it. Then B does the SELECT, locking Clients so nobody else (including A) can update it. Now A needs to exclusively lock Clients to do its INSERT, but B still has that read lock on it, and they're deadlocked.
Question 1>
If the row doesn't exist, does the process go like this:
process1 executes SELECT ... WITH XLOCK and holds an exclusive lock on Clients.
Because isolation level Serializable is used, other processes can't insert new rows or update rows within the defined range. Also, because an exclusive lock is held, other processes can't even read until process1 finishes?
Question 2>
How does it solve the deadlock problem?
Question 1:
When a transaction holds Exclusive locks on a range of rows, other transaction cannot read those rows, unless the second transaction's isolation level is not READ UNCOMMITTED. As Nate uses the same sp for inserts, yes, the select command blocks all readers.
Question2:
Deadlocks do not occur because a transaction that executes its select command is guaranteed to be granted all the locks it will needs further, that is, it cannot be blocked, so a deadlock can never occur. This is a sort of pre-declaration of locks, or pessimistic locking. When transaction A executes its select command, the other ones (say trans. B)cannot read. If transaction A takes a long time to commit, B might be eventually aborted. But this will not happen-the insert transaction is a short one, and it will need milliseconds to commit, after that transaction B(or other waiting transaction) will be granted the lock. In this scenario, aborts are very unlikely to occur unless the workload is high.
Avoiding deadlock
I have a stored procedure spUpdateClient, which takes as params a number of properties of a client application that wants to register its existence with the database. The sp just needs to add a new row or update an existing row with this data.
I tried to accomplish this with code somethign like this. (The table I'm updating is called Client, and its primary key is ClientId, which is a value passed into the sp from the client.)
IF (SELECT COUNT(ClientId) FROM Clients WHERE ClientId=@.ClientId) = 0
BEGIN
-- client not found, create it
INSERT INTO Clients (ClientId, Hostname, Etc)
VALUES (@.ClientId, @.Hostname, @.Etc)
ENDELSE
BEGIN
-- client was found, update it
UPDATE Clients
SET Hostname=@.Hostname, Etc=@.Etc
WHERE ClientId=@.ClientId
END
But the client apps call this every second or so, so soon enough I started getting primary key violations. It looks like one client would make two calls nearly at the same time, both would get a 0 value on the SELECT line, so both would try to insert a new row with the same ClientId. No good.
So then I added
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
BEGIN TRANSACTION
at the top, and a COMMIT at the bottom. I thought the first one in would get to run the whole sp, and the next one in would have to wait for the first to be done.
Instead I'm now getting deadlock errors.
If I understand the docs right, that's because the exclusive lock is not placed on the Clients table until the INSERT happens, not at the SELECT. So when two calls to the sp happen at nearly the same time (call them A and B), A does the SELECT and that locks Clients so nobody else can update it. Then B does the SELECT, locking Clients so nobody else (including A) can update it. Now A needs to exclusively lock Clients to do its INSERT, but B still has that read lock on it, and they're deadlocked.
I could catch the deadlock in my client app after SQL Server kills one of the transactions, but it seems to me there should be some way to set a lock at the top of the sp that says "nobody else can enter this sp until I exit it". Any such thing?
Thanks.
Nate Hekman
You can change your code to the following:
BEGIN TRANSACTION
IF NOT EXISTS(SELECT * FROM Clients WITH(SERIALIZABLE, XLOCK)WHERE ClientId=@.ClientId)
BEGIN
-- client not found, create it
INSERT INTO Clients (ClientId, Hostname, Etc)
VALUES (@.ClientId, @.Hostname, @.Etc)
ENDELSE
BEGIN
-- client was found, update it
UPDATE Clients
SET Hostname=@.Hostname, Etc=@.Etc
WHERE ClientId=@.ClientId
ENDCOMMIT
The XLOCK hint in the SELECT statement will ensure that if the rows exists you lock it exclusively so the update will work fine. And the SERIALIZABLE hint will ensure that if the row doesn't exist you lock the key range for the new row. This will prevent the deadlock from happening.
Another approach is to do the following:
|||BEGIN TRANSACTION
UPDATE Clients WITH(SERIALIZABLE)
SET Hostname=@.Hostname, Etc=@.Etc
WHERE ClientId=@.ClientId
IF @.@.ROWCOUNT = 0BEGIN
-- client not found, create it
INSERT INTO Clients (ClientId, Hostname, Etc)
VALUES (@.ClientId, @.Hostname, @.Etc)
ENDCOMMIT
This is a very good understanding of why you are getting a deadlock :) You can cause it to single thread by adding an LOCK hint to the existence check. Also, change from using a count to exists, it will be better as it just needs to see a single row, rather than counting them all. No need for serializable here now, but make sure ClientId is indexed right (and if it is the declare primary key that should be fine)
BEGIN TRANSACTION
IF EXISTS (SELECT 1
FROM Clients WITH (XLOCK)
WHERE ClientId=@.ClientId)
BEGIN
-- client not found, create it
INSERT INTO Clients (ClientId, Hostname, Etc)
VALUES (@.ClientId, @.Hostname, @.Etc)
END
ELSE
BEGIN
-- client was found, update it
UPDATE Clients
SET Hostname=@.Hostname, Etc=@.Etc
WHERE ClientId=@.ClientId
END
COMMIT TRANSACTION
An alternative is to just ignore the deadlock as you know why it occurs, and since you are only keeping a single copy, it is just as good and will be fast enough...
Another alternative would be to switch to an insert only methodology and just pump rows into a table. It would give you counts of visits, actual times of visits, etc. You could also glean the same information as you have now with no locking problems at all.
--clientId, visitDate would be the likely UNIQUE constraint
--if they are > .003 seconds apart, which I don't know based on your needs
create table clientVisit
(
clientVisitId int identity primary key,
clientId guid,
visitDate datetime default (getdate()),
hostName varchar(?),
etc varchar(?)
)
then just insert... It will take more disk space, but it should be just as fast. You could then pull the data off periodically and get the same information, plus some.
|||I didn't think that:
BEGIN TRANSACTION
IF NOT EXISTS(SELECT * FROM Clients WITH(SERIALIZABLE, UPDLOCK)
WHERE ClientId=@.ClientId)
Would suffice since a SHARED lock compatible with an UPDATE lock? In this case, the second could still read there to be no rows.
(I did overlook that you need to increase the isolation level just in case READ_COMMITTED_SNAPSHOT is enabled. And I didn't realize you could put lock hints on UPDATE statements :)
Thanks!
|||You are right. This should be XLOCK instead.|||Wow, thanks for the excellent replies everyone! I'm very new at T-SQL so all this locking stuff is a lot to mull over. But you've given me several good approaches that I think will work just great.
Thanks again.
Nate
|||IF (SELECT COUNT(ClientId) FROM Clients WHERE ClientId=@.ClientId) = 0
BEGIN
-- client not found, create it
INSERT INTO Clients (ClientId, Hostname, Etc)
VALUES (@.ClientId, @.Hostname, @.Etc)
END
ELSE
BEGIN
-- client was found, update it
UPDATE Clients
SET Hostname=@.Hostname, Etc=@.Etc
WHERE ClientId=@.ClientId
END
This problem's interesting and I'm sure lots of people have encountered before.
There are some things I still don't understand.
If we set the isolation level as Serializable and use XLOCK for the SELECT as follows:
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
BEGIN TRANSACTION
IF (SELECT COUNT(ClientId) FROM Clients (WITH XLOCK) WHERE ClientId=@.ClientId) = 0
BEGIN
-- client not found, create it
INSERT INTO Clients (ClientId, Hostname, Etc)
VALUES (@.ClientId, @.Hostname, @.Etc)
END
ELSE
BEGIN
-- client was found, update it
UPDATE Clients
SET Hostname=@.Hostname, Etc=@.Etc
WHERE ClientId=@.ClientId
END
COMMIT TRANSACTION
As Nate Hekman first wrote:
If I understand the docs right, that's because the exclusive lock is not placed on the Clients table until the INSERT happens, not at the SELECT. So when two calls to the sp happen at nearly the same time (call them A and B), A does the SELECT and that locks Clients so nobody else can update it. Then B does the SELECT, locking Clients so nobody else (including A) can update it. Now A needs to exclusively lock Clients to do its INSERT, but B still has that read lock on it, and they're deadlocked.
Question 1>
If the row doesn't exist, does the process go like this:
process1 executes SELECT ... WITH XLOCK and holds an exclusive lock on Clients.
Because isolation level Serializable is used, other processes can't insert new rows or update rows within the defined range. Also, because an exclusive lock is held, other processes can't even read until process1 finishes?
Question 2>
How does it solve the deadlock problem?
Question 1:
When a transaction holds Exclusive locks on a range of rows, other transaction cannot read those rows, unless the second transaction's isolation level is not READ UNCOMMITTED. As Nate uses the same sp for inserts, yes, the select command blocks all readers.
Question2:
Deadlocks do not occur because a transaction that executes its select command is guaranteed to be granted all the locks it will needs further, that is, it cannot be blocked, so a deadlock can never occur. This is a sort of pre-declaration of locks, or pessimistic locking. When transaction A executes its select command, the other ones (say trans. B)cannot read. If transaction A takes a long time to commit, B might be eventually aborted. But this will not happen-the insert transaction is a short one, and it will need milliseconds to commit, after that transaction B(or other waiting transaction) will be granted the lock. In this scenario, aborts are very unlikely to occur unless the workload is high.
Sunday, February 12, 2012
AutoStart Failed When Rebooted
Question, what would be the reason why it would not autostart when I reboote
d
the server? I noticed when they installed SQL server that the program file
s
was pointed to the D drive (SAN).
Thanks,
LDSQL Sever is trying to start before the os connects to the SAN
What type of SAN are you using?
--
paulz
"LITO" wrote:
> I have the SQL account services set to autostart via sql server properties
.
> Question, what would be the reason why it would not autostart when I reboo
ted
> the server? I noticed when they installed SQL server that the program fi
les
> was pointed to the D drive (SAN).
>
> Thanks,
> LD|||LITO
Here is more info about my last reply
For a windows 2003
Start Registry Editor.
Locate and then click the following subkey:
HKEY_LOCAL_MACHINE\System\CurrentControl
Set\Services\MSSQLSERVER
On the Edit menu, point to New, and then click Multi-String Value.
Type DependOnService to name the new registry value, and then press ENTER.
Double-click DependOnService, type MSiSCSI in the Value data box, and then
click OK.
http://support.microsoft.com/Default.aspx?kbid=870964
--
Paul Zanbaka
"paulz" wrote:
[vbcol=seagreen]
> SQL Sever is trying to start before the os connects to the SAN
> What type of SAN are you using?
> --
> paulz
>
> "LITO" wrote:
>
AutoStart Failed When Rebooted
Question, what would be the reason why it would not autostart when I rebooted
the server? I noticed when they installed SQL server that the program files
was pointed to the D drive (SAN).
Thanks,
LD
SQL Sever is trying to start before the os connects to the SAN
What type of SAN are you using?
paulz
"LITO" wrote:
> I have the SQL account services set to autostart via sql server properties.
> Question, what would be the reason why it would not autostart when I rebooted
> the server? I noticed when they installed SQL server that the program files
> was pointed to the D drive (SAN).
>
> Thanks,
> LD
|||LITO
Here is more info about my last reply
For a windows 2003
Start Registry Editor.
Locate and then click the following subkey:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Servic es\MSSQLSERVER
On the Edit menu, point to New, and then click Multi-String Value.
Type DependOnService to name the new registry value, and then press ENTER.
Double-click DependOnService, type MSiSCSI in the Value data box, and then
click OK.
http://support.microsoft.com/Default.aspx?kbid=870964
Paul Zanbaka
"paulz" wrote:
[vbcol=seagreen]
> SQL Sever is trying to start before the os connects to the SAN
> What type of SAN are you using?
> --
> paulz
>
> "LITO" wrote:
AutoStart Failed When Rebooted
Question, what would be the reason why it would not autostart when I rebooted
the server? I noticed when they installed SQL server that the program files
was pointed to the D drive (SAN).
Thanks,
LDSQL Sever is trying to start before the os connects to the SAN
What type of SAN are you using?
--
paulz
"LITO" wrote:
> I have the SQL account services set to autostart via sql server properties.
> Question, what would be the reason why it would not autostart when I rebooted
> the server? I noticed when they installed SQL server that the program files
> was pointed to the D drive (SAN).
>
> Thanks,
> LD|||LITO
Here is more info about my last reply
For a windows 2003
Start Registry Editor.
Locate and then click the following subkey:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MSSQLSERVER
On the Edit menu, point to New, and then click Multi-String Value.
Type DependOnService to name the new registry value, and then press ENTER.
Double-click DependOnService, type MSiSCSI in the Value data box, and then
click OK.
http://support.microsoft.com/Default.aspx?kbid=870964
--
Paul Zanbaka
"paulz" wrote:
> SQL Sever is trying to start before the os connects to the SAN
> What type of SAN are you using?
> --
> paulz
>
> "LITO" wrote:
> > I have the SQL account services set to autostart via sql server properties.
> > Question, what would be the reason why it would not autostart when I rebooted
> > the server? I noticed when they installed SQL server that the program files
> > was pointed to the D drive (SAN).
> >
> >
> > Thanks,
> > LD