Quantcast
Channel: SQL Server Database Engine forum
Viewing all 12554 articles
Browse latest View live

Facing Deadlock during Parallel Updates even when "with(rowlock)" is specified

$
0
0

Hi,

Brief Description about the process

  1.  We have some update statements running in parallel on a log table.
  2.  Structure of the Log Table is as below

      CREATE TABLE [dbo].[PackageTaskLog](

            [PackageTaskLogID] [int] IDENTITY(1,1) NOT NULL,

            [PackageLogID] [int] NOT NULL,

            [SourceName] [varchar](255) NOT NULL,

            [SourceID] [uniqueidentifier] NOT NULL,

            [StartDateTime] [datetime] NOT NULL,

            [EndDateTime] [datetime] NULL,

      CONSTRAINT [PK_PackageTaskLog] PRIMARY KEY CLUSTERED

       (

               [PackageTaskLogID] ASC

         )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY =        OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 80) ON          [PRIMARY]

        ) ON [PRIMARY]

 3.      The Update statement is as below

             UPDATE dbo.PackageTaskLog with (RowLock)

             SET EndDateTime = getdate()

             WHERE PackageLogID = @PackageLogID AND SourceID = @SourceID

              AND EndDateTime is null

  1.  At any point of time, combination of PackageLogID and SourceID will be distinct.

Currently we are facing some deadlock errors.

Information about the DeadLock

  1.  We had this deadlock issue around 4 months back. At that point of time, the update statement did not have with (RowLock). After adding this option, we thought deadlock issue was resolved.

 

  1.  But again, we faced this deadlock issue last week. Below image provides the deadlock graph

 

  1. According to the below link, they suggest to make the query as index seek.

http://social.msdn.microsoft.com/forums/sqlserver/en-US/dba45618-1d64-4661-891d-74cab09dddf1/deadlock-while-running-multiple-update-statements

      (Currently in my query Clustered Index Scan is happening)

But my doubt is, if we make index seek, suppose if it locks a particular page, again we may end up having deadlock.

 

  1. Also, one more point is that, since it was log table, we took data back up and truncated the table. And now since 4 days deadlock is not occurring.
  2. Also, one more point is that, since it was log table, we took data back up and truncated the table. And now since 4 days deadlock is not occurring.

Clarifications Needed

Because of above points, I have some clarifications which are listed below

  1. If we create non-clustered index and force the update statement to use that index, will it resolve the issue. Will it lock the page or will it pin-point exact row and lock it.

 

  1.  Also, in below link they mentioned that Update locks will prevent deadlock. They mentioned that if an Update lock is issued, then other process has to wait until this Update lock is released.

http://technet.microsoft.com/en-us/library/aa213039(v=sql.80).aspx

But, in the above deadlock graph, we see that Update lock and exclusive locks were involved.

I did not understand how Update lock was involved in my Update statement, even though I did not mention it in my update statement.

Whether the update lock in the deadlock graph and the Update lock mentioned in the above link are different?

  1. Can I embed this Update statement in a transaction and set transaction isolation level as “serializable”. Will it resolve my issue?

 

  1. Also, I want to know why deadlock did not recur after truncating the table. Original log table had around 944,771 records.

This is actually a data warehouse. In transactional database they have so many DML operations running in parallel. How do they handle it in transactional database?

Basically, how can we permanently eliminate this deadlock issue?




SQL Server Authentication issue

$
0
0

I have an issue with a SQL 2012 SP1 database that I need help with.  I am not a SQL expert, so I could be overlooking something very basic.

I have a Windows Server 2012 R2 cluster that hosts multiple database instances.  All the database instances are configures such that Windows Authentication works with them.  Only one have I enabled for SQL Server Authentication, and it is the one I am having the problem with.  I need SQL Server Authentication for this one database, so I can't eliminate that.

Using the Management Studio, I changed the database security to all SA and provided a password.  But here is where is gets strange.  If I launch the SQL Server Management Studio and try to connect to the Problem database via SQL Server Authentication, it fails with a timeout error.  I then connect to any other database via Windows Authentication (which always works).  Then I come back and try to connect again to the Problem database via SQL Server Authentication and it works.  Exit the Management Studio and come back in to get the exact same results.  For whatever reason, I have to first connect to any database via Windows Auth before I can open the Problem database via SQL Auth.

