dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.25k stars 5.89k forks source link

docs of using transactions with sqlbulkcopy is internally contradictory #19953

Open ShahryarSaljoughi opened 4 years ago

ShahryarSaljoughi commented 4 years ago

Issue description This document claims that Performing a Dedicated Bulk Copy Operation in a Transaction is similar to Performing a Non-transacted Bulk Copy Operation with one exception!

The problem is that they are no difference between them in terms of how they handle a failure.
According to docs, if no transaction is used:

All batches copied up to the point of the error are committed; the batch containing the duplicate key is rolled back, and the bulk copy operation is halted before processing any other batches. (quoted from the Performing a Non-transacted Bulk Copy Operation section)

and again according to docs, if UseInternalTransaction flag is used in order to perform a transacted bulk copy, the same behavior is happening:

l batches copied up to the point of the error are committed; the batch containing the duplicate key is rolled back, and the bulk copy operation is halted before processing any other batches. (quoted from the Performing a Dedicated Bulk Copy Operation in a Transaction section)

How are they different?

On the other hand the first paragraph of document says that:

The bulk copy operation occurs in a non-transacted way, with no opportunity for rolling it back.

and then suggests that if you need to rollback part of it, you need to use a transaction. In contrast of this, later in this article, it is stated that batches are executed in their own transaction, when we are "Performing a Non-transacted Bulk Copy Operation",and if a problem occurs the batch containing the problematic row will rollback!

Target framework

Check the .NET target framework(s) being used, and include the version number(s).

BillWagner commented 4 years ago

Ping @JeremyLikness for visibility.

JeremyLikness commented 3 years ago

@BillWagner I'm fairly confident this is owned by the SQLClient team. Do you know someone there we can tag?

JeremyLikness commented 3 years ago

@mairaw @guardrex pinging you as you were listed on the document. Do we know who the owner is we can assign this to?

guardrex commented 3 years ago

Before the doc came in from CAPS, it had @ JennieHubbard in the metadata as author. I defer to others beyond that tho. It's going on perhaps four years since I was working in this neck of the woods.

https://github.com/dotnet/docs/blame/319b525bc99bbe4b71024144188a4222265342c7/docs/framework/data/adonet/sql/transaction-and-bulk-copy-operations.md

mairaw commented 3 years ago

@stevestein is the current owner of this. You can always select view source on the doc and look at the metadata for author/ms.author to find the latest.

guardrex commented 3 years ago

I thought they eliminated it on this repo at some point. The current metadata is ...

---
title: "Transaction and Bulk Copy Operations"
ms.date: "03/30/2017"
dev_langs: 
  - "csharp"
  - "vb"
ms.assetid: f6f0cbc9-f7bf-4d6e-875f-ad1ba0b4aa62
---
mairaw commented 3 years ago

We eliminated on individual topics because they're set as global metadata on docfx.json. So the published article's source would have the source of truth for the latest.

image

adegeo commented 3 years ago

Sending email to @stevestein