SlideShare a Scribd company logo
Detecting Problems in the Database
Access Code of Large Scale Systems
An industrial Experience Report
1
Mohamed Nasser, Parminder Flora
Tse-Hsun(Peter) Chen Ahmed E. HassanWeiyi Shang
Existing static analysis tools focus on
language-related problems
2
Coverity PMD Google error-prone
Facebook InferFindBugs
However, many problems are related to
how developers use different frameworks
Over 67% of Java developers use
Object-Relational Mapping
(Hibernate) to access databases
3
Existing static analysis tools provide
mostly rudimentary support for JDBC!
22%67%
Over 40% of Java web application
developers use Spring
4
Developers use Spring to manage database
transactions in web applications
None of the static analysis tools support
Spring!
There is a huge need for framework-
specific tools
5
Developers leverage MANY frameworks,
but existing tools only support detecting
language-related problems.
An example class with Java ORM code
6
@Entity
@Table(name = “user”)
@DynamicUpdate
public class User{
@Column(name=“id”)
private int id;
@Column(name=“name”)
String userName;
@OneToMany(fetch=FetchType.EAGER)
List<Team> teams;
public void setName(String n){
userName = n;
}
… other getter and setter methods
User.java
User class is
mapped to “user”
table in DB
id is mapped to the
column “id” in the
user table
A user can belong
to multiple teams
Eagerly retrieve
associated teams
when retrieving a
user object
Performance-
related configs
Accessing the database using ORM
7
User u = findUserByID(1);
ORM
database
select u from user
where u.id = 1;
u.setName(“Peter”);
update user set
name=“Peter”
where user.id = 1;
Objects SQLs
Transaction management using Spring
8
@Transaction(Propogation.REQUIRED)
getUser(){
…
updateUserGroup(u)
…
}
By using ORM and Spring, developers
can focus more on the business logic
and functionality
Create a DB
transaction
Entire business logic will
be executed with the
same DB transaction
Implementing DBChecker
9
Source
code
• DBChecker looks for both functional
and performance bug patterns
• DBChecker is integrated in industrial
practice
Overview of the presentation
10
Bug patterns Lessons learned when
adopting the tool in practice
Overview of the presentation
11
Bug patterns Lessons learned when
adopting the tool in practice
More patterns and learned
lessons in the paper
ORM excessive data bug pattern
Class User{
@EAGER
List<Team> teams;
}
User u = findUserById(1);
u.getName();
EOF
12
Objects
SQL
Eagerly retrieve
teams from DB
User Table Team Table
join Team data is never
used!
Detecting excessive data
using static analysis
13
First find all the objects that
eagerly retrieve data from DB
Class User{
@EAGER
List<Team> teams;
}
Identify all the data usages of
ORM-managed objects
User user = findUserByID(1);
Check if the eagerly retrieved
data is ever used
user.getName();
user team
user team
Nested transaction bug pattern
14
@Transaction(Propogation.
REQUIRED)
getUser(){
updateUserGroup(u)
…
}
Create a DB
transaction
@Transaction(Propogation.
REQUIRES_NEW)
Create a child transaction, and suspend
parent transaction until child is finished
Misconfigurations can cause unexpected
transaction timeout, deadlock, or other
performance-related problems
Detecting nested transaction bug
pattern
15
@Transaction(Propogation.
REQUIRED)
getUser(){
…
updateUserGroup(u)
…
}
Parse all transaction
configurations
Identify all methods with the
annotation
Propogation.REQUIRED
Propogation.REQUIRS_NEW
calls
Traverse the call graph to identify
potential misconfigurations
Limitation of current static analysis
tools
16
Annotations are lost
when converting source
code to byte code
Do not consider how
developers configure
frameworks
@Transaction(Propo
gation.REQUIRED)
@EAGER
Many problems
are related to
framework
configurations
Many
configurations are
set through
annotations
Overview of the presentation
17
Bug patterns
Lessons learned when
adopting the tool in practice
Most discussed bug
patterns are related to
incorrect usage of
frameworks
Overview of the presentation
18
Bug patterns
Lessons learned when
adopting the tool in practice
Most discussed bug
patterns are related to
incorrect usage of
frameworks
Handling a large number of detection
results
19
• Developers have limited time to fix detected problems
• Most existing static analysis frameworks do not prioritize
the detected instances for the same bug pattern
20
Prioritizing based on DB tables
User
Time zone
• Problems related to large or
frequently-accessed tables are
ranked higher (more likely to be
performance bottlenecks)
• Problems related to highly
dependable tables are ranked
higher
Developers have different
backgrounds
21
• Not all developers are familiar with these frameworks and
databases
• Developers may not take the problems seriously if they
don’t understand the impact
Educating developers about
the detected problems
22
• We hosted several workshops
to educate developers about
the impact and cause of the
problems
• Walk developers through
examples of detected
problems
• May learn new bug patterns
from developers
Overview of the presentation
23
Bug patterns
Lessons learned when
adopting the tool in practice
Most discussed bug
patterns are related to
incorrect usage of
frameworks
We prioritize problems
based on DB tables, and
educate developers about
the problems
24
25
26
27
28
29
30
31
Tse-Hsun (Peter) Chen
http://petertsehsun.github.io

More Related Content

PPTX
MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational...
PPTX
CSER2016 - Detecting Problems in Database Access Code of Large Scale Systems
PPTX
FSE2016 - CacheOptimizer: Helping Developers Configure Caching Frameworks for...
PPTX
Improving the Performance of Database-Centric Applications Through Program An...
PPTX
TSE 2016 - Finding and Evaluating the Performance Impact of Redundant Data Ac...
PPTX
ICSE2014 - Detecting Performance Anti-patterns for Applications Developed usi...
PPTX
ICSE2017 - Analytics Driven Load Testing: An Industrial Experience Report on ...
PDF
Icse2018 autonomic
MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational...
CSER2016 - Detecting Problems in Database Access Code of Large Scale Systems
FSE2016 - CacheOptimizer: Helping Developers Configure Caching Frameworks for...
Improving the Performance of Database-Centric Applications Through Program An...
TSE 2016 - Finding and Evaluating the Performance Impact of Redundant Data Ac...
ICSE2014 - Detecting Performance Anti-patterns for Applications Developed usi...
ICSE2017 - Analytics Driven Load Testing: An Industrial Experience Report on ...
Icse2018 autonomic

What's hot (19)

PPTX
iPerfDetector: Characterizing and Detecting Performance Anti-patterns in iOS ...
PPTX
SQL Injections (Part 1)
PPTX
SQL Injection
PPTX
SQL Injection in JAVA
PPT
Sql injection attacks
PPTX
SQL Injections - A Powerpoint Presentation
PPTX
SharePoint underground (Unmanaged Code and SharePoint Internals)
PPTX
A first look at the integration of machine learning models in complex autonom...
PPTX
Web Security: SQL Injection
PPTX
java code and document security
PPTX
Sql injection - security testing
PDF
Approaches to detect and prevent sql injection in web applications
PPTX
seminar report on Sql injection
PPTX
SQL Injection Attacks cs586
PPTX
Semantic DEX Components
PDF
professional fuzzy type-ahead rummage around in xml type-ahead search techni...
PPTX
Testclass [Autosaved]
PPTX
Greensql2007
PPTX
Sql injections - with example
iPerfDetector: Characterizing and Detecting Performance Anti-patterns in iOS ...
SQL Injections (Part 1)
SQL Injection
SQL Injection in JAVA
Sql injection attacks
SQL Injections - A Powerpoint Presentation
SharePoint underground (Unmanaged Code and SharePoint Internals)
A first look at the integration of machine learning models in complex autonom...
Web Security: SQL Injection
java code and document security
Sql injection - security testing
Approaches to detect and prevent sql injection in web applications
seminar report on Sql injection
SQL Injection Attacks cs586
Semantic DEX Components
professional fuzzy type-ahead rummage around in xml type-ahead search techni...
Testclass [Autosaved]
Greensql2007
Sql injections - with example
Ad

Similar to ICSE2016 - Detecting Problems in Database Access Code of Large Scale Systems - An Industrial Experience Report (20)

PPT
YDP_API&MS_UNIT_IIIii8iiiiiiiii8iiii.ppt
PPT
YDP_API&MS_UNIT_hiii detail notes to understand api.ppt
PPTX
Icse2014 v3
PDF
Java Web Programming on Google Cloud Platform [2/3] : Datastore
PDF
Introduction to Datastore
PPTX
Eagle from eBay at China Hadoop Summit 2015
PDF
Data access
PPTX
12_Data_Storage_Part_2.pptx
PPTX
Basic of Big Data
PDF
Network Device Database Management with REST using Jersey
PPTX
S03 hybrid app_and_gae_datastore_v1.0
PPTX
Building Large Scale PHP Web Applications with Laravel 4
PPT
DataFinder: A Python Application for Scientific Data Management
PPTX
Extend your REST API
PDF
Hibernate training at HarshithaTechnologySolutions @ Nizampet
PPT
Organizing the Data Chaos of Scientists
DOC
IT6701-Information management question bank
DOCX
Hibernate3 q&a
PPTX
Microsoft Entity Framework
DOCX
Rajesh Ramasamy
YDP_API&MS_UNIT_IIIii8iiiiiiiii8iiii.ppt
YDP_API&MS_UNIT_hiii detail notes to understand api.ppt
Icse2014 v3
Java Web Programming on Google Cloud Platform [2/3] : Datastore
Introduction to Datastore
Eagle from eBay at China Hadoop Summit 2015
Data access
12_Data_Storage_Part_2.pptx
Basic of Big Data
Network Device Database Management with REST using Jersey
S03 hybrid app_and_gae_datastore_v1.0
Building Large Scale PHP Web Applications with Laravel 4
DataFinder: A Python Application for Scientific Data Management
Extend your REST API
Hibernate training at HarshithaTechnologySolutions @ Nizampet
Organizing the Data Chaos of Scientists
IT6701-Information management question bank
Hibernate3 q&a
Microsoft Entity Framework
Rajesh Ramasamy
Ad

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPT
Teaching material agriculture food technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
MYSQL Presentation for SQL database connectivity
“AI and Expert System Decision Support & Business Intelligence Systems”
Teaching material agriculture food technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Machine learning based COVID-19 study performance prediction
Network Security Unit 5.pdf for BCA BBA.
Mobile App Security Testing_ A Comprehensive Guide.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Chapter 3 Spatial Domain Image Processing.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
20250228 LYD VKU AI Blended-Learning.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Building Integrated photovoltaic BIPV_UPV.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Diabetes mellitus diagnosis method based random forest with bat algorithm
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Electronic commerce courselecture one. Pdf
Big Data Technologies - Introduction.pptx
Empathic Computing: Creating Shared Understanding
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx

ICSE2016 - Detecting Problems in Database Access Code of Large Scale Systems - An Industrial Experience Report

