| Openbravo Issue Tracking System - Openbravo ERP | 
| View Issue Details | 
| 
 | 
| ID | Project | Category | View Status | Date Submitted | Last Update | 
| 0036419 | Openbravo ERP | A. Platform | public | 2017-07-05 14:05 | 2017-09-21 16:49 | 
| 
 | 
| Reporter | alostale |  | 
| Assigned To | alostale |  | 
| Priority | normal | Severity | major | Reproducibility | have not tried | 
| Status | closed | Resolution | fixed |  | 
| Platform |  | OS | 5 | OS Version |  | 
| Product Version |  |  | 
| Target Version |  | Fixed in Version | 3.0PR17Q4 |  | 
| Merge Request Status |  | 
| Review Assigned To | AugustoMauch | 
| OBNetwork customer | No | 
| Web browser |  | 
| Modules | Core | 
| Support ticket |  | 
| Regression level |  | 
| Regression date |  | 
| Regression introduced in release |  | 
| Regression introduced by commit |  | 
| Triggers an Emergency Pack | No | 
| 
 | 
| Summary | 0036419: no request processed while killing abandoned sessions | 
| Description | In a professional instance with limited concurrent users, having abandoned sessions it is possible to reach a situation where no request is processed. 
 This can occur if there is a DB lock in the ad_session rows that detected as abandoned. The thread trying to kill them, waits this lock to be released in a synchronized method so no other thread can be processed as they are also waiting this lock to be released.
 | 
| Steps To Reproduce | Couldn't reproduce following standard flows, but it is possible to emulate it: 
 1. Activate instance with a license limited to 1 concurrent user
 2. Create an abandoned session in DB:
 
 insert into ad_session (
 ad_session_id    ,    ad_client_id     ,    ad_org_id        ,    isactive         ,
 created          ,    createdby        ,    updated          ,    updatedby        ,
 processed        ,    session_active   ,    last_session_ping,    login_status     ,
 username)
 values
 (get_uuid(),   '0',    '0',   'Y',
 now(),        '0',    now(), '0',
 'N', 'Y', now() - 1, 'S',
 'test'   ) ;
 
 3. Create a lock for that session in DB:
 
 begin; select * from ad_session  order by created desc limit 1 for update;
 
 4. Try to open login window in several tabs
 
 -> None of them is completed
 | 
| Proposed Solution |  | 
| Additional Information |  | 
| Tags | Performance | 
| Relationships | | related to | defect | 0036425 |  | closed | alostale | mobile sessions can be kicked out in cluster |  | blocks | feature request | 0036477 |  | closed | alostale | autorefresh professional subscription license | 
 | 
| Attached Files |  | 
| 
 | 