Of course, there is no way for the application to use such logic.  Any ideas for me to try?  Again, I am not a SQL expert, so I generally need step-by-step guidance to get things done in SQL.

Thanks for any direction you can provide.


. : | : . : | : . tim

dot net web app connection with sql cluster

$
0
0

we had a web app connecting on sql server 2008 database wew decided to build a clustered environment plesase find the steps taken

1- san storage connect to both nodes 

2- i have built the windows cluster service as well as sql cluster 

3- i have published the application on both server 


when i made a test from one client i noticed that the application is very slow compared by its status before cluster , although the data file is seperated from log file and tempdb has it own disk as recommended , so can u help

Questions on Max Worker Threads setting.

$
0
0

We've been getting alerts lately like this "The percentage of Worker Threads used (100.00%) is greater than the defined threshold 95.00%   ". 

Low CPU, no blocking, no long open transactions, not using High Availability or Log Shipping, etc. The users are not reporting any impact, but I am seeing some 4 second queries take 8 seconds during these time periods. 

Based on my amount of processors, we're allowed 704 Worker Threads. We're able to get a count of how many "real" connections are logging onto the system. Right around 10,000 when things are good, about 11,100 when things aren't so good.

My theory is that the queries are waiting on open connections, therefore being slowed down. A counter theory would be that queries are running slow, thereby not freeing connections. However, as stated we're not seeing anything that would lead to a sudden slowdown in query times.

My idea now is to change my setting to 800. If the 4 second queries stay 4 seconds when we hit 11,100 connections, my theory would be proven correct. If the queries still go to 8 seconds, my theory would be proven incorrect.

I know that changing this setting is warned against, but does anyone else have any other ideas for my "chicken or the egg" scenario?


TIA, ChrisRDBA

What is the identity range SQL Server providing, is it unlimited?

$
0
0

What is the identity range SQL Server 2008 R2 providing, is it unlimited?
I got one escalation from application saying the data loading from excel is fialing with some error. The Table which should get the data is in replication. User is trying to load 132k records but the publisher identity range is 50000 and Subscribers is 45000. I beleive SQL server will increase the number when we try to insert more than the identity range. But anyway I increased it to 250k.Is the error about the identity range? error message was not clear. It might be time out error from UI also.

Thanks


Swapna

SQL 2008 Page Life Expectancy very high

$
0
0

When I run the following query to determine the Page Life Expectancy:  SELECT cntr_valueAS'Page Life Expectancy'FROMsys.dm_os_performance_countersWHEREobject_name='SQLServer:Buffer Manager'AND counter_name='Page life expectancy'

It returns a value greater than 120,000, Shouldn't this value be in seconds?  So that would work out to 33 Hours, that does not seem right?  The server is a Virtual Windows 2008 R2 Enterprise running SQL 2008 Standard.  It has 24 GB in the box and 22.5 allocated to SQL.  The Buffer Cache is roughly 99% and the Target Server Memory (KB) is 21764.  So SQL is not using all of the RAM Allocated to it

Job failed

$
0
0

Hi Team,

Job is getting failed

Error:

Executed as user: TESCOKIPA\svc_sql_prod. Move file error check backup client: legato [SQLSTATE 42000] (Error 50000).  The step failed.

Please help me to fix

Thanks

Shashikala 




Shashikala

how to write vb.net code into sqlserver

$
0
0

Hi All,

I have a table named orders with 10 colums ,in that i have one coulmn contact_id which contains 15 digit number,now i want to make it as 18 digit number by using below vb.net code in sqlserver.Can some one help me on this.

Below is the vb.net code which needs to e converted to sql server query:

Function Id_18(InID As String) As String
Dim InChars As String, InI As Integer, InUpper As String
Dim InCnt As Integer
 
    If Len(InID) = 18 Then
        Id_18 = InID
        Exit Function
    End If
   
    InChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"
    InUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
   
    InCnt = 0
    For InI = 15 To 1 Step -1
        InCnt = 2 * InCnt + Sgn(InStr(1, InUpper, Mid(InID, InI, 1), vbBinaryCompare))
        If InI Mod 5 = 1 Then
            Id_18 = Mid(InChars, InCnt + 1, 1) + Id_18
            InCnt = 0
        End If
    Next InI
    Id_18 = InID + Id_18
   
End Function
 

Regards,

Sudha


sudha


MS DTC: Transaction is aborted from Transaction Statistics

$
0
0

