How to realize deadlock in HANA

In this blog, we will have a small test about how to realize a deadlock in HANA.

Multi version concurrency control ensures consistent read operations. However, it does not prevent concurrent write operations on the same data and the associated inconsistencies (dirty write, lost updates). To prevent concurrent write operations on the same data record, the SAP HANA database uses exclusive write locks at row level. For each write access, a row-level write lock is obtained. Concurrent transactions which need to write the same record have to wait until the lock is released. Write locks are implicitly requested before an update or delete operation is executed.

A deadlock situation occurs, if two transactions both need to update two records R1 and R2, and one transaction is given the lock for R1 and the other one the lock for R2. The transaction manager detects the deadlock and aborts one of the transactions.

In the following test, I created two stored procedures P1 and P2. Both P1 and P2 need to update all entries in one table(10000 entries). P1 updates the table from the last entry to the first entry. While P2 updates the table from the first entry to the last entry. Both P1 and P2 will execute at the same time. And one of the procedure will get aborted with deadlock error.

 

 

Execute the Transaction P1

Then execute the Transaction P2 in another SQL console session immediately

Here the transaction P2 aborted with the error deadlock detected. Could not execute ‘CALL “TRANSACTION_P2”’ in 29.059 seconds . SAP DBTech JDBC: [133]: transaction rolled back by detected deadlock: “TRANSACTION_P2”: line 8 col 3 (at pos 189): [133] (range 3): transaction rolled back by detected deadlock: TrexUpdate failed on table ‘TEST1’ with error: transaction rolled back by detected deadlock: Deadlock detected while executing transaction (TRANSACTION_ID=21, UPDATE_TRANSACTION_ID=60740880), rc=4616

Deadlocks are situations where two or more transactions lock each other cross-wise so that no transaction will ever be able to proceed. Usually deadlocks are caused by the application design.

If SAP HANA recognizes a deadlock based on a transactional lock, one of the transaction will be terminated and the following error is issued: SQL error 133: transaction rolled back by detected deadlock

This behavior is different from other databases like Oracle where a deadlock will only terminate the current DML operation and not the whole transaction.

For more details, please refer to SAP note 1999998 – FAQ: SAP HANA Lock Analysis. http://bit.ly/2FePGxB #SAP #SAPCloud #AI

Apache Camel URI Completion in VS Code XML Editor and Eclipse Che

ICYMI: Apache Camel empowers you to define routing and mediation rules in a variety of domain-specific languages, including a Java-based Fluent API, Spring or BlueprintXML Configuration files, and a Scala DSL. It also uses URIs to work directly with any kind of Transport or messaging model such as HTTP, ActiveMQ, JMS, JBI, SCA, MINA or CXF, as well as pluggable Components and Data Format options. Apache Camel is a small library with minimal dependencies for easy embedding in any Java application.

A few weeks ago, I blogged about Apache Camel URI completion in the Eclipse XML Editor. This week I’m happy to announce that the same feature is available for 2 others IDEs: VS Code and Eclipse Che. https://goo.gl/9T7R3W #DataIntegration #ML

Capitalizing Off of Blockchain to Transform the Gig Economy

The gig economy is growing at a record pace. BLS data shows that roughly 34% of the workforce is composed of independent contractors. The number of freelancers is expected to rise at least 60% between 2017 and 2020. Both freelancers and the brands depending on them are grappling with a variety of challenges. Blockchain is key to addressing some of the most pressing problems.

How can blockchain benefit the gig economy?

Blockchain was originally developed to process and authenticate digital currency transactions. It was the official ledger for bitcoin.

The same technology can be repurposed for managing online contracts. Here are some of the key advantages.

Verifying freelancer work

Brands must work with reputable freelancers to meet their business goals. Unfortunately, it can be difficult to verify the authenticity of their work and establish their reputation.

Blockchain provides a cutting-edge solution for both parties. Blockchain ledger systems enable freelancers to create unique online identities that nobody else has the cryptographic keys to access. This allows them to verify their identity and ownership of their content to protect against impersonators.

