Skip to content

db: adds mid txn errors#438

Merged
sanderpick merged 1 commit intomasterfrom
sander/txn-errors
Sep 17, 2020
Merged

db: adds mid txn errors#438
sanderpick merged 1 commit intomasterfrom
sander/txn-errors

Conversation

@sanderpick
Copy link
Copy Markdown
Contributor

Right now, when you call methods on a transaction like Save, Delete, etc., an error will end the txn, which is cumbersome in cases where you want to handle that error and retry (w/o recreating the whole transaction).

Easiest solution: Add an error to all the reply objects (CreateReply, etc.)

@sanderpick sanderpick self-assigned this Sep 17, 2020
Signed-off-by: Sander Pick <sanderpick@gmail.com>
}

func (n *net) pullThread(ctx context.Context, id thread.ID) error {
log.Debugf("pulling thread %s...", id)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates too much output, to the point where you can't easily make sense of the logs.


// RefreshCollection updates the transaction's collection reference from the master db map,
// which may have received updates while the transaction is open.
func (t *Txn) RefreshCollection() error {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to pick up collection changes during a transaction.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems odd given we're using a transaction here :P But I guess this actually makes sense, given our transactions provide atomicity but not isolation guarantees!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's kinda weird :/ Though, the transaction changes themselves and the underlying state are still "locked" during the transaction, as you stated differently above. Really I just needed the ability to update the collection after catching a schema mismatch error during the txn.

@sanderpick
Copy link
Copy Markdown
Contributor Author

Oh, note that the new errors are only used during a transaction... normal non-txn calls return the error as before.

Copy link
Copy Markdown
Member

@carsonfarmer carsonfarmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great @sanderpick, exactly what we need for remote offline-frist updates tbh.

@sanderpick
Copy link
Copy Markdown
Contributor Author

Thanks for the late night look!

@sanderpick sanderpick merged commit f4a9ab7 into master Sep 17, 2020
@sanderpick sanderpick deleted the sander/txn-errors branch September 17, 2020 05:34
@bitcard
Copy link
Copy Markdown

bitcard commented Mar 1, 2021

mark

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.

3 participants