The Application, SQL server 1 and SQL server 2 are locating in the same computer. Almost of the transactions are aborted.

Server: Windows Server 2008 R2 Enterprise
SQL Server: Microsoft SQL Server 2008 Enterprise

Our application is use SQLTransaction of ADO.NET not transactionscope,but our sqlscript contains linked server sql operation which will use MS DTC.

The DTC Security options:

The trace log is as below:

pid=1640       ;tid=3488       ;time=07/31/2014-19:12:38.272   ;seq=630041     ;eventid=TRANSACTION_BEGUN                        ;tx_guid=1bfe2bb8-af1b-4693-acb9-2c17ca93b870    ;"TM Identifier='(null)                                            '" ;"transaction has begun, description :'user_transaction'"
pid=1640       ;tid=3488       ;time=07/31/2014-19:12:38.272   ;seq=630042     ;eventid=RM_ENLISTED_IN_TRANSACTION               ;tx_guid=1bfe2bb8-af1b-4693-acb9-2c17ca93b870    ;"TM Identifier='(null)                                            '" ;"resource manager #1001 enlisted as transaction enlistment #1. RM guid = '8d2ed237-d5dd-49c1-94f6-d8aa196c4791'"
pid=1640       ;tid=3488       ;time=07/31/2014-19:12:38.288   ;seq=630043     ;eventid=RECEIVED_ABORT_REQUEST_FROM_BEGINNER     ;tx_guid=1bfe2bb8-af1b-4693-acb9-2c17ca93b870     ;"TM Identifier='(null)                                           '" ;"received request to abort the transaction from beginner"
pid=1640       ;tid=3488       ;time=07/31/2014-19:12:38.288   ;seq=630044     ;eventid=TRANSACTION_ABORTING                     ;tx_guid=1bfe2bb8-af1b-4693-acb9-2c17ca93b870    ;"TM Identifier='(null)                                            '" ;"transaction is aborting"
pid=1640       ;tid=3488       ;time=07/31/2014-19:12:38.288   ;seq=630045     ;eventid=RM_ISSUED_ABORT                          ;tx_guid=1bfe2bb8-af1b-4693-acb9-2c17ca93b870    ;"TM Identifier='(null)                                            '" ;"abort request issued to resource manager #1001 for transaction enlistment #1"
pid=1640       ;tid=3488       ;time=07/31/2014-19:12:38.288   ;seq=630046     ;eventid=RM_ACKNOWLEDGED_ABORT                    ;tx_guid=1bfe2bb8-af1b-4693-acb9-2c17ca93b870    ;"TM Identifier='(null)                                            '" ;"received acknowledgement of abort request from the resource manager #1001 for transaction enlistment #1"
pid=1640       ;tid=3488       ;time=07/31/2014-19:12:38.288   ;seq=630047     ;eventid=TRANSACTION_ABORTED                      ;tx_guid=1bfe2bb8-af1b-4693-acb9-2c17ca93b870    ;"TM Identifier='(null)                                            '" ;"transaction has been aborted"

Please help to resolve the aborted transaction problems.

How to determine which objects/queries are main cause for unusual increase in tempDB

$
0
0

Hi,

From past 2 days, tempdb is growing unexpectedly and completely filling up the Drive. Currently we are restarting the service.

Yesterday, when we ran the below query when tempDB was full, we got 2 queries. But those 2 queries were running since long time and we are surprised how suddenly those queries are responsible for tempDB growth

select top 10
t1.session_id,
t1.request_id,
t1.task_alloc,
     t1.task_dealloc, 
    (SELECT SUBSTRING(text, t2.statement_start_offset/2 + 1,
          (CASE WHEN statement_end_offset = -1
              THEN LEN(CONVERT(nvarchar(max),text)) * 2
                   ELSE statement_end_offset
              END - t2.statement_start_offset)/2)
     FROM sys.dm_exec_sql_text(sql_handle)) AS query_text,
(SELECT query_plan from sys.dm_exec_query_plan(t2.plan_handle)) as query_plan

from      (Select session_id, request_id,
sum(internal_objects_alloc_page_count +   user_objects_alloc_page_count) as task_alloc,
sum (internal_objects_dealloc_page_count + user_objects_dealloc_page_count) as task_dealloc
       from sys.dm_db_task_space_usage
       group by session_id, request_id) as t1,
       sys.dm_exec_requests as t2
where t1.session_id = t2.session_id and
(t1.request_id = t2.request_id) 
     -- and t1.session_id > 50
