Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OGR provider] Check return value of commitTransaction() in addFeatures() and deleteFeatures(); call rollback when an error was detected before #39456

Merged

Conversation

rouault
Copy link
Contributor

@rouault rouault commented Oct 18, 2020

Calling rollback() didn't seem to be strictly needed, but makes more sense than calling commit() when we know that something wrong happened.

@nyalldawson
Copy link
Collaborator

Wouldn't this mean that an error encountered while adding one feature from a batch would mean that NO features are written?

…es() and deleteFeatures(); call rollback when an error was detected before
@rouault rouault force-pushed the ogr_check_retval_commit_transaction branch from 95562e1 to 2906ee4 Compare October 18, 2020 23:47
@rouault
Copy link
Contributor Author

rouault commented Oct 18, 2020

Wouldn't this mean that an error encountered while adding one feature from a batch would mean that NO features are written?

Yes, and that was already the case since this is done in a transaction (for drivers that support transactions). My understanding is that the PostgreSQL provider does the same.

@github-actions github-actions bot added this to the 3.16.0 milestone Oct 18, 2020
@nyalldawson
Copy link
Collaborator

Yes, and that was already the case since this is done in a transaction (for drivers that support transactions).

Are you referring to a "qgis" transaction or a transaction on the underlying backend?

My understanding is that the PostgreSQL provider does the same.

@elpaso I recall that you've investigated this same question recently -- what was your findings regarding this? Do we add/update/delete what we can and then return false, or abort adding/updating/deleting all affected features?

@rouault
Copy link
Contributor Author

rouault commented Oct 18, 2020

Are you referring to a "qgis" transaction or a transaction on the underlying backend?

A OGR underlying backend transaction

Digging into history points to #4257 where the motivation was speed

@m-kuhn
Copy link
Member

m-kuhn commented Oct 19, 2020

For reference, we plan to come up with a QEP regarding transaction/data consistency soonish.

@nyalldawson
Copy link
Collaborator

@m-kuhn @elpaso should we merge?

@m-kuhn
Copy link
Member

m-kuhn commented Oct 20, 2020

+1
How risky do you see this, i.e. would it be worth to wait for after release (in 3 days)?

@elpaso
Copy link
Contributor

elpaso commented Oct 21, 2020

Yes, and that was already the case since this is done in a transaction (for drivers that support transactions).

Are you referring to a "qgis" transaction or a transaction on the underlying backend?

My understanding is that the PostgreSQL provider does the same.

@elpaso I recall that you've investigated this same question recently -- what was your findings regarding this? Do we add/update/delete what we can and then return false, or abort adding/updating/deleting all affected features?

@nyalldawson I think you mean #39178

The issue there was that while you are inside a QGIS transaction (group) and start a getFeatures loop, if you change attributes or geometry a getFeature is called, a new iterator is created and OGR provider did call a GDAL GetFeature function which reset the internal GDAL feature counter to 1, so you had and endless loop. Also, it wasn't possible to use a different connection than the one where the transaction was initiated: pretty bad bug, but I don't see it related to this PR.

So, I'm +1 to merge.

@nyalldawson nyalldawson merged commit c857a33 into qgis:master Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants