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.

InconsistentKeys error being returned where DuplicateKeys is expected

See original GitHub issue

Creating this issue as requested in forum thread: https://discuss.daml.com/t/2481/

When repeatedly exercising a choice with the below logic, an InconsistentKeys error is returned by the ledger API, whereas it seems like the correct error would be DuplicateKeys.

Please note, repeated commands are sent with a delay to ensure there is no race. There are no concurrent transactions when this error is produced.

template Vendor
 with
   networkOwner: Party
   vendor: Party
   vendorId: Text
 where
   signatory networkOwner
   observer vendor

   key (networkOwner, vendorId): (Party, Text)
   maintainer key._1

   controller networkOwner can
     nonconsuming RegisterProduct: (Optional (ContractId Client), ContractId Product)
       with productInfo: ProductInformation; clientInfo: ClientInformation
       do
         clientCid <- lookupByKey @Client (clientKey)
         productCid <- lookupByKey @Product (productKey)

         newClient <- case clientCid of
            None -> do
                exerciseByKey @ClientList (clientListKey) AddClients with newClients = [clientInfo]
                case clientInfo.clientType of
                  FIRSTTYPE -> do 
                      newClient <- create Client with ...
                      return (Some newClient)
                  SECONDTYPE -> do return None
            Some clientCid -> do
                client <- fetch clientCid
                archive clientCid
                newClient <- create client with products = dedup (productInfo :: client.products) 
                return (Some newClient)
 
        product <- create Product with ...

        return (newClient, product)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
LAshenhurstcommented, Jun 14, 2021

Hi @cocreature apologies for the delayed reply. Yes, this seems resolved now. Thanks for following up!

0reactions
cocreaturecommented, Jun 8, 2021

Hi @LAshenhurst, have you been able to verify that this fixes your issue? On our side, we are unable to reproduce this issue with the fix in 1.13.0 or anything later.

Read more comments on GitHub >

github_iconTop Results From Across the Web

check-db returns duplicate key error on a unique index ...
Tried to locate the duplicate rows, however select query returns only 1 value. I have absolutely no idea now. What could be the...
Read more >
I'm seeing a duplicate keys error, what does that mean?
Sometimes, the error message will be shown as “A duplicate key was detected (). Please check your data provider configuration and try again.“....
Read more >
3 common foreign key mistakes (and how to avoid them)
Dangling foreign keys 3. Not creating foreign key indexes Bonus: Not using foreign keys Key takeaway: think before you CREATE TABLE.
Read more >
Db2 11 - Messages - DSNU340I - IBM
Use the REPAIR utility with LOCATE RID and DUMP statements to view the records with duplicate keys. The inconsistent index can cause SQLSELECT...
Read more >
Find and fix inconsistent B-tree indexes - PostgreSQL
Inconsistencies in database indexes can occur for a variety of reasons ... The statement returns the duplicate keys and a count of the...
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