order by t1.task_alloc DESC

And today, periodically when I was trying to see the tables in "Temporary Tables" in tempdb, I am gettiing TimeOut Period.

Also, after referring below link, I have executed some queries

http://msdn.microsoft.com/en-us/library/ms176029.aspx

--1.Determining the Total Amount of Space 
SELECT SUM(size)*1.0/128 AS [size in MB]
FROM tempdb.sys.database_files
--63478.375000


--2. Determining the Amount Space Used by the Version Store
SELECT SUM(version_store_reserved_page_count) AS [version store pages used],
(SUM(version_store_reserved_page_count)*1.0/128) AS [version store space in MB]
FROM sys.dm_db_file_space_usage;
--176.875000 MB

--3.Determining the Amount of Space Used by Internal Objects
SELECT SUM(internal_object_reserved_page_count) AS [internal object pages used],
(SUM(internal_object_reserved_page_count)*1.0/128) AS [internal object space in MB]
FROM sys.dm_db_file_space_usage;
--0.625000 MB

--4. Determining the Amount of Space Used by User Objects
SELECT SUM(user_object_reserved_page_count) AS [user object pages used],
(SUM(user_object_reserved_page_count)*1.0/128) AS [user object space in MB]
FROM sys.dm_db_file_space_usage;
--1.500000

If we see the above query, total space occupied by tempDB is 63 GB. 

When I tried to see what are the objects making this total of 63 GB(Query 2, 3, 4) they do not sum up to 63 GB.

How can I know what is causing the tempDB to 63 GB and how can I check what is the root cause for this unexepected increase in the tempDB growth

NOTE: Last week, RAM has been increased by 8 GB and  2 processors were added.


Raksha

subselect with newid()

$
0
0

when I run an update sql like this one

update table1

set column1 = (select top 1 column1 from table2 order by newid())


the sql server run subselect once or many times (once for each row in table1) depend on how many rows are in table1.

I understand that is a good idea to cache subselect if it's doesn't contain any changeable data to optimize and boost performance of update sql, but in this case there is a "order by newid()" witch will order randomly and subselect will return random value for each row in table "table1", so will be better to have some hint for "don't cache subselect data" or to check subselect on parsing and if found newid() function call don't use cache.

MERGE failed because the following SET options have incorrect settings: 'ANSI_WARNINGS'.

$
0
0

I turned off ANSI_WARNINGS to insert 'Large' size data into a 'smaller' column. Now I couldn't get the MERGE statement working anymore, fails with the following error.

MERGE failed because the following SET options have incorrect settings: 'ANSI_WARNINGS'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations.

What are my options to fix "String or binary data would be truncated." error other than setting ANSI_WARNINGS OFF? I know I may reset data to match with the target column length before inserting. Is there anything else I can do?

Thanks.

database compatibility

$
0
0

Hi ,

I wanted to know if the database compatibilty in sql server can change on its own without someone changing it ?and also if there is a way to know who did the change in compatibilty ?

Thanks

Arindam

Backupmediaset identical values

$
0
0

SQL Server 2005 SP4 Standard

Windows 2003 R2 SP2 Enterprise

I am not able to understand the presence of a second physical device name that is similar to the first device but has _1 at the end. Any guidance is appreciated.


-Jeelani

issue while inserting values into tables

$
0
0

I have a table (abc_table) and i need to insert 2 millions Records

While i was inserting data into table (First these data will insert into Temp tables then insert into actual tables ) 4000 records are inserted successfully after that i got error likeinsertion failed error message  

I verified databases(TempDB, UserDB) sizes and disk size on  server it has sufficient space.

Could you plz help me what are the remaining  things i need to check

 


Kamal


SQL Server Agent job between 2 instances fails with Error 18456 - Login Failed for user

$
0
0

Hi,

SQL Server version: 2012 EE

OS: Windows 2008 R2 Enterprise

In my server, i have 2 instances, and I am trying to configure a SQL Server Agent job to query one table in Instance A, and insert some modified data in Instance B, both in the same server.

When i execute the job in instance A, i get the following error:

Executed as user: NT SERVICE\SQLSERVERAGENT. Login Failed for user "NT SERVICE\SQLSERVERAGENT". [SQLSTATE 28000] (Error 18456). The step failed.

