-
Notifications
You must be signed in to change notification settings - Fork 559
fix dynamodb lock table creation #1992
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
fix dynamodb lock table creation #1992
Conversation
per the AWS docs[^1], DescribeTable throws ResourceNotFoundException, not TableNotFoundException. checking for the wrong type caused createTableIfNotExists to always fail, although nothing was checking for the error it returned. [^1]: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTable.html
WalkthroughThe changes update error handling in DynamoDB table existence and creation logic. Error detection now uses Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant DynamoDbLock
participant DynamoDB
Caller->>DynamoDbLock: Lock / Unlock / GetLock
DynamoDbLock->>DynamoDbLock: createTableIfNotExists()
DynamoDbLock->>DynamoDB: DescribeTable
alt Table not found
DynamoDbLock->>DynamoDB: CreateTable
DynamoDbLock->>DynamoDB: WaitUntilTableCreated
DynamoDbLock-->>Caller: Return error if creation fails
else Table exists
DynamoDbLock->>DynamoDB: Proceed with lock operation
end
DynamoDbLock-->>Caller: Return result or error
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🔇 Additional comments (11)
✨ Finishing Touches
🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
Fixed critical DynamoDB lock table creation in backendless mode by correctly handling AWS API errors and improving error propagation.
- Corrected error type check in
libs/locking/aws/dynamo_locking.go
fromTableNotFoundException
toResourceNotFoundException
to match AWS API behavior - Removed unsafe
os.Exit(1)
call from error handling path indynamo_locking.go
, properly bubbling up errors instead - Added proper table creation checks in Lock(), Unlock(), and GetLock() methods
- Added TableStatus to mock implementation in
dynamo_locking_test.go
for more accurate testing
2 files reviewed, 1 comment
Edit PR Review Bot Settings | Greptile
Thank you! @nigelzor! |
When trying to set up backendless Digger in a new AWS account I was blocked by errors in locking:
Per the AWS docs1,
DescribeTable
throwsResourceNotFoundException
, notTableNotFoundException
. Checking for the wrong type causedcreateTableIfNotExists
to always fail, though nothing was checking for the error it returned.All callers now bubble up the error returned by
createTableIfNotExists
and there's no longer a hiddenos.Exit(1)
error handler.With these changes I was able to run Digger successfully.
Summary by CodeRabbit
Bug Fixes
Tests
Footnotes
https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTable.html ↩