Page 1 of 2

env_meta error

Posted: Fri May 03, 2019 10:03
by Miniontoby
I got now every time when I going to make a ctf map this error

Code: Select all

2019-05-03 11:59:28: WARNING[Server]: Failed to write to file: ~\bin\..\worlds\ctf_mapmake\env_meta.txt
2019-05-03 11:59:28: ERROR[Server]: An unhandled exception occurred: Couldn't save env meta
2019-05-03 11:59:28: ERROR[Server]: In thread 8:
2019-05-03 11:59:28: ERROR[Server]: /home/stefan/mt-build/build/minetest_64/minetest/src/server.cpp:74: run: A fatal error occurred: Couldn't save env meta
Does anyone has a solution?

Re: env_meta error

Posted: Sat May 04, 2019 00:26
by ANAND
Does this only happen when making a CTF map?

Re: env_meta error

Posted: Sat May 04, 2019 08:10
by Miniontoby
no, it had happened before

Re: env_meta error

Posted: Sat May 04, 2019 11:43
by ANAND
This seems to be a "SerializationError". The file is probably corrupted or inaccessible. Try deleting ~\bin\..\worlds\ctf_mapmake\env_meta.txt, and try again.

Re: env_meta error

Posted: Tue May 07, 2019 16:02
by Miniontoby
That doesn't work

Re: env_meta error

Posted: Fri May 10, 2019 12:16
by Miniontoby

Code: Select all

2019-03-23 10:27:32: WARNING[Server]: Failed to write to file: XXX\bin\..\worlds\youtube\env_meta.txt
2019-03-23 10:27:32: ERROR[Server]: An unhandled exception occurred: Couldn't save env meta
2019-03-23 10:27:32: ERROR[Server]: In thread e:
2019-03-23 10:27:32: ERROR[Server]: /home/stefan/mt-build/build/minetest_64/minetest/src/server.cpp:74: run: A fatal error occurred: Couldn't save env meta

Code: Select all

2019-05-10 12:55:51: WARNING[Server]: Failed to write to file: XXX\bin\..\worlds\youtube\env_meta.txt
2019-05-10 12:55:51: ERROR[Server]: An unhandled exception occurred: Couldn't save env meta
2019-05-10 12:55:51: ERROR[Server]: In thread 15:
2019-05-10 12:55:51: ERROR[Server]: /home/stefan/mt-build/build/minetest_64/minetest/src/server.cpp:74: run: A fatal error occurred: Couldn't save env meta

Code: Select all

2019-05-10 13:57:32: WARNING[Server]: Failed to write to file: XXX\bin\..\worlds\youtube\env_meta.txt
2019-05-10 13:57:32: ERROR[Server]: An unhandled exception occurred: Couldn't save env meta
2019-05-10 13:57:32: ERROR[Server]: In thread 9:
2019-05-10 13:57:32: ERROR[Server]: /home/stefan/mt-build/build/minetest_64/minetest/src/server.cpp:74: run: A fatal error occurred: Couldn't save env meta

Code: Select all

2019-05-10 12:55:51: WARNING[Server]: Failed to write to file: XXX\bin\..\worlds\youtube\env_meta.txt
2019-05-10 12:55:51: ERROR[Server]: An unhandled exception occurred: Couldn't save env meta
2019-05-10 12:55:51: ERROR[Server]: In thread 14:
2019-05-10 12:55:51: ERROR[Server]: /home/stefan/mt-build/build/minetest_64/minetest/src/server.cpp:74: run: A fatal error occurred: Couldn't save env meta

Code: Select all

2019-05-13 14:23:52: WARNING[Server]: Failed to write to file: XXX\bin\..\worlds\server_daconcepts.com_30000\env_meta.txt
2019-05-13 14:23:52: ERROR[Server]: An unhandled exception occurred: Couldn't save env meta
2019-05-13 14:23:52: ERROR[Server]: In thread f:
2019-05-13 14:23:52: ERROR[Server]: /home/stefan/mt-build/build/minetest_64/minetest/src/server.cpp:74: run: A fatal error occurred: Couldn't save env meta
I have got some more other errors (look at the all 3rd lines)

Re: env_meta error

Posted: Fri May 10, 2019 16:40
by pgimeno
This may well be another missing lock in the threading code. The temporary file that safeWriteToFile creates is not really thread-safe, it's just the original name with .~mt appended.

Please don't use multiple emerge threads.

Re: env_meta error

Posted: Fri May 10, 2019 17:46
by pgimeno
Miniontoby wrote:

Code: Select all

/src/server.cpp:74: run: A fatal error occurred: Couldn't save env meta
What version is that? Line 74 doesn't make sense for such an error.

Re: env_meta error

Posted: Fri May 10, 2019 18:43
by Miniontoby
I have no idea??

Re: env_meta error

Posted: Fri May 10, 2019 21:49
by pgimeno
You don't know what Minetest version you're using? o.O

Re: env_meta error

Posted: Sat May 11, 2019 06:42
by ANAND
pgimeno: The error is actually here https://github.com/minetest/minetest/bl ... t.cpp#L657

I don't understand what this has to do with server.cpp:74, as it's only called in lines 283 and 989.

Re: env_meta error

Posted: Sat May 11, 2019 10:46
by Miniontoby
I use Minetest version 5.0.1

Re: env_meta error

Posted: Sat May 11, 2019 13:18
by Miniontoby
Does anyone has a solution????

Re: env_meta error