I have already configure instance A as Master and disabled encryption, by changing the parameter MsxEncryptChannelOptions to 0 in regedit. I've also made my target instance (instance B) as a Target.

What am i missing?

Thanks for your attention and pacience

Table Size Increased after Column Store Index Rebuild (even though partition size decreased)

$
0
0

Hi,

I have a large table (about 60GB) with a Clustered Column Store Index (156 columns). The table is alsopartitioned (using SQL Server 2014 Developer Edition).

After the table was being populated with data for a while, I wanted to test the effects of Index Rebuild on the space used by the table.

I performed the test on a single partition.

I executed the following query to get an idea on how the segments are set up and how much disk space they take:

select object_name(object_id), partition_number, segment_id
, COUNT(DISTINCT column_id) AS NumOfColumns
, SUM(cs.row_count) AS Total_row_count
, AVG(cs.row_count) AS Avg_row_count
, MIN(cs.row_count) AS Min_row_count
, MAX(cs.row_count) AS Max_row_count
, SUM(cs.on_disk_size) AS Total_on_disk_size
, AVG(cs.on_disk_size) AS Avg_on_disk_size
, MIN(cs.on_disk_size) AS Min_on_disk_size
, MAX(cs.on_disk_size) AS Max_on_disk_size
from sys.column_store_segments as cs
inner join sys.partitions as p
on
	p.partition_id = cs.partition_id
where 1=1
and object_id = object_id('MyTable')
and partition_number = 10
GROUP BY object_name(object_id), partition_number, segment_id
ORDER BY segment_id

I also executed sp_spaceused on the table and noted its total size.

Then I executed an Index Rebuild on the one partition only of the clustered column store index:

ALTER INDEX [cci_MyTable] ON MyTable REBUILD PARTITION = 10

Then I executed the query above and sp_spaceused again and noted the changes.

The result was:

  • Two new segments were created.
  • The number of row counts per segment shuffled up (but the grand total remained the same).
  • The grand total of on_disk_size became smaller by ~26 MB.
  • The table size (from sp_spaceused) became BIGGER by ~12MB.

So my question is:

Why, even though the total partition size became smaller, the total table size became bigger?

Here are the detailed results of sp_spaceused before and after the rebuild:

namerowsreserveddataindex_sizeunused
MyTable12958714560867096 KB60729232 KB
7240 KB130624 KB
namerowsreserveddataindex_sizeunused
MyTable12958714560879504 KB60741712 KB
7240 KB130552 KB


Note that I executed the index rebuild on a single partition only (partition 10 in this case), and I'm executing sp_spaceused at the table level; the total number of rows in the table remained the same. But the reserved and data used increased, while the index_size remained the same.

This is all rather strange to me.

I would figure that the index rebuild would require some additional space as a working area, but when finished, this space will be marked as unused. So I would expect maybe the reserved column to increase, but the data column to decrease (since at the partition level, the total partition size actually decreased).

Any explanations? What could cause this?

Thanks


Eitan Blumin; SQL Server Consultant - Madeira SQL Server Services; http://www.madeira.co.il/author/eitan/

SQL Server agent job failing to back up database

$
0
0

I have set up a SQL server agent job to back up database on regular basis.. For some reason the back up fails.. Could not find any meaningful info in the logs.. Transaction logs are getting created for the same DB but not the database back up..

The below is my environment..

MS SQL Server 2005 - 9.00.1399.06

Windows 2003 server SP2

Any pointers would be helpful.. I checked the event logs and the agent logs and did not see obvious error.

Thanks

Integrated Security

$
0
0

I have create a .Net project with SQL 2012

In webconfig connection string  look like below :

<add name="DefaultConnection" connectionString="Data Source=xxxxxx ;Initial Catalog=xxxx User Id=xx;Password=xxxx"/> -->

I  published the code in IIS ….

I imported the SQL DB (Note:  connection string now like below without User Id and Password )

<add name="DefaultConnection" connectionString="Data Source= xxxxxx;Initial Catalog=xxxx;Integrated Security=True"/> 

When I run the code  from the VS2012 its running ; there is login screen (user name and password coming from SQL) to access the application it’s also working… but if I publish the same code in the IIS its running but on the Login screen if I give the user name and password for access the application its says INVALID.

Please advice.


Hai

How much RAM supports SQLSERVER 2000 in windows server 2008

$
0
0

Hi All,

How much RAM supports SQLSERVER 2000 in windows server 2008.

Viewing all 12554 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>