Locked .ldb file (1 Viewer)

kirkm

Registered User.
Local time
Tomorrow, 02:35
Joined
Oct 30, 2008
Messages
1,257
Hi, found a locked ldb file which I couldn't delete. Access was closed and nothing was showing in Task Manager (nor in Computer Management / System Tools / Shared Folders / Open Files).


The mdb file would not open. I rebooted and the locked ldb stayed, although I could then open the mdb and when closed, ldb went away.


What other action could I take to fix this without rebooting?
Thanks (btw using Win XP).
 

Micron

AWF VIP
Local time
Today, 09:35
Joined
Oct 20, 2018
Messages
3,476
this is over a network?
Not uncommon; usually from a dropped connection (or more commonly) a bad shutdown. Often users mistake a long running query for a problem and the "not responding" message is misleading. Best to terminate Access and start up again, and the ldb file is sometimes over-written. Alternative is to have IT person delete the file, but only if you're sure no one else is connected. Some login details can be known by looking at the ldb file.


EDIT - oh yeah, then there's just wait for the network to scan and automatically purge the file because it is found to not be in use.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:35
Joined
Oct 29, 2018
Messages
21,357
Sometimes, I try to take ownership of the lock file before trying to delete it.
 

kirkm

Registered User.
Local time
Tomorrow, 02:35
Joined
Oct 30, 2008
Messages
1,257
No it isn't over a Network, but I do/can have a ADODB connection from Excel although Excel was closed at the time.
Did "taking ownership" work? How do you do that? I'm the only user here, so presumably administrator?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:35
Joined
Oct 29, 2018
Messages
21,357
No it isn't over a Network, but I do/can have a ADODB connection from Excel although Excel was closed at the time.
Did "taking ownership" work? How do you do that? I'm the only user here, so presumably administrator?
Sometimes, the reason why you can't delete a file is because you don't own it. So, by taking ownership, I was able to delete most of them. There could be times taking ownership is not possible, if the file is owned by the system, for example. In those cases, rebooting like you did would probably be the only option. In your case though, if you're the only user and this is on a local machine, then you should have been the owner already.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:35
Joined
Feb 28, 2001
Messages
26,999
To find what is locking Access on your own (single) machine, you can start Resource Monitor, switch to the CPU tab, select MSACCESS.EXE as the image, and see what file handles are involved with that process.

Now reduce that to half-screen and start Task Manager. In the menu bar, use the View option to tell it to include the PID of each process. Reduce that to half-screen. You should be able to see what handles are still open. At least one of them might be different from the others because it comes from a different process than the instance of Access you just opened. You can find the process by PID and select it in Task Manager. Then do an End Process on it.

If that doesn't work and a reboot doesn't help, take a look at the security on the .LDB file. Right click on the file, select Properties >> Security then click Advanced >> Owner to see who owns it. You can take ownership of the file from that screen. From "Advanced" you can also see if the Effective Permissions on the file would allow you to delete it.

The file handle test looks for a common dynamic i.e. temporary reason to be unable to delete the file. Closing the process that owns a lock (handle) on the file should get rid of that reason. A reboot is the more aggressive way to get rid of file handles.

The owner and permissions tests look for a static i.e. permanent reason to be unable to delete the file. If you take ownership of the file or reset its permissions, that should be adequate to unblock the file.

If neither of those work, schedule a CHKDSK because some structure is corrupted and needs fixing.
 

kirkm

Registered User.
Local time
Tomorrow, 02:35
Joined
Oct 30, 2008
Messages
1,257
Thanks very much for the detailed reply. I've saved it and will work through it next time it happens.
 

kirkm

Registered User.
Local time
Tomorrow, 02:35
Joined
Oct 30, 2008
Messages
1,257
I had another instance of a bogus 'locked' file and tried to follow the steps by DocMan
but there is no Resource Monitor. I can get to task manager but no further. It Resource Manager only in late Windows versions (I have Win XP) ?
 