Posted: Sat May 11, 2019 13:40
by pgimeno
ANAND wrote:pgimeno: The error is actually here https://github.com/minetest/minetest/bl ... t.cpp#L657

I don't understand what this has to do with server.cpp:74, as it's only called in lines 283 and 989.
Me neither. It enters there only when safeWriteToFile returns false. In turn, safeWriteToFile emits the warning and returns false when renaming the temporary file fails. https://github.com/minetest/minetest/bl ... ys.cpp#736

My hypothesis was that lack of locking was causing a race where the file was renamed by a thread and then another thread tried to rename it and failed (because the name of the temporary file is the same for all threads). However, on inspection, the only callers to saveMeta I've found are all in server.cpp, and they are protected with the same lock. The callers I've found are:

Destructor
AsyncRunStep()

As you can see, both have their locks in place.

I don't see how this can be diagnosed without the ability to reproduce the issue, add debug info and so on.

Re: env_meta error

Posted: Sat May 11, 2019 16:24
by pgimeno
Miniontoby wrote:Does anyone has a solution????
Try setting num_emerge_threads = 1; that will probably solve it.

How many do you have currently? It looks like 20 or more because one of the threads that gave errors had ID 15h = 21.

Re: env_meta error

Posted: Sun May 12, 2019 01:41
by ANAND
Ah, another num_emerge_threads quirk :)

Re: env_meta error

Posted: Sun May 12, 2019 13:27
by Miniontoby
I have set it (but it was already setted) and I try a world and get the error

Code: Select all

2019-05-12 15:21:53: WARNING[Server]: Failed to write to file: XXX\bin\..\worlds\server_daconcepts.com_30000\env_meta.txt
2019-05-12 15:21:53: ERROR[Server]: An unhandled exception occurred: Couldn't save env meta
2019-05-12 15:21:53: ERROR[Server]: In thread 14:
2019-05-12 15:21:53: ERROR[Server]: /home/stefan/mt-build/build/minetest_64/minetest/src/server.cpp:74: run: A fatal error occurred: Couldn't save env meta

Re: env_meta error

Posted: Sun May 12, 2019 13:30
by Miniontoby
pgimeno wrote:
Miniontoby wrote:Does anyone has a solution????
Try setting num_emerge_threads = 1; that will probably solve it.

How many do you have currently? It looks like 20 or more because one of the threads that gave errors had ID 15h = 21.
Where do you found the "ID 15h = 21"???

Re: env_meta error

Posted: Sun May 12, 2019 14:54
by pgimeno
Miniontoby wrote:I have set it (but it was already setted) and I try a world and get the error

Code: Select all

2019-05-12 15:21:53: WARNING[Server]: Failed to write to file: XXX\bin\..\worlds\server_daconcepts.com_30000\env_meta.txt
2019-05-12 15:21:53: ERROR[Server]: An unhandled exception occurred: Couldn't save env meta
2019-05-12 15:21:53: ERROR[Server]: In thread 14:
2019-05-12 15:21:53: ERROR[Server]: /home/stefan/mt-build/build/minetest_64/minetest/src/server.cpp:74: run: A fatal error occurred: Couldn't save env meta
You don't seem to be setting it right

Sorry, I was wrong. The thread id is not the internal Minetest emerge thread id as I thought it was. It's the result of std::this_thread::get_id(), which can be something entirely different.

Re: env_meta error

Posted: Sun May 12, 2019 14:58
by Miniontoby
thanks for the convert hint, but I have no idea how that can.

I do now this script

Code: Select all

minetest.exe --worldname server_daconcepts.com_30000 --console --logfile XXX\serverdebug.txt 

Re: env_meta error

Posted: Sun May 12, 2019 15:26
by pgimeno
Edited my post, I was wrong, sorry.

Please try this. Using a terminal, change to the directory of your world, then type these:

Code: Select all

cp env_meta.txt env_meta.txt.~mt
mv env_meta.txt.~mt env_meta.txt
and report the output (or tell us if it succeeds).

Re: env_meta error

Posted: Sun May 12, 2019 15:30
by Miniontoby
When I start the world as a server it does do it

Re: env_meta error

Posted: Mon May 13, 2019 14:55
by Miniontoby
pgimeno wrote:Edited my post, I was wrong, sorry.

Please try this. Using a terminal, change to the directory of your world, then type these:

Code: Select all

cp env_meta.txt env_meta.txt.~mt
mv env_meta.txt.~mt env_meta.txt
and report the output (or tell us if it succeeds).
It does work (, I think)

Re: env_meta error

Posted: Mon May 13, 2019 16:14
by pgimeno
Miniontoby wrote:It does work (, I think)
That means that the problem is not in the file. For some reason the rename succeeds in the command line but it fails in the client. Without a client that can emit diagnostics (in particular the errno for the rename operation) I don't think anyone can do anything.

Do you think you can compile your own Minetest with this patch applied?

https://notabug.org/pgimeno/minetest/co ... 9f49.patch

For example, in my case, when I use chattr +i env_meta.txt, the patched version says:

Code: Select all

2019-05-13 18:09:09: WARNING[Server]: Failed to write to file: $MINETEST/bin/../worlds/carpastuff/env_meta.txt (error code: 1)
and error code 1 is EPERM (no permisson to write to the file).

Re: env_meta error

Posted: Tue May 14, 2019 08:46
by Miniontoby
I have Windows 10 and I think I can't compile it. Do you have option??