winnfsd / vagrant-winnfsd

Manage and adds support for NFS for Vagrant on Windows.
Other
570 stars 61 forks source link

SQLite - SQLSTATE[HY000]: General error: 10 disk I/O error #97

Open piotr-cz opened 8 years ago

piotr-cz commented 8 years ago

When using this plugin, I'm getting an SQLite error SQLSTATE[HY000]: General error: 10 disk I/O error after ~20s timeout when using php's PDO::query method.

There is not much info about the issue out there, just notes on PHP.net sqlite-open and SQLite FAQ sites suggesting not to use SQLite in combination with NFS at all.

I was able to make it work by setting mount_opts: [local_lock=posix], but it slowed the system almost to the point of when I didn't use vagrant-winnfsd plugin at all considerably.

If anyone is aware of solution, please let me know. Anyway I believe it's worth to have a reference for other users to save some debug time.

Vagrant: 1.8.5 vagrant-winnfsd: 1.3.0 WinNFSd 2.2.0 PHP 5.6.14

marcharding commented 8 years ago

Hey i just tried it with a very simple SQLite script and had no problems. Can you provide me with a test case?

piotr-cz commented 8 years ago
<?php
$connection = new PDO('sqlite:test.sqlite');
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

try {
    $connection->exec(
        "CREATE TABLE IF NOT EXISTS testTable
        (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            column VARCHAR(225),
            document text
        )
    ");
} catch (PDOException $e) {
    die($e->getMessage());
}

die('SQLite Database created');

This should print message SQLite Database created, but without _locallock=posix prints SQLSTATE[HY000]: General error: 10 disk I/O error.

Does not matter if the sqlite-test.sqlite file has been created before or not.

My vagrant box is homestead v2.2.1

marcharding commented 8 years ago

That works with a default ubuntu box. I'll have to try with homestead...

marcharding commented 8 years ago

Ok got the same error in homestead with the default mount options. Just using rw,vers=3,udp,nolock works. Will take a look when i get some time.

iGitK72 commented 8 years ago

Any news on this? I ran into the same issue while using Behat on my homestead install using sqlite.

marcharding commented 8 years ago

Hey,

the problem is that winnfsd does not nlm (file locking) and i probably won't implement this any time soon.

If the share is mounted with the nolock option, it works without problems. This is the default behaviour with a normal vagrant config.

Laravel homestead does not do this by default, but you can force it to:

In homestead/scripts/homestead.rb replace the following:

if settings.include? 'folders'
  settings["folders"].each do |folder|
    mount_opts = []

    if (folder["type"] == "nfs")
      mount_opts = folder["mount_opts"] ? folder["mount_opts"] : ['actimeo=1']
    end

    config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil, mount_options: mount_opts
  end
end

with this:

if settings.include? 'folders'
  settings["folders"].sort! { |a,b| a["map"].length <=> b["map"].length }

  settings["folders"].each do |folder|
    config.vm.synced_folder folder["map"], folder["to"], 
    id: folder["map"],
    :nfs => true,
    :mount_options => ['nolock,vers=3,udp']
  end
end

Source