What is the Version Control System that Stack Overflow uses for managing revisions of questions and answers, and is there information on the architecture employed? I had come across a post on MSE about the "tools and technologies" that Stack Exchange uses in the past and GitLab is mentioned under "External Bits". I would guess that GitLab is used for this task. But in what way? Does C# code talk with ROR endpoints? How many repositories are there? One repository for the whole of Stack Overflow? One repository per question? I could be way off, of course. But I would like some input.
1 Answer
The production database schema is probably different on details but what we get on SEDE is close enough to get an idea how this works.
Each site on the network will have their own database. Each database has two main tables that handle Questions and Answers:
The posts table and the posthistory table.
The posts table hold in the rows with posttypeid = 1 the questions, and in posttypeid =2 the answers.
For a row in the posts table the events that happened in history of the post are stored in the posthistory table, basically all posthistorytypeids < 10 are related to editing of a post. A revisionguid is used to keep track of records that belong to one revision.
The posts table stores the rendered html (as you see it on the site) where the posthistory table stores the raw markdown (basically how you posted it).
For information on how the actual diffing is done see the link provided by jonrsharpe, Smarter diff algorithm for revision history.
GitLab is used internally as the version control system for the code that makes up the site. It is not used in any way for tracking revisions of a post on the sites.
See also the database schema documentation for the public data dump and SEDE and the awesome blog posts from Nick Craver.
-
The company has a unified database, this is behind the stackexchange.com . Only ordinary mortals can not see it. If they are doing some... more sophisticated data collection and processing, they are using probably this data. Although they clearly show that they don't do it.– peterhCommented Oct 2, 2020 at 18:51
PostHistory
contain whole posts or diffs?