{"action":"created","issue":{"url":"https://api.github.com/repos/xbmc/xbmc/issues/12844","repository_url":"https://api.github.com/repos/xbmc/xbmc","labels_url":"https://api.github.com/repos/xbmc/xbmc/issues/12844/labels{/name}","comments_url":"https://api.github.com/repos/xbmc/xbmc/issues/12844/comments","events_url":"https://api.github.com/repos/xbmc/xbmc/issues/12844/events","html_url":"https://github.com/xbmc/xbmc/pull/12844","id":260973280,"number":12844,"title":"[PVR] Make PVR database threadsafe.","user":{"login":"ksooo","id":3226626,"avatar_url":"https://avatars3.githubusercontent.com/u/3226626?v=4","gravatar_id":"","url":"https://api.github.com/users/ksooo","html_url":"https://github.com/ksooo","followers_url":"https://api.github.com/users/ksooo/followers","following_url":"https://api.github.com/users/ksooo/following{/other_user}","gists_url":"https://api.github.com/users/ksooo/gists{/gist_id}","starred_url":"https://api.github.com/users/ksooo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ksooo/subscriptions","organizations_url":"https://api.github.com/users/ksooo/orgs","repos_url":"https://api.github.com/users/ksooo/repos","events_url":"https://api.github.com/users/ksooo/events{/privacy}","received_events_url":"https://api.github.com/users/ksooo/received_events","type":"User","site_admin":false},"labels":[{"id":1659186,"url":"https://api.github.com/repos/xbmc/xbmc/labels/Fix","name":"Fix","color":"0b02e1","default":false},{"id":15146247,"url":"https://api.github.com/repos/xbmc/xbmc/labels/PVR","name":"PVR","color":"009800","default":false},{"id":400751192,"url":"https://api.github.com/repos/xbmc/xbmc/labels/v18%20Leia","name":"v18 Leia","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/xbmc/xbmc/milestones/95","html_url":"https://github.com/xbmc/xbmc/milestone/95","labels_url":"https://api.github.com/repos/xbmc/xbmc/milestones/95/labels","id":2166828,"number":95,"title":"L 18.0-alpha1","description":"","creator":{"login":"MartijnKaijser","id":907436,"avatar_url":"https://avatars1.githubusercontent.com/u/907436?v=4","gravatar_id":"","url":"https://api.github.com/users/MartijnKaijser","html_url":"https://github.com/MartijnKaijser","followers_url":"https://api.github.com/users/MartijnKaijser/followers","following_url":"https://api.github.com/users/MartijnKaijser/following{/other_user}","gists_url":"https://api.github.com/users/MartijnKaijser/gists{/gist_id}","starred_url":"https://api.github.com/users/MartijnKaijser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartijnKaijser/subscriptions","organizations_url":"https://api.github.com/users/MartijnKaijser/orgs","repos_url":"https://api.github.com/users/MartijnKaijser/repos","events_url":"https://api.github.com/users/MartijnKaijser/events{/privacy}","received_events_url":"https://api.github.com/users/MartijnKaijser/received_events","type":"User","site_admin":false},"open_issues":12,"closed_issues":1263,"state":"open","created_at":"2016-11-30T16:58:49Z","updated_at":"2017-09-27T13:26:15Z","due_on":"2017-12-31T08:00:00Z","closed_at":null},"comments":3,"created_at":"2017-09-27T13:26:15Z","updated_at":"2017-09-27T20:00:33Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/xbmc/xbmc/pulls/12844","html_url":"https://github.com/xbmc/xbmc/pull/12844","diff_url":"https://github.com/xbmc/xbmc/pull/12844.diff","patch_url":"https://github.com/xbmc/xbmc/pull/12844.patch"},"body":"class `CPVRDatabase` had no concurrency protection features but is accessed simultaneously from multiple threads. :-/ This PR introduces basic concurrency support for `CPVRDatabase`.\r\n\r\nExample:\r\n<pre>\r\nThread 43 (Thread 0x59d65390 (LWP 736)):\r\n#0  0x007480f8 in dbiplus::field_prop* std::__uninitialized_default_n_1<false>::__uninit_default_n<dbiplus::field_prop*, unsigned int>(dbiplus::field_prop*, unsigned int) ()\r\n#1  0x00748164 in std::vector<dbiplus::field_prop, std::allocator<dbiplus::field_prop> >::_M_default_append(unsigned int) ()\r\n#2  0x00747774 in dbiplus::SqliteDataset::query(std::string const&) ()\r\n#3  0x0073ddd4 in CDatabase::GetSingleValue(std::string const&, std::unique_ptr<dbiplus::Dataset, std::default_delete<dbiplus::Dataset> >&) ()\r\n#4  0x0073ee90 in CDatabase::GetSingleValue(std::string const&, std::string const&, std::string const&, std::string const&) ()\r\n#5  0x008c507c in PVR::CPVRDatabase::PersistChannels(PVR::CPVRChannelGroup&) ()\r\n#6  0x008c696c in PVR::CPVRDatabase::Persist(PVR::CPVRChannelGroup&) ()\r\n#7  0x008aa28c in PVR::CPVRChannelGroup::Persist() ()\r\n#8  0x008ac814 in PVR::CPVRChannelGroup::UpdateGroupEntries(PVR::CPVRChannelGroup const&) ()\r\n#9  0x008af3bc in PVR::CPVRChannelGroupInternal::UpdateGroupEntries(PVR::CPVRChannelGroup const&) ()\r\n#10 0x008aef20 in PVR::CPVRChannelGroupInternal::Update() ()\r\n#11 0x008b1874 in PVR::CPVRChannelGroups::Update(bool) ()\r\n#12 0x008b24e4 in PVR::CPVRChannelGroupsContainer::Update(bool) ()\r\n#13 0x008d184c in PVR::CPVRChannelGroupsUpdateJob::DoWork() ()\r\n#14 0x008c1370 in PVR::CPVRManagerJobQueue::ExecutePendingJobs() ()\r\n#15 0x008c200c in PVR::CPVRManager::Process() ()\r\n#16 0x0066c9a4 in CThread::Action() ()\r\n#17 0x0066d0a0 in CThread::staticThread(void*) ()\r\n#18 0x76efdd34 in start_thread (arg=0x59d65390) at pthread_create.c:465\r\n#19 0x74fd0ab8 in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:73 from /usr/lib/libc.so.6\r\nBacktrace stopped: previous frame identical to this frame (corrupt stack?)\r\n\r\n\r\nThread 1 (Thread 0x6e8ff390 (LWP 685)):\r\n#0  0x7519ea60 in std::string::assign(std::string const&) () from /usr/lib/libstdc++.so.6\r\n#1  0x00746978 in dbiplus::SqliteDataset::make_query(std::list<std::string, std::allocator<std::string> >&) ()\r\n#2  0x00745a88 in dbiplus::SqliteDataset::make_insert() ()\r\n#3  0x0073e058 in CDatabase::CommitInsertQueries() ()\r\n#4  0x008a7a78 in PVR::CPVRChannel::Persist() ()\r\n#5  0x008ad160 in PVR::CPVRChannelGroup::SearchAndSetChannelIcons(bool) ()\r\n#6  0x008b264c in PVR::CPVRChannelGroupsContainer::SearchMissingChannelIcons() const ()\r\n#7  0x008d1474 in PVR::CPVRSearchMissingChannelIconsJob::DoWork() ()\r\n#8  0x00627984 in CJobWorker::Process() ()\r\n#9  0x0066c9a4 in CThread::Action() ()\r\n#10 0x0066d0a0 in CThread::staticThread(void*) ()\r\n#11 0x76efdd34 in start_thread (arg=0x6e8ff390) at pthread_create.c:465\r\n#12 0x74fd0ab8 in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:73 from /usr/lib/libc.so.6\r\nBacktrace stopped: previous frame identical to this frame (corrupt stack?)\r\n</pre>\r\n\r\nThis should fix several occasional crashes reported in the forum and elsewhere.\r\n\r\nExample: https://forum.kodi.tv/showthread.php?tid=298461&pid=2651405#pid2651405 (second crashlog in that posting)\r\n\r\nI runtime-tested this change on macOS, latest Kodi master.\r\n\r\n@Jalle19 for review?"},"comment":{"url":"https://api.github.com/repos/xbmc/xbmc/issues/comments/332638384","html_url":"https://github.com/xbmc/xbmc/pull/12844#issuecomment-332638384","issue_url":"https://api.github.com/repos/xbmc/xbmc/issues/12844","id":332638384,"user":{"login":"a1rwulf","id":5141257,"avatar_url":"https://avatars3.githubusercontent.com/u/5141257?v=4","gravatar_id":"","url":"https://api.github.com/users/a1rwulf","html_url":"https://github.com/a1rwulf","followers_url":"https://api.github.com/users/a1rwulf/followers","following_url":"https://api.github.com/users/a1rwulf/following{/other_user}","gists_url":"https://api.github.com/users/a1rwulf/gists{/gist_id}","starred_url":"https://api.github.com/users/a1rwulf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/a1rwulf/subscriptions","organizations_url":"https://api.github.com/users/a1rwulf/orgs","repos_url":"https://api.github.com/users/a1rwulf/repos","events_url":"https://api.github.com/users/a1rwulf/events{/privacy}","received_events_url":"https://api.github.com/users/a1rwulf/received_events","type":"User","site_admin":false},"created_at":"2017-09-27T20:00:33Z","updated_at":"2017-09-27T20:00:33Z","author_association":"MEMBER","body":"I think the VideoDatabase code does not share database instances across threads, at least the parts I've seen. Sqlite should be compiled with multithread support so also this shouldn't be an issue either.\r\n\r\nAs far as I can see PVRManager holds the DB connection that is shared, so this changes are very needed."}}
{"actor":{"display_login":"a1rwulf"}}