| Issue History | 
| Date Modified | Username | Field | Change | 
| 2017-07-05 14:05 | alostale | New Issue |  | 
| 2017-07-05 14:05 | alostale | Assigned To | => platform | 
| 2017-07-05 14:05 | alostale | OBNetwork customer | => No | 
| 2017-07-05 14:05 | alostale | Modules | => Core | 
| 2017-07-05 14:05 | alostale | Triggers an Emergency Pack | => No | 
| 2017-07-06 08:15 | alostale | Tag Attached: Performance |  | 
| 2017-07-06 08:29 | alostale | Relationship added | related to 0036425 | 
| 2017-07-06 14:08 | alostale | Assigned To | platform => alostale | 
| 2017-07-06 14:08 | alostale | Review Assigned To | => AugustoMauch | 
| 2017-07-06 14:09 | hgbot | Checkin |  | 
| 2017-07-06 14:09 | hgbot | Note Added: 0097912 |  | 
| 2017-07-06 14:10 | hgbot | Checkin |  | 
| 2017-07-06 14:10 | hgbot | Note Added: 0097913 |  | 
| 2017-07-06 14:10 | hgbot | Status | new => resolved | 
| 2017-07-06 14:10 | hgbot | Resolution | open => fixed | 
| 2017-07-06 14:10 | hgbot | Fixed in SCM revision | => http://code.openbravo.com/erp/devel/pi/rev/76e0f1c4b33e58b7c413c696f3715e37b60f1ad1 [^] | 
| 2017-07-06 14:10 | hgbot | Checkin |  | 
| 2017-07-06 14:10 | hgbot | Note Added: 0097914 |  | 
| 2017-07-06 14:10 | hgbot | Checkin |  | 
| 2017-07-06 14:10 | hgbot | Note Added: 0097915 |  | 
| 2017-07-07 10:51 | hgbot | Checkin |  | 
| 2017-07-07 10:51 | hgbot | Note Added: 0097936 |  | 
| 2017-07-07 10:51 | AugustoMauch | Note Added: 0097937 |  | 
| 2017-07-07 10:51 | AugustoMauch | Status | resolved => closed | 
| 2017-07-07 10:51 | AugustoMauch | Fixed in Version | => 3.0PR17Q4 | 
| 2017-07-12 12:47 | alostale | Relationship added | blocks 0036477 | 
| 2017-09-21 16:49 | hudsonbot | Checkin |  | 
| 2017-09-21 16:49 | hudsonbot | Note Added: 0099238 |  | 
| 2017-09-21 16:49 | hudsonbot | Checkin |  | 
| 2017-09-21 16:49 | hudsonbot | Note Added: 0099239 |  | 
| 2017-09-21 16:49 | hudsonbot | Checkin |  | 
| 2017-09-21 16:49 | hudsonbot | Note Added: 0099240 |  | 
| 2017-09-21 16:49 | hudsonbot | Checkin |  | 
| 2017-09-21 16:49 | hudsonbot | Note Added: 0099241 |  | 
| 2017-09-21 16:49 | hudsonbot | Checkin |  | 
| 2017-09-21 16:49 | hudsonbot | Note Added: 0099245 |  | 
	| Notes | 
	| 
 | 
	| 
		
			| (0097912) |  
			| hgbot |  
			| 2017-07-06 14:09 |  | 
		
			| Repository: erp/devel/pi Changeset: 5aed2a398dac4b1d7d0438eaf6ba27c7eb6bd492
 Author: Asier Lostalé <asier.lostale <at> openbravo.com>
 Date: Wed Jul 05 14:47:20 2017 +0200
 URL: http://code.openbravo.com/erp/devel/pi/rev/5aed2a398dac4b1d7d0438eaf6ba27c7eb6bd492 [^]
 
 related to bug 36419: no request processed while killing abandoned sessions
 
 Deactivate abandoned sessions in a separate DB transaction, in this manner the
 time locks in ad_session are held is reduced to only this action, before those
 locks were held till the thread was terminated.
 
 ---
 M src/org/openbravo/erpCommon/obps/ActivationKey.java
 A src/org/openbravo/erpCommon/obps/ActivationKey_data.xsql
 ---
 
 |  | 
	| 
 | 
	| 
		
			| (0097913) |  
			| hgbot |  
			| 2017-07-06 14:10 |  | 
		
			| Repository: erp/devel/pi Changeset: 76e0f1c4b33e58b7c413c696f3715e37b60f1ad1
 Author: Asier Lostalé <asier.lostale <at> openbravo.com>
 Date: Thu Jul 06 07:41:00 2017 +0200
 URL: http://code.openbravo.com/erp/devel/pi/rev/76e0f1c4b33e58b7c413c696f3715e37b60f1ad1 [^]
 
 fixed bug 36419: no request processed while killing abandoned sessions
 
 * ActivationKey.getInstance is not synchronized anymore
 * Synchronization is now reduced to the places changing state
 * Session deactivation monitored by a lock to ensure there is at most one
 thread in this block, in this way, at most one thread can be wating for
 DB lock at this position
 
 ---
 M src/org/openbravo/erpCommon/obps/ActivationKey.java
 ---
 
 |  | 
	| 
 | 
	| 
		
			| (0097914) |  
			| hgbot |  
			| 2017-07-06 14:10 |  | 
		
			| Repository: erp/devel/pi Changeset: 79ddd2858936e1198dc7cc391563204254f94ae4
 Author: Asier Lostalé <asier.lostale <at> openbravo.com>
 Date: Thu Jul 06 08:11:02 2017 +0200
 URL: http://code.openbravo.com/erp/devel/pi/rev/79ddd2858936e1198dc7cc391563204254f94ae4 [^]
 
 related to bug 36419: no request processed while killing abandoned sessions
 
 Removed synchronization in WS call counter
 
 ---
 M src/org/openbravo/erpCommon/obps/ActivationKey.java
 ---
 
 |  | 
	| 
 | 
	| 
		
			| (0097915) |  
			| hgbot |  
			| 2017-07-06 14:10 |  | 
		
			| Repository: erp/devel/pi Changeset: 0d877e9b82122f10c66fbce1480723108168a715
 Author: Asier Lostalé <asier.lostale <at> openbravo.com>
 Date: Thu Jul 06 08:21:45 2017 +0200
 URL: http://code.openbravo.com/erp/devel/pi/rev/0d877e9b82122f10c66fbce1480723108168a715 [^]
 
 related to bug 36419: no request processed while killing abandoned sessions
 
 Log stack traces in case of error
 
 ---
 M src/org/openbravo/erpCommon/obps/ActivationKey.java
 ---
 
 |  | 
	| 
 | 
	| 
		
			| (0097936) |  
			| hgbot |  
			| 2017-07-07 10:51 |  |  | 
	| 
 | 
	|  | 
		
			| Code reviewed and verified in pi@aa2d71ec3678 |  | 
	| 
 | 
	|  |  | 
	| 
 | 
	|  |  | 
	| 
 | 
	|  |  | 
	| 
 | 
	|  |  | 
	| 
 | 
	|  |  |