question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When errors occur in a batch, only last one is visible, masking the original cause of the failure

See original GitHub issue

When batch execution fails, we usually want to see the first failed statement. The subsequent failures can be caused by the first one, but in the exception thrown the (irrelevant) information of only the last failure is available.

Note the following line:

https://github.com/microsoft/mssql-jdbc/blob/05ef7c07d184e9f8b659c351f68599b1a94132e3/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java#L1879

Our scenario:

  1. We are using SET IDENTITY_INSERT .. ON in one batch with INSERTs to fill a table with IDENTITY fields.
  2. Insertions fails somewhere in the middle of the batch because of constraint violation.
  3. But what we see in exception is “Cannot insert explicit value for identity column”, which has nothing to do with the real cause of the error.

Can we change the logic of error handling so that the first failure in the batch is saved and is used when building BatchUpdateException?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Jeffery-Wastycommented, Sep 29, 2022

@inponomarev

I initially thought to move this to our backlog, and consider it again in the future, but on further thought, this doesn’t seem like work that will enhance the driver. Users are able to see all batch error messages with the method described above and thus we feel no change is required. Adding a ‘total number of errors’ like you describe wouldn’t be helpful either. The user still needs to process the batch response, so they will be seeing the total regardless of whether is presented to them outright, or through batch processing. Finally, again, while changing to show a first error message may help workflows that use the first response, it will harm workflows that take advantage of last error message, having zero, or even a negative effect, in the long run.

Thanks for the submission, and discussion, but we will now close this issue.

1reaction
Jeffery-Wastycommented, Sep 22, 2022

Hi @inponomarev,

We’ll look into this. You make a good argument around how returning the last known error can mask the actual problem, but we’ll have to take a look into the impact this has on other workflows. Thanks for the PR as well, we’ll take a look into that too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command Line Execution - DataVeil Data Masking User Guide
This command is on one logical line although it appears on multiple lines below due to line wrap. ./dataveil --nosplash --nogui -J-Dnetbeans.logger.
Read more >
How Batch process works during the Error.
1. Assume a batch process has 3 iterations processing 200 records each. The batch process is doing an insert and I am using...
Read more >
Data Masker Command Line Arguments and Batch Mode
The script output below shows such an operation. The 301 exit code means the masking set execution failed with an error.
Read more >
Db2 Administration Tool 12.1 - CM batch parameter definitions
Specifies whether and how to generate a base version. This parameter enables you to start Change Management (CM) batch interface only to generate...
Read more >
Find errors with transactional replication - SQL Server
Transactions occur on objects that are replicated, and are marked "for replication" in the transaction log. · The Log Reader Agent scans through ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found