Protection and transfer of intellectual property rights

The Internet has complicated the enforcement of intellectual property rights. In the United States, United Kingdom and many other developed countries, originators of written content aren’t required to register their IP with a government registry. They secure their copyrights as soon as their content is published.

However, verifying the original creator of the content over the Internet is very difficult. Timestamps can’t be easily accessed, unless the content has been saved by a trusted Internet archiver.

Blockchain offers an ideal solution. Content developers can register their work with a blockchain registry such as Bernstein, so there will be no dispute over ownership of the IP rights.

Cost-effective alternatives to escrow

Traditional gig economy platforms charge fees ranging from 10 to 15% of every contract. These fees have raised the cost structure of the gig economy.

Blockchain provides a much more cost-effective alternative. Freelancers and clients can enter into contracts with clearly defined payment terms. The blockchain can serve as an intermediary between the two and ensure transactions are processed as soon as the work is completed to the client’s satisfaction. Transaction fees via the blockchain may be as low as 0.5%. This enables freelancers to lower their rates and split the savings between them and their clients.

New work agreement platforms like Grain.io are being built on blockchain to process work agreement securely and at a much lower cost. Former Senior Director at Microsoft and Grain CEO Onno Hektor explains, “By moving work agreements to a blockchain solution, we can substantially lower overhead costs and make both sides of the transaction better off. Transferring money to workers becomes cheap by eliminating unfavorable exchange rates or high transaction costs.”

Toolkit for blockchain developers offering gig economy solutions

Blockchain developers can take advantage of a number of development tools to create cutting-edge solutions for the gig economy. A few years ago, their only option was to use bitcoin to create daaps. Since bitcoin is intended for peer to peer transactions, it isn’t adequate solution for daap development.

Here are some alternative watching development tools.

Mist

Mist is a blockchain solution that blockchain developers use to handle a wide range of applications. It is commonly used for awarding and regulating smart contracts, which makes it an ideal solution for gig economy platforms.

Etherium blockchain developers that haven’t used Mist before can find it on Github. This environment has a wide array of scripts, modules and other resources they need to begin coding.

BaaS

BaaS is an Etherium blockchain developer platform created by Microsoft Azure. All content hosted and shared through BaaS is encrypted.

BaaS has a permanent digital transaction trail. If developers need to correct any transactions, a rectifying transaction must be completed. Transactions cannot be modified or deleted.

One of the key benefits of the BaaS environment is its machine learning capabilities. The environment is interconnected with other developers, so it becomes more streamlined as the transaction ledger scales. Replication of transactions also continually enhances the authenticity of the BaaS environment.

Blockchain Testnet

Blockchain testnets simulate the environment of the actual blockchain, while keeping it sanitized from test transactions. There are a number of different Blockchain testnets, but Blockcypher is one of the most popular.

With Blockcypher, blockchain developers begin the simulation the blockchain environment by creating a push transaction. This is accomplished by selecting the transaction type and entering the hexadecimal code associated with it. After the simulated transaction is created, can be publicly broadcast to the blockchain testing environment.

The process can be reversed to decode blockchain transactions as well. http://bit.ly/2Fc2xoc #SAP #SAPCloud #AI

What We Need to Be Machine Readable at API Run Time

I had breakfast with Mike Amundsen (@mamund) and Matt McLarty (@MattMcLartyBC) of the CA API Academy team this morning in midtown. As we were sharing stories of what each other was working on, the topic of what is needed to execute an API call came up. Not the time consuming find an API, sign up for an account, figure out the terms of service and pricing version, but all of this condensed into something that can happen in a split second within applications and systems.

How do we distill down the essential ingredients of API consumption into a single, machine-readable unit that can be automated into what Mike Amundsen calls, “find and bind.” This is something I’ve been thinking a lot about lately as I work on my API discovery research, and there are a handful of elements that need to be present: https://goo.gl/zhY7FZ #DataIntegration #ML