Cfgridupdate Error - casting
I'm getting this error on a cfgridupdate: Error casting an
object of type to an incompatible type. The weird thing is that I
only get it on my client machine. Others are using it without the
error. It's a simple grid, no date/time. There is one field named
"type". Is type a reserved word perhaps? Even so, why would i get
this only on my machine? Any help is appreciated. Thanks.
--Steve
sbrehm,
You are absolutely right. Turning debugging off solved the
problem. In this case, you can leave debugging on but uncheck the
"Database Activity" checkbox. Something must be getting confused
between the DB debugging and the CFGRIDUPDATE call. Hopefully Adobe
will fix this glitch.
By the way, I tried using <cfsetting
showdebugoutput="no"> on the .cfm file in question, but that
didn't work. I had to physically disable to "database activity"
debugging completely.
Thanks for the suggestion!
Similar Messages
-
Error with CFGRIDUPDATE after installing CFMX 7 Updaters
I installed ColdFusion MX 7 Updater (7.0.1) and ColdFusion MX
7 Updater 2 (7.0.2). Now I'm geting the following errors when using
CFGRIDUPDATE:
Error casting an object of type
coldfusion.sql.CFNoResultSetTable to an incompatible type. This
usually indicates a programming error in Java, although it could
also mean you have tried to use a foreign object in a different way
than it was designed.
coldfusion.sql.CFNoResultSetTable
<cfgridupdate datasource="#request.dsn#" grid="thisGrid"
tablename="MY_TABLE">
Is anyone else getting this? I'm going to handle the SQL
manually until I can use CFGRIDUPDATE again.sbrehm,
You are absolutely right. Turning debugging off solved the
problem. In this case, you can leave debugging on but uncheck the
"Database Activity" checkbox. Something must be getting confused
between the DB debugging and the CFGRIDUPDATE call. Hopefully Adobe
will fix this glitch.
By the way, I tried using <cfsetting
showdebugoutput="no"> on the .cfm file in question, but that
didn't work. I had to physically disable to "database activity"
debugging completely.
Thanks for the suggestion! -
When using CFGridUpdate, I get this exception:
Error casting an object of type to an incompatible type. This
usually indicates a programming error in Java, although it could
also mean you have tried to use a foreign object in a different way
than it was designed.
What does this mean and how do I make it go away?!
Thanks!getting same error. Did you find a work around?
-
There seems to be a lot of old chatter about the cfgridupdate
not working but nothing recent. I am unsing MX7 with java version
1.4.2_05. I get the "Error casting an object of type to an
incompatible type " error message. I would love for this to work
since I need a very simple interactive grid. Any
Suggestions.To answer my own question on this...
cfgridupdate wasn't working so I wrote a regular block of
code to make the required changes when submitting a grid. -
Column Formula with Error in OBIEE 11g
Hello,
On Oracle Business Intelligence Enterprise Edition 11g, I am trying to create an analysis. The database is MySQL. In the database, there is a field of type varchar(10). This
field shows a date. In OBIEE 11g, when creating the analysis, in the Criteria tab, I choose this column (varchar) and edit the formula of it. The operation that I want to do is:
YEAR(CURRENT_DATE) - SUBSTRING("TableName"."ColumnName" FROM 1 FOR 4) where the ColumnName is the name of the column of type varchar(10)
but I get an error: +[nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 27002] Near <->: Syntax error [nQSError: 26012]+
If I execute the same query directly on the MySQL database, I get the desired result without any error.
Also, if I use the following formula, I also get an error:
CAST((SUBSTRING("TableName"."ColumnName" FROM 1 FOR 4)) AS INTEGER)
So, I am asking why the first query throws an error in OBIEE 11g but not when it runs directly on the MySQL database. Also, how can I convert in OBIEE 11g a string to integer?
Thank you in advance,
GriseldaBusiness Intelligence Foundation wrote:
Hi
Im getting below error in Bi11g. core application services is down.
Error:
[nQSError: 46066] Operation cancelled.
[nQSError: 46067] Queue has been shut down. No more operations will be accepted.
If anyone Know tell me.
Thanks and Regards
sathyaHi sathya,
It could mean several different things. Do you know if the administrator have shut down the services? If you have access to the server, check to see if all the services are up and running.
Thanks,
-Amith. -
Who Can help me? About "Error 500--Internal Server Error"
Dear,brothers,
I can run AdminMain in "http://192.9.100.3:7001/AdminMain". But when I run
pooltest in
"http://192.9.100.3:7001/pooltest". It cannot work.It displays:
Error 500--Internal Server Error
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.5.1 500 Internal Server Error
The server encountered an unexpected condition which prevented it from
fulfilling the request.
When I see the weblogic.log,there are some information about it:
Wed Jun 28 20:03:51 MDT 2000:<E> <IIOPSocket> failed to configure user for
iiop protocol
Wed Jun 28 20:03:56 MDT 2000:<E> <ServletContext-General> Error casting
servlet: examples.jdbc.oracle.simpleselect
java.lang.ClassCastException:
at
weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java
:382)
at weblogic.servlet.internal.ServletStubImpl.createInstances(Compiled Code)
at
weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.jav
a:338)
at
weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:16
4)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:99)
at
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
l.java:742)
at
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
l.java:686)
at
weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
Manager.java:247)
at
weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:361)
at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:261)
at weblogic.kernel.ExecuteThread.run(Compiled Code)
Wed Jun 28 20:03:56 MDT 2000:<E> <ServletContext-General> Servlet failed
with Exception
javax.servlet.ServletException: Servlet class:
examples.jdbc.oracle.simpleselect does not implement javax.servlet.Servlet
at
weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java
:385)
at weblogic.servlet.internal.ServletStubImpl.createInstances(Compiled Code)
at
weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.jav
a:338)
at
weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:16
4)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:99)
at
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
l.java:742)
at
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
l.java:686)
at
weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
Manager.java:247)
at weblogic.socket.MuxableSocketHTTP.invokeServlet(Compiled Code)
at weblogic.socket.MuxableSocketHTTP.execute(Compiled Code)
at weblogic.kernel.ExecuteThread.run(Compiled Code)
Get the TNSNAMES.ORA file of your database and copy it in Discoverer Home (i.e., home where you installed Discoverer Administrator, usually BIToolsHome_1/network/admin). Then login to Discoverer Administrator using a new database user (usually EUL_US) which you might have created as part of installation. Once logged in, it will prompt you to create an EUL. Please follow Discoverer Installation Document.
-
Hello,
OBIEE 11.1.1 answers question.
To recover full date time accuracy from a number of date / time elements I have concatenated up date / time elements to give me a full char version of a timestamp, however when I try to convert it to a timestamp to perform a calculation on it I get a general error, even though when I convert a timestamp to a char I see an identical date / time string in the format dd/mm/yyyy hh:mi:ss i.e. 31/01/2011 15:32:26
I have also tried switching the char datestring around to yyyymmdd.
Does anyone know the secret, the code examples from the manuals just do not work for timestamp as they say they should, i.e. you cannot cast a date directly to stamp, but you can cast it via a char to timestamp....
A simple example of converting a literal to a timestamp (including hours / minutes / seconds) would be ideal here.
And yes, I know this would be best created in the repository not in analytics.
many thanks,
Robert.Okay, I have answered my question, the timestamp format seems to be; -
cast( '31-DEC-01010203' as timestamp)
Where this would equate to the 31st December 2001 01:02:03 (just after 2 minutes past 1 in the morning).
But...
Still my function bombs when I feed concatenated values into it, even though when I look at the results for the filter applied all of them - pre casting to timestamp - conform to my "format mask" above.
Does this mean that even though all of my values evaluate properly the function is being applied to ALL values before any (independent) filters are applied??
Is there anyway to gracefully handle these kind of cast errors - the logical equivalent of; -
on error (cast("my folder"."my character date" as timestamp) then cast('01-DEC-51000001' as timestamp)
thanks for any pointers on this, appreciated.
Robert. -
Error create new Application Set based on ApShell (BPC 5.1)
On BPC 5.1, I'm trying to create a new Application Set based on Apshell, called "UFG".
At the step where the OLAP database is created, I receive an error message stating the following.
Error message:The ApShell Role role referenced by the CubePermission permission does not exist in the UFG database.
Any help would be greatly appreciated.Hi Joost,
yes it's a fresh 5.1 installation. I'm trying the steps you suggested, however I get the following errors:
If I try to assign the installation user to the AdminTeam I receive the following error:
Cast from string "SAP" to type 'integer' not valid.
If I attempt to assign the installation user directly to the SysAdmin Task Profile and to the AdminMbrAccPrf Member Access Profile, the error message is:
Error converting data type nvarchar to numeric. -
Type casting for properties accessed in COM Object
I have a com object that I need to access which provides my a
list of addresses in an Array. The object give me a property that
has a count for the number of addresses and then I have a loop that
calls the property which contains the address details to get each
individual address each time passing to the property the INDEX
value on the loop.
This errors out each time.
The error I get is
Error casting an object of type to an incompatible type.
This usually indicates a programming error in Java, although it
could also mean you have tried to use a foreign object in a
different way than it was designed.
It appears the the variable type of the index is not
compatible with the property of the component(which is an int).
IS there some way to type cast the variable used as the index
for CFLOOP to that of an INT?You can try to use the JavaCast("int", myValue) function. It
works great for Java objects, but I'm not sure how well it will
work for COM. Worth a try, I guess.
In your case it would be something like:
<cfobject type="COM" context="INPROC" action="create"
name="MR" class="DLLNAME">
<cfloop from="1" to="#AddressCount#" index="i">
<cfset VDname = mr.vdsname(JavaCast("int", i))>
<cfset VDaddress = mr.vdsaddress(JavaCast("int", i))#>
<cfset VDXML = mr.VDSXML(JavaCast("int", i))>
</cfloop> -
Output Parameter cast problems
Wondering if anyone has seen this ...
Migrating a data access layer (based on the MS DAAB) using the ODP.NET provider. I wrote my own parameter discovery code to dynamically configure parameters at runtime - just like the SqlCommandBuilder.DeriveParameters() method does for SQL Server sprocs.
(I query the "all_arguments" view to get this data, by the way, passing the package name and procedure name.)
Here's the problem: you cannot discover the Size property for a parameter via this query. Bummer. So for VarChar2 and Char types I tried setting the Size to somethng big, like 2000.
When I retrieve the parameters after an ExecuteNonQuery statement, I am getting Type cast errors:
"Cast from type 'OracleString' to type 'String' is not valid"
Here's the weird part:
- CType(params(5).Value, Integer) 'WORKS
- CType(params(2).Value, String) 'DOESN'T WORK
- params(2).Value.ToString 'WORKS
- CType(params(2).Value, Date) 'DOESN'T WORK
What the ...? Why can't I cast a VarChar2 or Char type back to a .NET String? Why does ToString work but Ctype() not work?
I hope somebody can offer guidance, I've got a lot invested in this DAL :-)
Thanks eh
Kurt Mang
Vancouver BCThere's not really an elegant way to provide these conversions in VB. In C# OracleString uses operator overloading to provide type conversions, but this version of VB doesn't support it.
They might have implemented IConvertible on the oracle types.
Then you could write
Dim osw as new OracleString("Hello")
Dim s as String = CType(osw, IConvertible).ToString
But that's not really better than
Dim osw as new OracleString("Hello")
Dim s as String = osw.Value
The long and short of it is, OracleTypes ( and other ADO.NET provider types), are special high-performance types (usually value types), and they convert using a different idiom. By convention they are converted to the corresponding framework type using a property called .Value, and constructed from framework types using a constructor.
String s = New OracleString("Hello").Value
Converts the Unicode string "Hello" to an OracleString structure, and then back to a unicode string.
David -
With the following code under CF9,
<cfset c_dir=#GetDirectoryFromPath(GetCurrentTemplatePath())#>
<cfset ex_file=c_dir & "eshopping.xlsx">
#ex_file#<br>
<!--- 80 rows --->
<!--- 454 colomns --->
<cfset val=SpreadsheetGetCellValue(ex_file, "6", "454")>
<hr>
value : #val#
I have the following error : Internal server error : Error casting an object of type java.lang.String to an incompatible type. This usually indicates a programming error in Java, although it could also mean you have tried to use a foreign object in a different way than it was designed. java.lang.String
(Excel 2007, extension xlsx)
I think I neeed to know how to define dthe "spreadsheetobject" ?
is this the Excel file adress ? or something ?
Thanks for HELP, I thought It will be easy of use ?plarts wrote:
With the following code under CF9,
<cfset c_dir=#GetDirectoryFromPath(GetCurrentTemplatePath())#>
<cfset ex_file=c_dir & "eshopping.xlsx">
#ex_file#<br>
<!--- 80 rows --->
<!--- 454 colomns --->
<cfset val=SpreadsheetGetCellValue(ex_file, "6", "454")>
<hr>
value : #val#
I have the following error : Internal server error : Error casting an object of type java.lang.String to an incompatible type. This usually indicates a programming error in Java, although it could also mean you have tried to use a foreign object in a different way than it was designed. java.lang.String
(Excel 2007, extension xlsx)
I think I neeed to know how to define dthe "spreadsheetobject" ?
is this the Excel file adress ? or something ?
You have guessed correctly what the problem is. The variable ex_file is a string representing a URL, not a spreadsheet object. You may define the spreadsheet object like this:
<cfset c_dir=#GetDirectoryFromPath(GetCurrentTemplatePath())#>
<cfset ex_file=c_dir & "eshopping.xlsx">
<cfset spreadSheetObj = spreadSheetRead(ex_file)> -
Error:
Error casting an object of type to an incompatible type. This usually indicates a programming error in Java, although it could also mean you have tried to use a foreign object in a different way than it was designed.
The error occurred in C:\Inetpub\wwwroot\RMS\Untitled-3.cfm: line 15
13 : <cfloop from="1" to ="#listlen(application.Sql_SC)#" index="i">
14 : union
15 : <cfquery name="GetZone#i#" datasource="#i#">
16 : SELECT ccflocationID, Location_Name
17 : FROM ccflocation
<cfcomponent hint="This cfc goes to Scorecard environment and grabs some stuff">
<cffunction name="Zone" access="public" returntype="Query">
<cfset myLoc = QueryNew("ccflocationID,Location_Name", "Integer,VarChar")>
<cfargument name="DSN" required="true" type="string">
<cfquery dbtype="query" name="GetZone">
select ccflocationID, Location_Name from myLoc
<cfloop from="1" to ="#listlen(arguments.DSN)#" index="i">
union
<cfquery name="GetZone#i#" datasource="#i#">
SELECT ccflocationID, Location_Name
FROM ccflocation
</cfquery>
</cfloop>
</cfquery>
<cfreturn GetZone>
</cffunction>
</cfcomponent>You can NOT mix QoQ and DB queries together...
this is QoQ
<cfquery dbtype="query" name="GetZone">
this is DB query
<cfquery name="GetZone#i#" datasource="#i#">
You will need to run your DB queries first (outside QoQ)
and then run the loop again to UNION all results...
<cfloop from="1" to ="#listlen(arguments.DSN)#" index="i">
<cfquery name="GetZone#i#" datasource="#i#">
SELECT ccflocationID, Location_Name
FROM ccflocation
</cfquery>
</cfloop>
<cfquery dbtype="query" name="GetZone">
select ccflocationID, Location_Name from myLoc
<cfloop from="1" to ="#listlen(arguments.DSN)#" index="i">
union
select ccflocationID, Location_Name from GetZone#i#
</cfloop>
</cfquery> -
Cast was not declared in scope
Set::View setResults = theCache->entrySet(EqualsFilter::create(vPsngSmryExtractor, psng_smry_id));
for (Iterator::Handle iter = setResults->iterator(); iter->hasNext(); )
std::cout << "here" << std::endl;
Map::Entry::View vEntry = cast<Map::Entry::View>(iter->next());
//std::cout << vEntry->getKey() << " " << vEntry->getValue() << std::endl;
coherence.cpp:86: error: 'cast' was not declared in this scope
coherence.cpp:86: error: expected primary-expression before '>' token
is something wrong in the code..?
solved:: we need to use coherence::castYour first step should be to try without yaourt (or any other AUR helper). Those may be convenient but they are not recommended for troubleshooting. See if you can reproduce it with makepkg.
EDIT: Post on the AUR page. xxdiff doesn't compile here either.
Last edited by cfr (2013-08-26 02:14:00) -
Get list of Not Null and PK Columns
hi All,
I need to get the list of all the columns which are part of PK and not null, can you help me on this?
with the below query I am getting the not null ones but need to get the PK columns also
SqlServer Version is 2008R2
SELECT TABLE_CATALOG AS Database_Name, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, IS_NULLABLE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'Express'
AND IS_NULLABLE = 'NO'
Thanks!
NeilGive this a go. It includes by bitval solver function, as the status column is stored that way.
CREATE FUNCTION dbo.solveBitVal(@val BIGINT)
RETURNS @result TABLE (id INT, bitvalue BIGINT)
BEGIN
DECLARE @bitTranslate TABLE (id INT, bitvalue BIGINT)
DECLARE @numbah TABLE (num INT)
DECLARE @loopah INT
SET @loopah = 1
WHILE @loopah <= 63
BEGIN
INSERT INTO @bitTranslate (id, bitvalue) VALUES (@loopah, POWER(CAST(2 AS BIGINT),@loopah-1))
INSERT INTO @numbah (num) VALUES (@loopah)
SET @loopah = @loopah + 1
END
WHILE @val > 0
BEGIN
INSERT INTO @result
SELECT MAX(id), MAX(bitvalue) FROM @bitTranslate WHERE bitvalue <= @val
SELECT @val = @val - MAX(bitvalue) FROM @bitTranslate WHERE bitvalue <= @val
END
RETURN
END
GO
;WITH cons AS (
SELECT o.name, c.*, b.id AS statusID, ROW_NUMBER() OVER (PARTITION BY c.id, colid ORDER BY b.id) AS seq
FROM sys.sysconstraints c
INNER JOIN sys.objects o
ON c.id = o.object_id
CROSS APPLY dbo.solveBitVal(c.status) b
), rCTE AS (
SELECT c.name, c.constid, c.id, c.colid, c.spare1, c.status, c.actions, c.error, CAST(CASE WHEN statusID = 1 THEN 'PRIMARY KEY constraint '
WHEN statusID = 2 THEN 'UNIQUE KEY constraint '
WHEN statusID = 3 THEN 'FOREIGN KEY constraint '
WHEN statusID = 4 THEN 'CHECK constraint '
WHEN statusID = 5 THEN 'DEFAULT constraint '
WHEN statusID = 16 THEN 'Column-level constraint'
WHEN statusID = 32 THEN 'Table-level constraint '
END AS NVARCHAR(MAX)) AS statusName, c.seq, c.statusID
FROM cons c
WHERE seq = 1
UNION ALL
SELECT c.name, c.constid, c.id, c.colid, c.spare1, c.status, c.actions, c.error, CAST(r.statusName + ', ' + CASE WHEN c.statusID = 1 THEN 'PRIMARY KEY constraint '
WHEN c.statusID = 2 THEN 'UNIQUE KEY constraint '
WHEN c.statusID = 3 THEN 'FOREIGN KEY constraint '
WHEN c.statusID = 4 THEN 'CHECK constraint '
WHEN c.statusID = 5 THEN 'DEFAULT constraint '
WHEN c.statusID = 16 THEN 'Column-level constraint'
WHEN c.statusID = 32 THEN 'Table-level constraint '
END AS NVARCHAR(MAX)), c.seq, c.statusID
FROM cons c
INNER JOIN rCTE r
ON c.id = r.id
AND c.colid = r.colid
AND c.seq - 1 = r.seq
SELECT *
FROM rCTE
Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question. -
Service Broker Activation Deadlocking
I have implemented a (slightly) modified version of conversation recycling using conversation timers and stored procedure activation from http://rusanu.com/2007/05/03/recycling-conversations/ . However it appears that, occasionally, deadlocks occur
between the send and activated procedures on the conversation group/table. The main modification is that instead of having a column to represent the SPID in the table I am using an IdentifierType and Identifier value to identify the conversation. However I
am only using the defaults (@@SPID) so I don't think that should matter in this case.
For the send side I have:
CREATE PROCEDURE [dbo].[usp_SendMessage]
@endpointCode VARCHAR(255) = NULL,
@endpointGroup VARCHAR(255) = NULL,
@xmlPayload XML=NULL,
@binaryPayload VARBINARY(MAX)=NULL,
@varcharPayload VARCHAR(MAX)=NULL,
@identifier VARCHAR(50) = @@SPID,
@identifierType VARCHAR(50) = '@@SPID'
AS BEGIN
SET NOCOUNT ON
DECLARE @fromService SYSNAME,
@toService SYSNAME,
@onContract SYSNAME,
@messageType SYSNAME,
@conversationTimeout INT
SELECT @fromService = FromService
, @toService = ToService
, @onContract = OnContract
, @messageType = MessageType
, @conversationTimeout = ConversationTimeout
FROM dbo.ServiceBrokerEndpointConfig
WHERE GroupCode = @endpointGroup
IF @fromService IS NULL OR @toService IS NULL OR @onContract IS NULL OR @messageType IS NULL OR @conversationTimeout IS NULL
BEGIN
RAISERROR (
N'Failed to get endpoint config for GroupCode ''%s''.'
, 16, 1, @endpointGroup) WITH LOG;
RETURN;
END
DECLARE @SBDialog UNIQUEIDENTIFIER
DECLARE @Message XML
DECLARE @counter INT
DECLARE @error INT
DECLARE @handle UNIQUEIDENTIFIER;
DECLARE @NotNullCount INT = ((CASE WHEN @xmlPayload IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN @binaryPayload IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN @varcharPayload IS NULL THEN 0 ELSE 1 END))
IF @NotNullCount > 1
BEGIN
RAISERROR (
N'Failed to SEND because %i payload fields are filled in when no more than 1 is expected'
, 16, 1, @NotNullCount) WITH LOG;
RETURN;
END
SET @counter = 1
WHILE (1=1)
BEGIN
SET @handle = NULL
-- Seek an eligible conversation in [ServiceBrokerConversations]
-- We will hold an UPDLOCK on the composite primary key
SELECT @handle = Handle
FROM [ServiceBrokerConversations] WITH (UPDLOCK)
WHERE Identifier = @identifier
AND IdentifierType = @identifierType
AND FromService = @fromService
AND ToService = @toService
AND OnContract = @onContract;
IF @handle IS NULL
BEGIN
-- Need to start a new conversation for the current @Id
BEGIN DIALOG CONVERSATION @handle
FROM SERVICE @fromService
TO SERVICE @toService
ON CONTRACT @onContract
WITH ENCRYPTION = OFF;
-- Then the sender must listen on the
-- send queue for the http://schemas.microsoft.com/SQL/ServiceBroker/DialogTimer message type and
-- cleanup appropriately.
IF @conversationTimeout IS NOT NULL
BEGIN
BEGIN CONVERSATION TIMER (@handle) TIMEOUT = @conversationTimeout;
END
INSERT INTO [ServiceBrokerConversations]
(Identifier, IdentifierType, FromService, ToService, OnContract, Handle)
VALUES
(@identifier, @identifierType, @fromService, @toService, @onContract, @handle);
END;
IF @xmlPayload IS NOT NULL
BEGIN
-- Attempt to SEND on the associated conversation
;SEND ON CONVERSATION @handle
MESSAGE TYPE @messageType (@xmlPayload);
END ELSE IF @binaryPayload IS NOT NULL
BEGIN
;SEND ON CONVERSATION @handle
MESSAGE TYPE @messageType (@binaryPayload);
END ELSE BEGIN
;SEND ON CONVERSATION @handle
MESSAGE TYPE @messageType (@varcharPayload);
END
SELECT @error = @@ERROR;
IF @error = 0
BEGIN
-- Successful send, just exit the loop
BREAK;
END
SELECT @counter = @counter+1;
IF @counter > 10
BEGIN
-- We failed 10 times in a row, something must be broken
RAISERROR (
N'Failed to SEND on a conversation for more than 10 times. Error %i.'
, 16, 1, @error) WITH LOG;
BREAK;
END
-- Delete the associated conversation from the table and try again
DELETE FROM [ServiceBrokerConversations]
WHERE Handle = @handle;
SET @handle = NULL;
END
END
And for the activation on the initiator queue I have:
CREATE PROCEDURE [dbo].[usp_InitiatorQueueHandler]
AS
BEGIN
SET NOCOUNT ON
DECLARE @handle UNIQUEIDENTIFIER;
DECLARE @messageTypeName SYSNAME;
DECLARE @messageBody VARBINARY(MAX);
WHILE (1=1)
BEGIN
BEGIN TRAN;
;WAITFOR (RECEIVE TOP(1)
@handle = conversation_handle,
@messageTypeName = message_type_name,
@messageBody = message_body
FROM [InitiatorQueue]), TIMEOUT 5000;
IF (@@ROWCOUNT = 0)
BEGIN
COMMIT TRAN;
BREAK;
END
-- Call the base stored procedure to handle ending the conversation
EXEC dbo.usp_BrokerHandleInitiator @handle, @messageTypeName, @messageBody
COMMIT TRAN;
END
END
GO
ALTER QUEUE [InitiatorQueue]
WITH ACTIVATION (
STATUS=ON,
PROCEDURE_NAME=dbo.usp_InitiatorQueueHandler,
EXECUTE AS OWNER,
MAX_QUEUE_READERS=10
GO
CREATE PROCEDURE [dbo].[usp_BrokerHandleInitiator]
@handle UNIQUEIDENTIFIER,
@messageTypeName SYSNAME,
@messageBody VARBINARY(MAX)
AS
BEGIN
SET NOCOUNT ON
IF @handle IS NOT NULL
BEGIN
-- Delete the message from the [ServiceBrokerConversations] table
-- before sending the [EndOfStream] message. The order is
-- important to avoid deadlocks.
IF @messageTypeName = N'http://schemas.microsoft.com/SQL/ServiceBroker/DialogTimer'
OR @messageTypeName = N'http://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'
BEGIN
DELETE FROM [ServiceBrokerConversations]
WHERE [Handle] = @handle;
END
IF @messageTypeName = N'http://schemas.microsoft.com/SQL/ServiceBroker/DialogTimer'
BEGIN
;SEND ON CONVERSATION @handle
MESSAGE TYPE [EndOfStream];
END
ELSE IF @messageTypeName = N'http://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'
BEGIN
END CONVERSATION @handle;
END
ELSE IF @messageTypeName = N'http://schemas.microsoft.com/SQL/ServiceBroker/Error'
BEGIN
END CONVERSATION @handle;
-- We could send a notification or store the error in a table for further inspection
DECLARE @error INT;
DECLARE @description NVARCHAR(4000);
WITH XMLNAMESPACES (N'http://schemas.microsoft.com/SQL/ServiceBroker/Error' AS ssb)
SELECT
@error = CAST(@messageBody AS XML).value(
'(//ssb:Error/ssb:Code)[1]', 'INT'),
@description = CAST(@messageBody AS XML).value(
'(//ssb:Error/ssb:Description)[1]', 'NVARCHAR(4000)')
-- Maybe log to audit log instead?
RAISERROR(N'Received error Code:%i Description:"%s"',
16, 1, @error, @description) WITH LOG;
END;
END
END
The deadlock XML is:
<deadlock>
<victim-list>
<victimProcess id="process807dbd0c8" />
</victim-list>
<process-list>
<process id="process807dbd0c8" taskpriority="0" logused="0" waitresource="METADATA: database_id = 21 CONVERSATION_GROUP($hash = 0xff26c7e1:0x478840de:0xd403bb)" waittime="2600" ownerId="8333217736" transactionname="GetDialogByHandle" lasttranstarted="2015-03-23T10:53:58.683" XDES="0x87f251c90" lockMode="X" schedulerid="2" kpid="7220" status="suspended" spid="110" sbid="0" ecid="0" priority="0" trancount="2" lastbatchstarted="2015-03-23T10:53:58.683" lastbatchcompleted="2015-03-23T10:53:58.683" lastattention="1900-01-01T00:00:00.683" clientapp=".Net SqlClient Data Provider" hostname="COLFOQA2" hostpid="1436" loginname="dev" isolationlevel="read committed (2)" xactid="8333217704" currentdb="21" lockTimeout="4294967295" clientoption1="673185824" clientoption2="128056">
<executionStack>
<frame procname="MYDB.dbo.usp_SendMessage" line="116" stmtstart="7540" stmtend="7696" sqlhandle="0x03001500aada77428391a0005da4000001000000000000000000000000000000000000000000000000000000">
SEND ON CONVERSATION @handle
MESSAGE TYPE @messageType (@xmlPayload); </frame>
</executionStack>
<inputbuf>
Proc [Database Id = 21 Object Id = 1115151018] </inputbuf>
</process>
<process id="process869a5e558" taskpriority="0" logused="588" waitresource="KEY: 21:72057594039959552 (1f1ae6770d1b)" waittime="2600" ownerId="8333217730" transactionname="user_transaction" lasttranstarted="2015-03-23T10:53:58.683" XDES="0x3e28456a8" lockMode="U" schedulerid="4" kpid="6720" status="background" spid="22" sbid="0" ecid="0" priority="0" trancount="2">
<executionStack>
<frame procname="MYDB.dbo.usp_BrokerHandleInitiator" line="28" stmtstart="1996" stmtend="2144" sqlhandle="0x03001500f704cd06e691a0005da4000001000000000000000000000000000000000000000000000000000000">
DELETE FROM [ServiceBrokerConversations]
WHERE [Handle] = @handle; </frame>
<frame procname="MYDB.dbo.usp_InitiatorQueueHandler" line="29" stmtstart="1014" stmtend="1172" sqlhandle="0x03001500316f56101694a0005da4000001000000000000000000000000000000000000000000000000000000">
EXEC dbo.usp_BrokerHandleInitiator @handle, @messageTypeName, @messageBody </frame>
</executionStack>
<inputbuf>
</inputbuf>
</process>
</process-list>
<resource-list>
<metadatalock subresource="CONVERSATION_GROUP" classid="$hash = 0xff26c7e1:0x478840de:0xd403bb" dbid="21" id="lock54fdb1800" mode="X">
<owner-list>
<owner id="process869a5e558" mode="X" />
</owner-list>
<waiter-list>
<waiter id="process807dbd0c8" mode="X" requestType="wait" />
</waiter-list>
</metadatalock>
<keylock hobtid="72057594039959552" dbid="21" objectname="MYDB.dbo.ServiceBrokerConversations" indexname="PK__ServiceB__877FDFD18DF079BD" id="lock6c65b1a00" mode="U" associatedObjectId="72057594039959552">
<owner-list>
<owner id="process807dbd0c8" mode="U" />
</owner-list>
<waiter-list>
<waiter id="process869a5e558" mode="U" requestType="wait" />
</waiter-list>
</keylock>
</resource-list>
</deadlock>
I have a clustered index on the fields I am SELECTing by and a UNIQUE index on the Handle (for the DELETE). When running the SELECT/DELETE statements against the table the query plan reports index seeks are being used:
CREATE TABLE [dbo].[ServiceBrokerConversations] (
[Identifier] VARCHAR (50) NOT NULL,
[IdentifierType] VARCHAR (50) NOT NULL,
[FromService] [sysname] NOT NULL,
[ToService] [sysname] NOT NULL,
[OnContract] [sysname] NOT NULL,
[Handle] UNIQUEIDENTIFIER NOT NULL,
[CreateDate] DATETIME2 (7) NULL,
PRIMARY KEY CLUSTERED ([Identifier] ASC, [IdentifierType] ASC, [FromService] ASC, [ToService] ASC, [OnContract] ASC) ON [PRIMARY],
UNIQUE NONCLUSTERED ([Handle] ASC) ON [PRIMARY]
) ON [PRIMARY];
What appears to be happening is the DELETE is somehow deadlocking with the SEND but I am not sure how since I am using them in the same order in both the send procedure and the activated procedure. Also, RCSI is enabled on the database I am receiving the
deadlocks on.
EDIT:
I think I have found the culprit with lock acquisition order:
- In the usp_SendMessage proc:
The SELECT locks the conversation record
The SEND locks the conversation group
- In the timer activated proc on the initiator queue:
The RECEIVE locks the conversation group
The DELETE locks the conversation record
Given that I think there may be a few solutions:
There is some subtle difference between my code and the code from the article that I am not noticing that when fixed will resolve the deadlocking. I am hoping this is the case since it seems that others have used this pattern without issues as far as I
know.
Or...The deadlocking is inherent to the pattern the code is using and I can either:
Deal with the deadlocking by adjusting the deadlock priority on the activated stored procedure so that it becomes the victim, and I can implement retry logic.
Remove conversation timers and activation all together and resort to some sort of job that expires the conversation by polling it, where I can control the ordering.
My ultimate goal is to eliminate any deadlocking on usp_SendMessage so that it "never" fails.
I appreciate any feedback!
ThanksI can understand why the deadlock happens. As you point out the activation procedure and the send SP acquire locks on the resources in reverse order.
Really why Remus does not consider this in his blog post, I don't know. But may I ask, since you have replaced @@spid as a key with two other columns, does this also mean that multiple processes can use the same conversation? I'm not so sure that
this is a good idea. I worked with an SB implementation which reuses conversations some months ago, and I recall that considered channing the pattern, but that I decided against it the end although I don't remember the exact details.
But so much is clear, if multiple processes can use the same handle, they will serialise on the SELECT with UPDLOCK. That will not happen if you change to REPEATABLEREAD, but I guess they will serialiase on the SEND instead.
The best way to address the problem appears to use SET LOCK_TIMEOUT 0 in the activation procedure and trap the the timeout error in a CATCH block, and let the message go back to the queue. This should be better than SET DEADLOCK_PRIORITY, since the there
will never be a deadlock that upholds the the sender.
Erland Sommarskog, SQL Server MVP, [email protected]
Maybe you are looking for
-
How to know if user (session) is authenticated in other application (SSO)
Hi folks! We've deployed various J2EE applications in some OC4J instances. So far the applications used SSO Authentication against OiD (LDAP), but we need a public access application. The problem is the following: we need a different behaviour in thi
-
Imported MPEG video playback problems
Hi, I have a client whose camera produces MPG video files. When she imports them into Presenter, the resulting video plays back way too fast, with no audio. If she plays the original MPG video on the desktop media player, it plays fine. Anyone with e
-
Joins - Retrieving 300 rows out of 2000 from both tables
How can you retrieve 300 out of 2000 rows from table B (columns monkee, data1, data2) and table A (columns monkee, data1, data2) ? No primary key, but will be using the monkee column for referencing data. Any ideas : Need concrete real life working e
-
Add new iCloud email to Apple ID
My Apple ID is based on my AT&T email address. I created and added an iCloud e-mail address as an alternate email address to my Apple ID. Because of some issues, I need to create a new iCloud e-mail address and use it as the alternate email address.
-
I have an IPhone 5 and the bluetooth will not stay connected with my 2011 Chrysler 200. I was told by Chrysler service department that it is a problem with the IPhone 5. Is there an update or a fix so i can use the bluetooth in my vehicle?