Maybe a SQL Replication bug.....

73 views
Skip to first unread message

Yanjie Zhou

unread,
Mar 23, 2015, 4:43:08 PM3/23/15
to rav...@googlegroups.com
Hi,

I found a problem when I use the for loop in SQL replication script, for example:

The document structure is like this, 
Order
{
         TotalCost : "6"
        OrderLine :
               [
                        {
                              Quality : "1"
                              Cost : "2"
                        },
                        {
                              Quality : "2"
                              Cost : "4"
                        },
               ]
}


If I have the OrderLine table on SQL side and want to fill that table with the OrderLine in the document, I need to write a for loop script to complete that:

for(var i = 0; i < this.OrderLine.length; i++)
    {
           var OrderLine = this.OrderLine[i];

           var OrderLineData = 
                        {
                                OrderId : documentId,
                                Quality : OrderLine.Quality,
                                Cost : OrderLine.Cost
                        }
          replicateToOrderLine(OrderLineData);
    }

That works fine until I do one kind of changes on the raven document, when I remove all the OrderLine parameters in OrderLine in one time and make it to OrderLine : [], the SQL side will not update the changes of the document in OrderLine table.

On other situation when I insert more parts or delete some parts in the OrderLine, it works fine.

So could you help me to resolve this problem?



Thank you

Yanjie Zhou

Tal Weiss

unread,
Mar 24, 2015, 11:41:53 AM3/24/15
to rav...@googlegroups.com
Hi,
This behavior should not happen.
Can you please go to your database Setting and choose the SQL Replication tab.
under the tools selection button choose Simulation and choose one of your Order documents that contains 0 order lines and press the simulation button.
Now what are the SQL commands you are seen?
can you please print the screen and share it?


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Hibernating Rhinos Ltd  cid:image001.png@01CF95E2.8ED1B7D0

Tal Weiss l Core Team Developer Mobile:+972-54-802-4849

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

RavenDB paving the way to "Data Made Simplehttp://ravendb.net/ 

Yanjie Zhou

unread,
Mar 24, 2015, 12:02:34 PM3/24/15
to rav...@googlegroups.com
Hi, 

I'm using Raven 2956, I think the simulation function is 3.0?


Thank you

Yanjie Zhou

Oren Eini (Ayende Rahien)

unread,
Mar 24, 2015, 12:04:00 PM3/24/15
to ravendb
Yes, can you try with 3.0?

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Yanjie Zhou

unread,
Mar 24, 2015, 12:56:03 PM3/24/15
to rav...@googlegroups.com

Our environments are all using 2956 and if that is a problem in the sql replication of version 2956, that is a big impact.


Thank you

Yanjie Zhou

Yanjie Zhou

unread,
Mar 24, 2015, 1:51:35 PM3/24/15
to rav...@googlegroups.com
So could you help to deal with this problem?


On Tuesday, March 24, 2015 at 12:04:00 PM UTC-4, Oren Eini wrote:

Kijana Woodard

unread,
Mar 24, 2015, 1:57:00 PM3/24/15
to rav...@googlegroups.com
"So could you help to deal with this problem?"

Who are you talking to?

This is the community forum, not the urgent support center.

Yanjie Zhou

unread,
Mar 24, 2015, 2:26:38 PM3/24/15
to rav...@googlegroups.com
OK I'm sorry, so do you have any suggestions about it besides using the raven version 3.0?

Thank you

James Tan

unread,
Mar 24, 2015, 2:45:27 PM3/24/15
to rav...@googlegroups.com
Oren,

If this is confirmed as a bug in 2.5, shall I assume it will be fixed in 2.5?

Thanks

James

Oren Eini (Ayende Rahien)

unread,
Mar 24, 2015, 3:12:16 PM3/24/15
to ravendb
This it not confirmed for 2.5
We tested that it works for 3.0
In 2.5, it should also work as well:

Can you show the SQL Profiler output from 2.5?

James Tan

unread,
Mar 24, 2015, 3:19:31 PM3/24/15
to rav...@googlegroups.com
Thanks Oren, the code is there. More testing and SQL profiling will be done and will post results here.

James

Tal Weiss

unread,
Mar 25, 2015, 9:39:34 AM3/25/15
to rav...@googlegroups.com
I have tested the Sql replication on RavenDB-Build-2956, when clearing the order lines all the relevant sql lines are been deleted.
attached is a screenshot of an order document from the northwind sample data (order/830)
I have set up sql replication as shown in the documentation and made sure the data is been replicated correctly and then i have deleted the order lines from the order, the result is as expected.
The script (database is northwind go to task-> create sample data):
var orderData = {
			Id: documentId,
			OrderLinesCount: this.Lines.length,
			TotalCost: 0
		};

		for (var i = 0; i < this.Lines.length; i++) {
			var line = this.Lines[i];
			var lineCost = ((line.Quantity * line.PricePerUnit) * (1 - line.Discount));
			orderData.TotalCost += lineCost;

			replicateToOrderLines({
				OrderId: documentId,
				Qty: line.Quantity,
				Product: line.Product,
				Cost: lineCost
			});
		}
		
		replicateToOrders(orderData);
SqlReplicationWorkingFine.JPG

James Tan

unread,
Mar 26, 2015, 10:49:09 AM3/26/15
to rav...@googlegroups.com
Here is how to reproduce it and confirmed it as a bug

Use the example Tal gave, it is working fine. BUT
If we remove the last line replicateToOrders(orderData); the bug showed up.
Remove any lines if lines is not empty, works fine
Remove ALL lines, no deletion happened.

No idea why like this but it is reproduced couple times in different environments.

The reason we have such scripts because some ETL only needs sub collections.

Thanks

James

Oren Eini (Ayende Rahien)

unread,
Mar 26, 2015, 10:52:28 AM3/26/15
to ravendb
When you don't have _any_ calls to anything? 
Message has been deleted

James Tan

unread,
Mar 26, 2015, 11:04:04 AM3/26/15
to rav...@googlegroups.com
Yes, when removed all from sub collections (make it empty).

Thanks

James

Oren Eini (Ayende Rahien)

unread,
Mar 26, 2015, 11:39:14 AM3/26/15
to ravendb
We'll look at that on Sunday

Oren Eini (Ayende Rahien)

unread,
Mar 26, 2015, 11:40:58 AM3/26/15
to ravendb

Yanjie Zhou

unread,
Apr 3, 2015, 4:22:11 PM4/3/15
to rav...@googlegroups.com
Hi,

Do you have any news about it?

Thank you

Yanjie Zhou

t...@ayende.com

unread,
Apr 5, 2015, 7:21:49 AM4/5/15
to rav...@googlegroups.com
Yes, it is now fix, should be available in the next unstable release.

Yanjie Zhou

unread,
Apr 6, 2015, 4:58:31 PM4/6/15
to rav...@googlegroups.com
Thank you, I see the fix information on 3.0 version about this problem.

Do you have any plan about fix this problem on 2.5 version? As our environments are all still using 2.5 version now.


Thank you

Yanjie Zhou

Oren Eini (Ayende Rahien)

unread,
Apr 6, 2015, 5:29:03 PM4/6/15
to ravendb
In 2.5, you can just add a dummy table that would always be called.
A backport exists, but it will take a day or two to finish testing
Reply all
Reply to author
Forward
0 new messages