Bug 14806 - dsdb_get_schema calls expensive talloc_is_parent()
Summary: dsdb_get_schema calls expensive talloc_is_parent()
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: AD: LDB/DSDB/SAMDB (show other bugs)
Version: 4.15.0rc2
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Andrew Bartlett
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on: 14821
Blocks:
  Show dependency treegraph
 
Reported: 2021-08-23 02:17 UTC by Andrew Bartlett
Modified: 2021-10-06 03:52 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Bartlett 2021-08-23 02:17:37 UTC
talloc_is_parent() is not, as one might imagine, a direct pointer lookup, or a wrapper around talloc_parent(), but instead confirms if the supplied pointer is in a parent/child relationship up to any depth.

This is quite expensive and so becomes the dominant memory operation in LDB search operations. 

We need to re-evaluate if these calls can be safely omitted in some cases and if not, change talloc_is_parent(foo, parent) to talloc_parent(foo) == parent.
Comment 1 Andrew Bartlett 2021-08-23 02:19:31 UTC
The suspect commit is in Samba 4.12 and later:

commit ee2fe56ba0ef6626b634376e8dc2185aa89f8c99
Author: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Date:   Tue Nov 27 11:07:44 2018 +1300

    drepl: memory leak fix
    
    Fixes a memory leak where schema reference attached to ldb
    instance is lost before it can be freed.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14042
    
    Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
    
    Reviewed-by: Andrew Bartlett <abartlet@samba.org>
    Reviewed-by: Garming Sam <garming@catalyst.net.nz>
    
    Autobuild-User(master): Garming Sam <garming@samba.org>
    Autobuild-Date(master): Wed Jul 17 06:17:10 UTC 2019 on sn-devel-184
Comment 2 Samba QA Contact 2021-09-05 03:20:05 UTC
This bug was referenced in samba master:

8affe4a1e625104de4ca024fdc3e9cd96498aff3
Comment 3 Samba QA Contact 2021-09-08 13:55:39 UTC
This bug was referenced in samba v4-15-test:

86d3397f852e4e6e5fa5096d91c4263e26742d0f
Comment 4 Samba QA Contact 2021-09-09 06:55:22 UTC
This bug was referenced in samba v4-15-stable (Release samba-4.15.0rc6):

86d3397f852e4e6e5fa5096d91c4263e26742d0f
Comment 5 Samba QA Contact 2021-09-10 15:25:46 UTC
This bug was referenced in samba v4-13-test:

02c40fd92dcd7224228dc232d5fdf0738d313a36
Comment 6 Samba QA Contact 2021-09-13 09:00:04 UTC
This bug was referenced in samba v4-14-test:

59f6d56f4ef4a8cde8a4e50bb6ab1a51093de025
Comment 7 Samba QA Contact 2021-09-22 07:04:54 UTC
This bug was referenced in samba v4-13-stable (Release samba-4.13.12):

02c40fd92dcd7224228dc232d5fdf0738d313a36
Comment 8 Samba QA Contact 2021-10-05 13:19:11 UTC
This bug was referenced in samba v4-14-stable (Release samba-4.14.8):

59f6d56f4ef4a8cde8a4e50bb6ab1a51093de025