Micron

AWF VIP
Local time
Today, 09:35
Joined
Oct 20, 2018
Messages
3,476
Do you know for sure it wasn't someone else who created this file? Open in NotePad (be sure to not keep a default checkbox about "always open with this application" or whatever it says). The pc number should be visible in NotePad. If you get strange characters, open Word, new doc, and drag laccdb file on to Word header. If prompted about being in use, just choose to make a read only copy.

I suspect whoever is leaving that file behind does not have delete rights on the folder. Thus they can create the lock file, or add to it if it's already there, but they can't delete it (I mean Access deleting according to their permissions, not that they are intentionally trying to delete it - it's automatic).

Another possibility is virus/trojan/ransom or network software like Trend Micro stuff. I had those on and they kept locking various files and I couldn't start browser or email. Files were being reported as being in use by the applications but they were not. No problems since I removed the programs.
 
Last edited:

kirkm

Registered User.
Local time
Tomorrow, 02:35
Joined
Oct 30, 2008
Messages
1,257
No one else uses the comp. This has happened a couple of times now, but I can't make it so.. next time I'll open the .ldb in Notepad or Word and let you know what it says.
Thanks...
 

Micron

AWF VIP
Local time
Today, 09:35
Joined
Oct 20, 2018
Messages
3,476
Well if no one else could be opening the db, and you are not shutting down db abnormally (e.g. task manager or via code, or something akin to pulling the plug) then I'd look at virus programs. If the contents of the file don't help, try shutting down any virus or network type of scanner programs and deleting file a few moments later.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:35
Joined
Feb 28, 2001
Messages
26,999
WinXP certainly complicates matters because a lot of the tools since Win7 just aren't there for XP. But thinking about this, I have to ask this question: How is an .LDB file created? And the answer is, someone has to open the database file. So the NEXT question is, how do I do that? There is more than one way, so I'll ramble a bit and see if it rings any bells.

The first and most obvious way is to launch the App with a click or double-click (depends on Windows settings for task launching as to which) or click-Run.

The next way is for the code to contain an explicit OpenDatabase pointing to the file for which you have this messy .LDB file. If you programmatically open the .MDB file, you will also get an .LDB file. If you then have a problematic exit, you might not get to clean up that second opening step.

I don't think a virus CAN create an .LDB file so easily and doubt that malware would do a "phantom launch" of an Access app because they would have to be written for a fairly specific type of malicious behavior than somehow, despite its complexity, seems a bit too innocuous for a virus or trojan. The question would then be whether you have any other DBs on the machine that have shown similar behavior.

By any chance, do you have code to do late mapping of tables? Because that would surely use an .OpenDatabase method. And when this locking occurs, does your app take some sort of unhandled error that forces a reset? Because that might do it.
 

isladogs

MVP / VIP
Local time
Today, 13:35
Joined
Jan 14, 2017
Messages
18,186
Doc
What exactly does 'late mapping of tables' mean?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:35
Joined
Feb 28, 2001
Messages
26,999
Late binding - where you create linked tables on-the-fly to an external file. Lock files exist for ALL database files opened by Access regardless of whether they were opened at launch time or opened later. Doesn't seem likely in this case, but I recall cases we have seen on this forum where someone had multiple back-end files as archives that could be searched from the FE. I believe that even when you use the "IN path" syntax that is part of a FROM clause, for the duration of that usage, the referenced DB file gets a lock as well. However, I'm not betting on an exotic case like that one here.
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:35
Joined
Feb 28, 2001
Messages
26,999
kirkm - I glanced at this before but passed on it.

I do/can have a ADODB connection from Excel although Excel was closed at the time.

There are those who disagree with me on being meticulous about this, but the fact that you CAN have an external connection makes me wonder. I'm assuming you have an open connection from Excel because in Excel's VBA you opened a recordset. But when you were finished with that connection, did you actively close it? Or did you just hope that exiting from Excel would close it? In theory all recordsets should close when the code closes. But if Excel is lurking in the background in an I/O rundown state (where it is TRYING to close but hasn't got there yet), it won't be visible on Task Manager.

On XP, you lack the tools (like Resource Manager) to further explore the tasks in your system that are in transitional states. I/O rundown "hangs" happen. I used to see them from time to time with the U.S. Navy desktop systems because we had a LOT of XP systems - several hundred, in fact - at the Navy Enterprise Data Center. We eventually upgraded to Win7 and later they were heading to Win10 when I retired, but we were always behind the power curve on new operating systems. Had to do with delays in getting group policies and other features set up for a network with 10,000 users nation-wide. But that meant I got to see lots of hung process situations.
 

Micron

AWF VIP
Local time
Today, 09:35
Joined
Oct 20, 2018
Messages
3,476
I don't think a virus CAN create an .LDB file so easily
That's not what I'm saying. I'm saying virus/ransomeware scanning or blocking programs, or wifi network security applications not releasing their lock on files, thus leaving them behind when the application that creates them has already closed. I gave the name of one of them.
 

isladogs

MVP / VIP
Local time
Today, 13:35
Joined
Jan 14, 2017
Messages
18,186
Late binding - where you create linked tables on-the-fly to an external file. Lock files exist for ALL database files opened by Access regardless of whether they were opened at launch time or opened later.

I guessed you meant that rather than 'late mapping'
Whether you use early or late binding to create a table in an external DB, no lock file appears to be created in that DB
For info, I used the code in this link https://software-solutions-online.com/vba-automation-external-access-database-create-table/to check before posting
 

Micron

AWF VIP
Local time
Today, 09:35
Joined
Oct 20, 2018
Messages
3,476
Late binding - where you create linked tables on-the-fly to an external file.
Can't say I've ever read that definition before. Can't say I agree with it either, but then...
To me it has always referred to explicitly referencing a library file (dll, olb. tlb, etc) so that the association is made at compile time rather than letting Access determine the association at run time. Thus if not explicit, Access chooses (for example) version 15 rather than 16 according to which is available, but only when code executes.
 

kirkm

Registered User.
Local time
Tomorrow, 02:35
Joined
Oct 30, 2008
Messages
1,257
Thanks for the feedback... co-incidently another ldb file has just locked itself. This doesn't use Excel but is a Backend DB that an Access FrontEnd uses. The front end wasn't open and I'd opened the back end to look at some tables. After it shut it locked itself. This all happened in about 2 mins so perhaps unlikely a virus/malware got to it in that time?
Anyway I dragged it into Notepad and it says my Name and Admin twice. It's 128 bytes long...and consists of (very little help I'm sure)

4b49 524b 0020 2020 2020 2020 2020 2020
2020 2020 2020 2020 2020 2020 2020 2020
4164 6d69 6e00 2020 2020 2020 2020 2020
2020 2020 2020 2020 2020 2020 2020 2020
4b49 524b 0020 2020 2020 2020 2020 2020
2020 2020 2020 2020 2020 2020 2020 2020
4164 6d69 6e00 2020 2020 2020 2020 2020
2020 2020 2020 2020 2020 2020 2020 20

I don't need the file for a while so I leave it in this state in case someone has anything to try. Ideally I just want to delete it so I can open the mdb again (without rebooting the comp). If I get a fix I can apply it, otherwise try and figure out why they're locking which won't be easy. Or more likely, impossible.
 

Micron

AWF VIP
Local time
Today, 09:35
Joined
Oct 20, 2018
Messages
3,476
I'd say that is a big help. It would mean you are the culprit

Somehow you are initiating multiple locks but for some reason are not ending all of them. A prior post commented that you are using Excel against your tables. Are you creating a connection that persists but should not be? It's getting late here and this is in my phone so I will leave it at that for now. I think you are making some progress with this but more info may be required. Or a copy of db and workbook so that procedures can be checked
 

Users who are viewing this thread

Top Bottom