I have a table that is in a one way transactional publication. I need to create a full-text catalog on this table and have that catalog exist on the subscriber as well. I understand simply creating a FTC for an object in a publication will not cause that FTC to be replicated to the subscribers. I have scripted out the command and tried to use sp_addscriptexec to push it to the subscriber. When I do this, I get the following error:
Last 183 characters in 'sqlcmd' output buffer: Changed database context to 'database'.
Msg 574, Level 16, State 1, Server SQLSERVER, Line 2
CREATE FULLTEXT CATALOG statement cannot be used inside a user transaction.
Also, when this script is run directly from the subscriber, it works fine (but since the subscriber is our production machine, I'd prefer to not have to do it that way). I believe I can reinitialize the publication and have the FTC pushed to the subscriber, but this is not ideal either, since some of our databases can be very large and take a long time to initialize.
Is there a better way to accomplishing this other then connecting directly to the subscriber and running the script or by reinitializing the publication? Thanks for your help!
-mike
By default, full-text indexes are not replicated. You can enable it when you setup a Publication through Publication Wizard UI in the "Articles" page; set the article property to "true" for "Copy full text indexes".
If you setup your publication through stored procedure, make sure when you call sp_addarticle, @.schema_option includes 0x1000000.
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/0483a157-e403-4fdb-b943-23c1b487bef0.htm
Regards,
Gary
|||Gary,
I do have that schema option enabled in my publication, but it only seems to replicate full text indexes on first initialization of that publication, not if you add a full text index and catalog after the publication is up and running.
-mike
|||
Hi, Mike,
The behavior you're observing is by design. Schema change after initial sync has its own rule, and adding an index is considered a schema change to the publication, and it will not be replicated per DDL replication rule, however, you can explicitly add script to be run at subscriber to create the index (for example, use sp_addscriptexec).
Excerpt from SQL 2005 Books Online:
Making Schema Changes on Publication Databases:
Explicitly adding, dropping, or altering indexes is not supported. Indexes created implicitly for constraints (such as a primary key constraint) are supported.
http://msdn2.microsoft.com/en-us/library/ms151870.aspx
Thanks,
Zhiqiang Feng
|||
Mike,
The error you are getting from the distribution agent is indeed caused by the "CREATE FULLTEXT CATALOG" statement.
sp_addscriptexec would have been the best approach for what you want to achieve, however as it stated in the error message, "CREATE FULLTEXT CATALAG" cannot run within a transaction. In this case, your script is applied by distribution agent, and there is always a transaction created by the agent for the purpose of rolling back in case of an error is encountered (and this is by design).
So unfortunately, the sp_addscriptexec would not work for you in this case. The only work around I can think of are the ones you already know: apply scripts directly or reinitialize the publication.
Regards,
Gary
|||Odd. I just created a script to create a full-text catalog and create a full-text index on a table and applied it to a merge publication using sp_addscriptexec and it worked fine. Any reason why this should work on a merge publication but not a transactional?
Thanks for the help guys.
|||
Cut the long story short.
For transactional replication, ACID properties are preserved and transactions are taken place in the same order in publisher tables and subscriber tables. Since it's important all changes are executed sucessfully on subscriber, it needs to be wrap in a transaction, so roll back is possilbe in case of unexpected failure.
For merge replication, since conflicts may occur, and it can be detected and resolved (manually or by preset conflict resolver). There is no need to roll back all the changes in the committed batch of commands, only the failed ones are marked for conflict resolution by user. Therefore it's okay not to wrap it within a transaction.
Regards,
Gary
|||I have a similar question. I have a one-way transactional replication from A to B. I have replicated the initial full text index from A to B. But A will be contantly updated with new data, and its full text index will be incrementally updated. I would like to have only the updates to the full text index replicated to B as they occur or on a schedule.
Is there a way to do this? Thanks
|||
I don't think the full text index updates will be replicated. The full text engine for SQL Server (MSFTESQL) is responsible for updating and building the full text catalog on each server. So if you insert couple new records at the publisher, those new records got replicated to the subscriber, then the full text engine on the subscriber will take care of updating the full-text database on subscriber database. Replication shouldn't give you additional work load because of the full-text index on the table.
Regards,
Gary
|||Gary,
Thanks for the reply. We want to avoid running the full text index update on the subscriber because the subscriber needs to respond to the web server. When we run the full text index updating on the subscriber, the server becomes very busy for over several hours and response to the web server becomes very slow.
We got the following suggestion from a different forum:
Use "Change Tracking" and "Update Index in Background" on the Push Subscribers
Use change tracking, once the initial population is complete it is much faster than incremental populations.
To replicate the index commands use the post snapshot command and include commands to run a full-population and then enable change tracking.
Will this work?
Paul
|||
Paul,
I think this is more of a full-text index question than replication question, but here is my two cents :-)
The full text index should use the most resources (time-wise) on your subscriber when the initial snapshot is applied, at this time, the full-text index engine is doing a full population of the initial dataset. Depending on the size of the initial dataset, it is not uncommon to see a full population takes several hours. But after the initial population, all the subsequent updates to your subscriber should be a reasonable light weight process to your full-text index engine (this is my personal opinion, don't quote me on that). Having say that, it really depend on what kind of data you have and how much data you are replicating to your subscribers.
"Use change tracking, once the initial population is complete it is much faster than incremental populations.
To replicate the index commands use the post snapshot command and include commands to run a full-population and then enable change tracking."
I think the suggestion would save you time when you apply the snapshot, because the distribution agent (which responsible for replicating data from publisher to subscriber) is not running at the same time as the full-text index engine when it's trying to populate the full-text index catalog as data was pouring in. But after the initial snapshot, all the subsequent index updates are still done by the full-text index engine on the subscriber.
So, back to your question, I "think" it'll work if you are using snapshot replication where you are always apply a new data snapshot to subscriber.
As for transactional replication, it would save you time when the initial snapshot is applied, and after that, the distribution agent will replicate the changes to subscriber and you really just want the full-text index engine to do incremental update on subscriber tables instead of a full population.
Hope that helps,
GaryC