opdenkamp/xbmc — Issue #305: Debug log shows XBMC attempting to remove XBMC entries constantly.
Author: samnazarko
Created: 2011-11-04 21:38:14+00:00
State: open

This issue is similar to Issue #283.

The following is appearing in xbmc.log, and the IO is very high causing the performance to lock in some cases:

```bash
cat /root/.xbmc/temp/xbmc.log | grep Epg
18:56:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
18:56:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg4.db
18:56:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg3.db
18:56:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg2.db
18:56:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg1.db
18:56:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg.db
18:56:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
18:56:53 T:3011705744 INFO: EpgDB - CreateTables - creating tables
18:56:53 T:3011705744 DEBUG: EpgDB - CreateTables - creating table 'epg'
18:56:53 T:3011705744 DEBUG: EpgDB - CreateTables - creating table 'epgtags'
18:56:53 T:3011705744 DEBUG: EpgDB - CreateTables - creating table 'lastepgscan'
18:56:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
18:56:53 T:3011705744 INFO: EpgContainer - RemoveOldEntries - removing old EPG entries
18:56:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
19:01:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
19:11:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
19:11:53 T:3011705744 INFO: EpgContainer - RemoveOldEntries - removing old EPG entries
19:11:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
19:21:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
19:26:53 T:3011705744 INFO: EpgContainer - RemoveOldEntries - removing old EPG entries
19:26:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
19:31:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
19:41:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
19:41:53 T:3011705744 INFO: EpgContainer - RemoveOldEntries - removing old EPG entries
19:41:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
19:51:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
19:56:53 T:3011705744 INFO: EpgContainer - RemoveOldEntries - removing old EPG entries
19:56:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
20:01:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
20:11:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
20:11:53 T:3011705744 INFO: EpgContainer - RemoveOldEntries - removing old EPG entries
20:11:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
20:21:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
20:26:53 T:3011705744 INFO: EpgContainer - RemoveOldEntries - removing old EPG entries
20:26:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
20:31:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
20:41:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
20:41:53 T:3011705744 INFO: EpgContainer - RemoveOldEntries - removing old EPG entries
20:41:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
20:51:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
20:56:53 T:3011705744 INFO: EpgContainer - RemoveOldEntries - removing old EPG entries
20:56:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
21:01:53 T:3011705744 DEBUG: Connecting to sqlite:/root/.xbmc/userdata/Database/:Epg5.db
```

This has been occurring since October 21st commit to EpgContainer.cpp. Reverting to Sep19 (80278a98c6) version of the file, does not cause the issue.

Interestingly, marking the file is immutable and erasing its contents:

```bash
echo "">Epg5.db
touch Epg5.db
chattr +i Epg5.db
```

Stops this loop from occurring and bings back sane performance.

In Oct21 commit I notice introduction of:

`bool bLoaded(false);` the use of a boolean variable that might be causing this loop. Use of UTC time instead of local time.

Not sure if this is of use, but nonetheless. Temporary workaround is this patch:

```
166d165
< bool bLoaded(false);
177c176
< CDateTime::GetCurrentDateTime().GetAsUTCDateTime().GetAsTime(iNow);
---
> CDateTime::GetCurrentDateTime().GetAsTime(iNow);
179c178
< bUpdateEpg = (iNow >= m_iNextEpgUpdate || !bLoaded);
---
> bUpdateEpg = (iNow >= m_iNextEpgUpdate);
194,195d192
< bLoaded = true;
<
463c460
< CDateTime::GetCurrentDateTime().GetAsUTCDateTime().GetAsTime(m_iNextEpgUpdate);
---
> CDateTime::GetCurrentDateTime().GetAsTime(m_iNextEpgUpdate);
477c474
< CDateTime::GetCurrentDateTime().GetAsUTCDateTime().GetAsTime(iNow);
---
> CDateTime::GetCurrentDateTime().GetAsTime(iNow);

```