  • 1. Detecting Problems in the Database Access Code of Large Scale Systems An industrial Experience Report 1 Mohamed Nasser, Parminder Flora Tse-Hsun(Peter) Chen Ahmed E. HassanWeiyi Shang
  • 2. Existing static analysis tools focus on language-related problems 2 Coverity PMD Google error-prone Facebook InferFindBugs However, many problems are related to how developers use different frameworks
  • 3. Over 67% of Java developers use Object-Relational Mapping (Hibernate) to access databases 3 Existing static analysis tools provide mostly rudimentary support for JDBC! 22%67%
  • 4. Over 40% of Java web application developers use Spring 4 Developers use Spring to manage database transactions in web applications None of the static analysis tools support Spring!
  • 5. There is a huge need for framework- specific tools 5 Developers leverage MANY frameworks, but existing tools only support detecting language-related problems.
  • 6. An example class with Java ORM code 6 @Entity @Table(name = “user”) @DynamicUpdate public class User{ @Column(name=“id”) private int id; @Column(name=“name”) String userName; @OneToMany(fetch=FetchType.EAGER) List<Team> teams; public void setName(String n){ userName = n; } … other getter and setter methods User.java User class is mapped to “user” table in DB id is mapped to the column “id” in the user table A user can belong to multiple teams Eagerly retrieve associated teams when retrieving a user object Performance- related configs
  • 7. Accessing the database using ORM 7 User u = findUserByID(1); ORM database select u from user where u.id = 1; u.setName(“Peter”); update user set name=“Peter” where user.id = 1; Objects SQLs
  • 8. Transaction management using Spring 8 @Transaction(Propogation.REQUIRED) getUser(){ … updateUserGroup(u) … } By using ORM and Spring, developers can focus more on the business logic and functionality Create a DB transaction Entire business logic will be executed with the same DB transaction
  • 9. Implementing DBChecker 9 Source code • DBChecker looks for both functional and performance bug patterns • DBChecker is integrated in industrial practice
  • 10. Overview of the presentation 10 Bug patterns Lessons learned when adopting the tool in practice
  • 11. Overview of the presentation 11 Bug patterns Lessons learned when adopting the tool in practice More patterns and learned lessons in the paper
  • 12. ORM excessive data bug pattern Class User{ @EAGER List<Team> teams; } User u = findUserById(1); u.getName(); EOF 12 Objects SQL Eagerly retrieve teams from DB User Table Team Table join Team data is never used!
  • 13. Detecting excessive data using static analysis 13 First find all the objects that eagerly retrieve data from DB Class User{ @EAGER List<Team> teams; } Identify all the data usages of ORM-managed objects User user = findUserByID(1); Check if the eagerly retrieved data is ever used user.getName(); user team user team
  • 14. Nested transaction bug pattern 14 @Transaction(Propogation. REQUIRED) getUser(){ updateUserGroup(u) … } Create a DB transaction @Transaction(Propogation. REQUIRES_NEW) Create a child transaction, and suspend parent transaction until child is finished Misconfigurations can cause unexpected transaction timeout, deadlock, or other performance-related problems
  • 15. Detecting nested transaction bug pattern 15 @Transaction(Propogation. REQUIRED) getUser(){ … updateUserGroup(u) … } Parse all transaction configurations Identify all methods with the annotation Propogation.REQUIRED Propogation.REQUIRS_NEW calls Traverse the call graph to identify potential misconfigurations
  • 16. Limitation of current static analysis tools 16 Annotations are lost when converting source code to byte code Do not consider how developers configure frameworks @Transaction(Propo gation.REQUIRED) @EAGER Many problems are related to framework configurations Many configurations are set through annotations
  • 17. Overview of the presentation 17 Bug patterns Lessons learned when adopting the tool in practice Most discussed bug patterns are related to incorrect usage of frameworks
  • 18. Overview of the presentation 18 Bug patterns Lessons learned when adopting the tool in practice Most discussed bug patterns are related to incorrect usage of frameworks
  • 19. Handling a large number of detection results 19 • Developers have limited time to fix detected problems • Most existing static analysis frameworks do not prioritize the detected instances for the same bug pattern
  • 20. 20 Prioritizing based on DB tables User Time zone • Problems related to large or frequently-accessed tables are ranked higher (more likely to be performance bottlenecks) • Problems related to highly dependable tables are ranked higher
  • 21. Developers have different backgrounds 21 • Not all developers are familiar with these frameworks and databases • Developers may not take the problems seriously if they don’t understand the impact
  • 22. Educating developers about the detected problems 22 • We hosted several workshops to educate developers about the impact and cause of the problems • Walk developers through examples of detected problems • May learn new bug patterns from developers
  • 23. Overview of the presentation 23 Bug patterns Lessons learned when adopting the tool in practice Most discussed bug patterns are related to incorrect usage of frameworks We prioritize problems based on DB tables, and educate developers about the problems
  • 24. 24
  • 25. 25
  • 26. 26
  • 27. 27
  • 28. 28
  • 29. 29
  • 30. 30