Skip to content

Add TransactWriteItems - #174

Closed
ryanblock wants to merge 34 commits into
mainfrom
libertymutual-add_transactWriteItems
Closed

ryanblock wants to merge 34 commits into
mainfrom
libertymutual-add_transactWriteItems

Conversation

@ryanblock

Copy link
Copy Markdown
Member

Thank you for helping out! ✨

We really appreciate your commitment to improving Dynalite

To maintain a high standard of quality in our releases, before merging every pull request we ask that you've completed the following:

  • Forked the repo and created your branch from main
  • Made sure tests pass (run npm it from the repo root)
  • Expanded test coverage related to your changes:
    • Added and/or updated unit tests (if appropriate)
    • Added and/or updated integration tests (if appropriate)
  • Updated relevant documentation
  • Summarized your changes in changelog.md
  • Linked to any related issues, PRs, etc. below that may relate to, consume, or necessitate these changes

Please also be sure to completed the CLA (if you haven't already).

Learn more about contributing to Architect here.

Thanks again!

tume and others added 30 commits April 14, 2020 14:21
…ransactWriteItems

� Conflicts:
�	package-lock.json
Testing locally, all these took <1s to run
@CLAassistant

CLAassistant commented Sep 3, 2023 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 4 committers have signed the CLA.

✅ ryanblock
❌ jpeterschmidt
❌ tume
❌ n0286293


n0286293 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@dimaqq dimaqq left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor comments mostly

Comment thread test/helpers.js
request(opts(target, data), function (err, res) {
if (err) return done(err)
if (typeof res.body !== 'object') {
return done(new Error('Not JSON: ' + res.body))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

super-minor: I'd use a template literal instead

children: 'AttrStruct<ValueStruct>',
},
ExpressionAttributeNames: {
type: 'Map<java.lang.String>',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is a Java reference an artefact of the validation library?
It's odd to see it here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

DynamoDB's java leaks through in its validation, I think this is expected.

children: 'AttrStruct<ValueStruct>',
},
ExpressionAttributeNames: {
type: 'Map<java.lang.String>',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ditto.

Comment on lines +150 to +151
msg = validations.validateAttributeValue(request.Put.Item[key])
if (msg) return msg

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

subject to style debate:

Suggested change
msg = validations.validateAttributeValue(request.Put.Item[key])
if (msg) return msg
if (msg = validations.validateAttributeValue(request.Put.Item[key]))
return msg

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Those inline assignments within conditionals are clever but are also imo a bit unusual, and certainly more difficult to debug later. They also blow up eslint:recommended on no-cond-assign.

Comment on lines +145 to +147
var i, request, msg, key
for (i = 0; i < data.TransactItems.length; i++) {
request = data.TransactItems[i]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

subject to style debate, or maybe performance?

I'd rather move the variable declaration into the loop:

Suggested change
var i, request, msg, key
for (i = 0; i < data.TransactItems.length; i++) {
request = data.TransactItems[i]
for (const request of data.TransactItems) {
let msg;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agree

Comment thread test/transactWriteItem.js
Comment on lines +144 to +147
var requests = [], i
for (i = 0; i < 26; i++) {
requests.push(i % 2 ? { Delete: { Key: { a: { S: String(i) } } } } : { Put: { Item: { a: { S: String(i) } } } })
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe something like this:

Suggested change
var requests = [], i
for (i = 0; i < 26; i++) {
requests.push(i % 2 ? { Delete: { Key: { a: { S: String(i) } } } } : { Put: { Item: { a: { S: String(i) } } } })
}
const requests = new Array(26).fill(null).map(() => ({...}))

Comment thread test/transactWriteItem.js
assertTransactionCanceled = helpers.assertTransactionCanceled.bind(null, target),
assertNotFound = helpers.assertNotFound.bind(null, target)

describe('transactWriteItem', function () {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This file really needs a review, specifically that correct exceptions are raised in corner cases, in a way that dynalite behaviour matches AWS dynamodb.

I'm flagging it here because GitHub hides this diff by default calling it "too large".

async.each(operationsbyTable, function ([ tableName, ops ], callback) {
var itemDb = store.getItemDb(tableName)

store.getTable(tableName, function (err, table) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think we need to dig into this @jpeterschmidt – do you recall what was intended here? It looks like the callback can be called in a variety of different ways and may be called multiple times.

For example, the callback on L29 may be called many times across the indexUpdates array, and will not cancel operations. And then itemDb.batch on L32 may also be calling the same callback at the same time. Moreover, if there's an error it will call said callback twice, with the results in the error position of the errback.

children: 'AttrStruct<ValueStruct>',
},
ExpressionAttributeNames: {
type: 'Map<java.lang.String>',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

DynamoDB's java leaks through in its validation, I think this is expected.

Comment on lines +145 to +147
var i, request, msg, key
for (i = 0; i < data.TransactItems.length; i++) {
request = data.TransactItems[i]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agree

Comment on lines +150 to +151
msg = validations.validateAttributeValue(request.Put.Item[key])
if (msg) return msg

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Those inline assignments within conditionals are clever but are also imo a bit unusual, and certainly more difficult to debug later. They also blow up eslint:recommended on no-cond-assign.

@jpshack-at-palomar

Copy link
Copy Markdown

@ryanblock What is the must fix here to get this merged? If we are just a few hours of work away I'd be happy pitch in.

@ryanblock

Copy link
Copy Markdown
Member Author

@jpshack-at-palomar please read my comments above; this PR has fundamental issues with how continuation passing works, and it cannot be merged in its current state. As a programmer, I do not feel confident making claims that anything is a few hours of work away, let alone something as complex as this.

I was hoping the author would help us get this PR into shape, but since we haven't heard back my plan has been to hopefully snag a few bits here and there, but probably rewrite. As ever, I'd be happy for someone in the community to start work on a fresh PR.

@zirkelc

zirkelc commented Apr 22, 2025

Copy link
Copy Markdown

Hey @ryanblock I would be willing to work on this if you could be a bit more specific which issues need to be solved. Like what do you mean with this PR has fundamental issues with how continuation passing works?

@ryanblock

Copy link
Copy Markdown
Member Author

Well, it's been >1.5y since I looked at this, but I recall seeing a bunch of callbacky code in here that was incorrectly implemented (i.e. a given callbacks can be called multiple times, etc.). I think anyone who wants to work on this feature should start anew. Given the fact that the original author has not made movement to improve this PR, I think it's probably the best idea to close it and allow the next person to start a fresh one.

@ryanblock ryanblock closed this Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

7 participants