Auto-assigning issues using a GitHub Action
by Andrew Lock
posted on: January 05, 2021
Creating my first GitHub app with Probot - Part 4
by Andrew Lock
posted on: January 05, 2021
Creating my first GitHub app with Probot - Part 4
by Oren Eini
posted on: January 04, 2021
My talk to the Azure Israel about Cosmos DB is up (in Hebrew)…
by Gérald Barré
posted on: January 04, 2021
If you use an internal NuGet server or just want to be explicit on the sources to use to restore package, you need to set the source in the NuGet configuration. You can use the dotnet nuget command to manage sources:Shellcopydotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.o
by Oren Eini
posted on: December 28, 2020
We got an interesting question a few times in recent weeks. How can I manually create a document revision with RavenDB? The answer for that is that you can use the ForceRevisionCreationFor() method to do so. Here is how you’ll typically use this API: This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters using (var session = store.OpenSession()) { var company = new Company { Name = "HR" }; session.Store(company); session.Advanced.Revisions.ForceRevisionCreationFor(company); session.SaveChanges(); } view raw force-revisions.cs hosted with ❤ by GitHub This is the typical expected usage for the API. We intended this to make it so users can manually triggers revisions, for example, when moving a document from draft mode to public and the like.It turns out that there is another reason to want to use this API, when you migrate data to RavenDB and want to create historical revisions. The API we envisioned isn’t suitable for this, but the layered API in RavenDB means that we can still get the desired behavior. Here is how we can achieve this: This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters using (var session = store.OpenSession()) { session.Advanced.Defer(new PutCommandData("users/1", null, new DynamicJsonValue { ["Name"] = "Oren" })); session.Advanced.Defer(new ForceRevisionCommandData("users/1")); session.Advanced.Defer(new PutCommandData("users/1", null, new DynamicJsonValue { ["Name"] = "Ayende" })); session.Advanced.Defer(new ForceRevisionCommandData("users/1")); session.SaveChanges(); } view raw force-multi-revisions.cs hosted with ❤ by GitHub Basically, we manually create the transaction steps that will run on the server, and we can apply the command to the same document multiple times. Note that RavenDB requires a document to create a revision from it, so we set the document, create a revision and overwrite the document again, as many times as we need to. Another issue that was brought up is that the @last-modified property on the document is set to the date of the revision creation. In some cases, they want to do this to get the revision to be created at the right time it was originally created during the migration period. That is not supported by RavenDB, because the @last-modified is tracking the time that RavenDB modified the document or revision. If you need to track the time a document was modified in the domain, you need to keep that as part of your actual domain model.
by Gérald Barré
posted on: December 28, 2020
I received an email from a service that catches spelling errors, grammar errors, and broken links on websites. They spam website owners to sell their services. Here's the content of the email:I wrote 340 posts and there are only 27 errors, I was happy 😃 But getting 0 error is still better. So, I c
by Ardalis
posted on: December 24, 2020
There is some debate about whether the movie Die Hard (1988) should be categorized as a Christmas movie. On the one side are those who point…Keep Reading →
by Oren Eini
posted on: December 22, 2020
Alex has been writing a sample application in RavenDB and has been getting deep into the details of how to architect a non trivial system.He recently published: Power of Dynamic fields for indexing dictionaries and collections in RavenDB – how to deal with dynamic fields, which joins the previous post:Yet Another Bug Tracker (YABT)NoSQL Data Model through the DDD prismHidden side of document IDs in RavenDBPower of Dynamic fields for indexing dictionaries and collections in RavenDB This makes for an interesting read and walks you through the entire process. There are more in the pipeline…
by Oren Eini
posted on: December 21, 2020
I wrote an article on DZone that explores some of the new possibilities that RavenDB 5.1 enables. You can read it here, and as usual, I would love to hear your feedback.
by Gérald Barré
posted on: December 21, 2020
An IEnumerable<T> can be costly to enumerate. If you need to do it twice or more, you'll pay the cost each time you enumerate it. For instance, if you use Directory.EnumerateFiles(), it will enumerate the file system each time you start enumerating the results. You can use ToList or ToArray t
by Oren Eini
posted on: December 18, 2020
Valgrind is an essential tool for anyone who is working with native code, especially if you are running C or C++ code. I have a codebase that is about 15,000 lines of C code, and Valgrind is absolutely essential for me to check my work. It has caught quite a few of my slips.I recently switched systems and when running the same code using Valgrind, I started to get annoying warnings, like this:==16896== --16896-- WARNING: Serious error when reading debug info --16896-- When reading debug info from /tmp/test.txt: --16896-- can't read file to inspect ELF header ==16896==The key issue is that this is, as you can imagine, a data file, why is Valgrind attempting to read ELF details from the file? It took me a while to narrow things down, but I found that I could reproduce this easily with the following code: This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters #define _GNU_SOURCE /* See feature_test_macros(7) */ #include <fcntl.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <sys/mman.h> int main() { int fd = open("test.txt", O_RDWR|O_CREAT|O_TRUNC|O_DSYNC|O_DIRECT|O_CLOEXEC, S_IRUSR | S_IWUSR); if(fd == -1) { printf("file can't be opened\n"); return 1; } int ret = ftruncate(fd, 256*1024); if(ret == -1){ printf("file can't be extended\n"); return 1; } char* buf = mmap(0, 1024*64, PROT_READ, MAP_SHARED , fd, 0); if(buf == MAP_FAILED){ printf("cannot map\n"); return 1; } munmap(buf, 1024*64); close(fd); return 0; } view raw a.c hosted with ❤ by GitHub If you’ll run this code with the following command, you should see the warning:clang a.c && valgrind ./a.outNote that this is with clang 10.0.0-4ubuntu1 and valgrind-3.16.1. I decided to check what Valgrind is doing using strace, which gave the following output: This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters openat(AT_FDCWD, "test.txt", O_RDWR|O_CREAT|O_TRUNC|O_DSYNC|O_DIRECT|O_CLOEXEC, 0600) = 3 ftruncate(3, 262144) = 0 mmap(0x4a4d000, 262144, PROT_READ, MAP_SHARED|MAP_FIXED, 3, 0) = 0x4a4d000 statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=262144, ...}) = 0 readlink("/proc/self/fd/3", "/tmp/test.txt", 4096) = 13 statx(AT_FDCWD, "/tmp/test.txt", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=262144, ...}) = 0 pread64(3, 0x1002ea98a0, 1024, 0) = -1 EINVAL (Invalid argument) view raw strace.log hosted with ❤ by GitHub Digging a little deeper, let’s highlight the root cause of this:openat(AT_FDCWD, "test.txt", O_RDWR|O_CREAT|O_TRUNC|O_DSYNC|O_DIRECT|O_CLOEXEC, 0600) = 3mmap(0x4a4d000, 262144, PROT_READ, MAP_SHARED|MAP_FIXED, 3, 0) = 0x4a4d000pread64(3, 0x1002ea98a0, 1024, 0) = -1 EINVAL (Invalid argument)I’m opening the test.txt file using the O_DIRECT file, which limits the kind of things that you can do with the file. In particular, it means that all access should be on page aligned memory. The pread64() call is not using a page aligned buffer to read from the file.What is interesting is that my code isn’t issuing any such call, this is coming from inside of Valgrind itself. In particular, I believe that this is the offending piece of code: di_notify_mmap is called whenever we map code, and is complex. The basic issue is that it does not respect the limits of files created with O_DIRECT and that causes the pread() call to fail. At this point, Valgrind outputs the warning.Brief look at the code indicate that this should be fine. This is a data mapping, not executable mapping, but it still make the attempt. Debugging into Valgrind is beyond the scope of what I want to do. For now, I changed things so any mmap() won’t use the file descriptor with O_DIRECT, and that resolved things for me.