Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Search Indexer ExceptionSearch Indexer Exception
Previous
 
Next
New Post
3/3/2009 11:01 PM
 

I've had my database filling up exponentially, and after checking the event viewer, I've found a pretty gross search indexer exception that's repeated hundreds of times every 30 minutes (when the search indexer is run).  It appears on two pages, each of the pages is simply a report module that loads about 50 records from the db and display it on the page (haven't had any problems with this other than the search indexer errors).

ModuleId: 433
SearchItemId: 0
Title: Basic Report
SearchKey:
GUID:
AssemblyVersion: 05.00.00
PortalID: -1
PortalName:
UserID: -1
UserName:
ActiveTabID: -1
ActiveTabName:
RawURL:
AbsoluteURL:
AbsoluteURLReferrer:
UserAgent:
DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider
ExceptionGUID: efa8ff36-dcb3-434c-b139-473f4d40c219
InnerException: Cannot insert duplicate key row in object 'dbo.SearchItem' with unique index 'IX_SearchItem'. The statement has been terminated.
FileName:
FileLineNumber: 0
FileColumnNumber: 0
Method: System.Data.SqlClient.SqlConnection.OnError
StackTrace:
Message: DotNetNuke.Services.Exceptions.SearchException: Cannot insert duplicate key row in object 'dbo.SearchItem' with unique index 'IX_SearchItem'. The statement has been terminated. ---> System.Data.SqlClient.SqlException: Cannot insert duplicate key row in object 'dbo.SearchItem' with unique index 'IX_SearchItem'. The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteScalar() at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteScalar(SqlConnection connection, CommandType commandType, String commandText, SqlParameter[] commandParameters) at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteScalar(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters) at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteScalar(String connectionString, String spName, Object[] parameterValues) at DotNetNuke.Data.SqlDataProvider.AddSearchItem(String Title, String Description, Int32 Author, DateTime PubDate, Int32 ModuleId, String Key, String Guid, Int32 ImageFileId) at DotNetNuke.Services.Search.SearchDataStoreController.AddSearchItem(SearchItemInfo item) at DotNetNuke.Services.Search.SearchDataStore.StoreSearchItems(SearchItemInfoCollection SearchItems) --- End of inner exception stack trace ---
Source:
Server Name: WEB701

Any ideas?

 
New Post
4/25/2009 11:04 PM
 

I got tired of seeing this error myself.  A little investigation into the database identified the root cause as the stored proc that adds items to the SearchItem table.  As installed by DNN distribution modules, it does not check to see if a record already exists for the ModuleID and SearchKey that it is trying to add.  Since there is a unique index on the table for these fields, when the stored proc tries to insert a duplicate, the error gets thrown.  The fix is to check to see if the record already exists, and if it does, just update it instead of trying to insert it.  In both cases, the ID of the record needs to be returned.  Here is the code I used to do an alter on the stored proc:

SET Ansi_Nulls  ON  
GO
SET Quoted_IdentIfier  ON  
GO
ALTER PROCEDURE [dbo].[AddSearchItem]
               @Title       NVARCHAR(200),
               @Description NVARCHAR(2000),
               @Author      INT,
               @PubDate     DATETIME,
               @ModuleId    INT,
               @SearchKey   NVARCHAR(100),
               @Guid        NVARCHAR(200),
               @ImageFileId INT
AS
  DECLARE  @ID INT
  SELECT @ID = SearchItemId
  FROM   SearchItem
  WHERE  ModuleId = @ModuleID
         AND SearchKey = @SearchKey
  IF @ID IS NULL
    BEGIN
      INSERT INTO SearchItem
                 ([Title],
                  [Description],
                  [Author],
                  [PubDate],
                  [ModuleId],
                  [SearchKey],
                  [guId],
                  [HitCount],
                  [ImageFileId])
      VALUES     (@Title,
                  @Description,
                  @Author,
                  @PubDate,
                  @ModuleId,
                  @SearchKey,
                  @Guid,
                  0,
                  @ImageFileId)
      SELECT Scope_identity()
    END
  ELSE
    BEGIN
      UPDATE [SearchItem]
      SET    [Title] = @Title,
             [Description] = @Description,
             [Author] = @Author,
             [PubDate] = @PubDate,
             [ModuleId] = @ModuleId,
             [SearchKey] = @SearchKey,
             [guId] = @Guid,
             [HitCount] = [HitCount] + 1,
             [ImageFileId] = @ImageFileId
      WHERE  SearchItemId = @ID
      SELECT @ID
    END

I also found a smaller error in a related stored proc that I am not sure is causing any problems, but should probably be fixed as well.  Here is the code to fix this error, which just adds a BEGIN - END block around the ELSE portion of the code:

SET Ansi_Nulls  ON 
GO
SET Quoted_IdentIfier  ON 
GO
ALTER PROCEDURE [dbo].[AddSearchItemWord]
               @SearchItemID  INT,
               @SearchWordsID INT,
               @Occurrences   INT
AS
  DECLARE  @ID INT
  SELECT @id = SearchItemWordId
  FROM   SearchItemWord
  WHERE  SearchItemId = @SearchItemID
         AND SearchWordsId = @SearchWordsID
  IF @ID IS NULL
    BEGIN
      INSERT INTO SearchItemWord
                 ([SearchItemId],
                  [SearchWordsId],
                  [Occurrences])
      VALUES     (@SearchItemID,
                  @SearchWordsID,
                  @Occurrences)
      SELECT Scope_identity()
    END
  ELSE
    BEGIN
      UPDATE SearchItemWord
      SET    Occurrences = @Occurrences
      WHERE  SearchItemWordId = @id
             AND Occurrences <> @Occurrences
      SELECT @id
    END

You can implement both of these changes by copying each of the code sections above into the SQL code execution tool within the Host menu.  After I put these in place, the errors stopped completely.


Gene W
 
New Post
4/26/2009 2:19 AM
 

Gene,

I am sure, the error is evoked by an incorrect implementation of iSearcheable in your installation.

Anyways, it looks promising to investigate your changes for integration into DNN core code. please log your enhancement suggestion into the public issue tracker (2nd from top) at support.dotnetnuke.com, thank you.


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Search Indexer ExceptionSearch Indexer Exception


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out